Skip to content

Commit e8062a0

Browse files
committed
update mode to continuous_mode
1 parent 901b475 commit e8062a0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

adafruit_mcp3421/mcp3421.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(
7878

7979
self.gain = self._gain
8080
self.resolution = self._resolution
81-
self.mode = self._mode
81+
self.continuous_mode = self._mode
8282

8383
self.adc_data = bytearray(4)
8484

@@ -171,7 +171,7 @@ def resolution(self, value: int) -> None:
171171
device.write(bytes([config_byte]))
172172

173173
@property
174-
def mode(self) -> bool:
174+
def continuous_mode(self) -> bool:
175175
"""
176176
Current mode setting from the device
177177
@@ -183,8 +183,8 @@ def mode(self) -> bool:
183183
except Exception as error:
184184
raise OSError(f"Failed to read mode from device: {error}") from error
185185

186-
@mode.setter
187-
def mode(self, value: bool) -> None:
186+
@continuous_mode.setter
187+
def continuous_mode(self, value: bool) -> None:
188188
self._mode = value
189189
config_byte = self._register_value
190190
with self.i2c_device as device:

examples/mcp3421_simpletest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@
2828
while True:
2929
print(f"ADC value: {adc_channel.value}")
3030
print(f"Current gain: {adc.gain}X")
31+
print(f"Current resolution: {adc.resolution}-bit")
32+
if adc.continuous_mode:
33+
mode = "continuous"
34+
else:
35+
mode = "one-shot"
36+
print(f"Mode: {mode}")
3137
print()
3238
time.sleep(0.01)

0 commit comments

Comments
 (0)