|
45 | 45 | https://github.com/adafruit/circuitpython/releases
|
46 | 46 | * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
|
47 | 47 | """
|
48 |
| -import atexit |
49 | 48 | import math
|
50 | 49 | import time
|
51 | 50 |
|
@@ -321,7 +320,6 @@ def __init__(self, i2c, address=41, io_timeout_s=0):
|
321 | 320 | self._perform_single_ref_calibration(0x00)
|
322 | 321 | # "restore the previous Sequence Config"
|
323 | 322 | self._write_u8(_SYSTEM_SEQUENCE_CONFIG, 0xE8)
|
324 |
| - atexit.register(self._cleanup) |
325 | 323 |
|
326 | 324 | def _read_u8(self, address):
|
327 | 325 | # Read an 8-bit unsigned value from the specified 8-bit address.
|
@@ -458,11 +456,6 @@ def _get_sequence_step_timeouts(self, pre_range):
|
458 | 456 | pre_range_mclks,
|
459 | 457 | )
|
460 | 458 |
|
461 |
| - def _cleanup(self): |
462 |
| - #when exiting, don't forget to also turn off continuous mode |
463 |
| - if (self._continuous_mode): |
464 |
| - self.stopContinuous() |
465 |
| - |
466 | 459 | @property
|
467 | 460 | def signal_rate_limit(self):
|
468 | 461 | """The signal rate limit in mega counts per second."""
|
@@ -543,7 +536,7 @@ def range(self):
|
543 | 536 | """
|
544 | 537 | # Adapted from readRangeSingleMillimeters in pololu code at:
|
545 | 538 | # https://github.com/pololu/vl53l0x-arduino/blob/master/VL53L0X.cpp
|
546 |
| - if (not self._continuous_mode): |
| 539 | + if not self._continuous_mode: |
547 | 540 | self.doRangeMeasurement()
|
548 | 541 | return self.readRange()
|
549 | 542 |
|
@@ -600,7 +593,7 @@ def continuous_mode(self):
|
600 | 593 |
|
601 | 594 | @continuous_mode.setter
|
602 | 595 | def continuous_mode(self, enabled):
|
603 |
| - if (enabled): |
| 596 | + if enabled: |
604 | 597 | self.startContinuous()
|
605 | 598 | else:
|
606 | 599 | self.stopContinuous()
|
@@ -642,7 +635,7 @@ def stopContinuous(self):
|
642 | 635 | (0x00, 0x00),
|
643 | 636 | (0x91, 0x00),
|
644 | 637 | (0x00, 0x01),
|
645 |
| - (0xFF, 0x00) |
| 638 | + (0xFF, 0x00), |
646 | 639 | ):
|
647 | 640 | self._write_u8(pair[0], pair[1])
|
648 | 641 | self._continuous_mode = False
|
|
0 commit comments