5353 16 : 0x0A00 ,
5454}
5555
56+ # Pins
57+ A0 = 0
58+ """Analog Pin 0"""
59+ A1 = 1
60+ """Analog Pin 1"""
61+ A2 = 2
62+ """Analog Pin 2"""
63+ A3 = 3
64+ """Analog Pin 3"""
65+
5666
5767class Mode :
5868 """An enum-like class representing possible ADC operating modes."""
@@ -141,7 +151,9 @@ def __init__(
141151 ):
142152 self ._last_pin_read = None
143153 self .buf = bytearray (3 )
144- self .initialized = False # Prevents writing to ADC until all values are initialized
154+ self .initialized = (
155+ False # Prevents writing to ADC until all values are initialized
156+ )
145157 self .i2c_device = I2CDevice (i2c , address )
146158 self .gain = gain
147159 self .data_rate = self ._data_rate_default () if data_rate is None else data_rate
@@ -214,7 +226,9 @@ def comparator_queue_length(self) -> int:
214226 def comparator_queue_length (self , comparator_queue_length : int ) -> None :
215227 possible_comp_queue_lengths = self .comparator_queue_lengths
216228 if comparator_queue_length not in possible_comp_queue_lengths :
217- raise ValueError (f"Comparator Queue must be one of: { possible_comp_queue_lengths } " )
229+ raise ValueError (
230+ f"Comparator Queue must be one of: { possible_comp_queue_lengths } "
231+ )
218232 self ._comparator_queue_length = comparator_queue_length
219233 if self .initialized :
220234 self ._write_config ()
@@ -243,7 +257,9 @@ def comparator_low_threshold(self, value: int) -> None:
243257 :param int value: 16-bit signed integer to write to register
244258 """
245259 if value < - 32768 or value > 32767 :
246- raise ValueError ("Comparator Threshold value must be between -32768 and 32767" )
260+ raise ValueError (
261+ "Comparator Threshold value must be between -32768 and 32767"
262+ )
247263
248264 self ._comparator_low_threshold = value
249265 self ._write_register (_ADS1X15_POINTER_LO_THRES , self .comparator_low_threshold )
@@ -255,7 +271,9 @@ def comparator_high_threshold(self, value: int) -> None:
255271 :param int value: 16-bit signed integer to write to register
256272 """
257273 if value < - 32768 or value > 32767 :
258- raise ValueError ("Comparator Threshold value must be between -32768 and 32767" )
274+ raise ValueError (
275+ "Comparator Threshold value must be between -32768 and 32767"
276+ )
259277
260278 self ._comparator_high_threshold = value
261279 self ._write_register (_ADS1X15_POINTER_HI_THRES , self .comparator_high_threshold )
@@ -423,20 +441,28 @@ def _read_config(self) -> None:
423441 config_value = self ._read_register (_ADS1X15_POINTER_CONFIG )
424442
425443 self .gain = next (
426- key for key , value in _ADS1X15_CONFIG_GAIN .items () if value == (config_value & 0x0E00 )
444+ key
445+ for key , value in _ADS1X15_CONFIG_GAIN .items ()
446+ if value == (config_value & 0x0E00 )
427447 )
428448 self .data_rate = next (
429- key for key , value in self .rate_config .items () if value == (config_value & 0x00E0 )
449+ key
450+ for key , value in self .rate_config .items ()
451+ if value == (config_value & 0x00E0 )
430452 )
431453 self .comparator_queue_length = next (
432454 key
433455 for key , value in _ADS1X15_CONFIG_COMP_QUEUE .items ()
434456 if value == (config_value & 0x0003 )
435457 )
436458 self .mode = Mode .SINGLE if config_value & 0x0100 else Mode .CONTINUOUS
437- self .comparator_mode = Comp_Mode .WINDOW if config_value & 0x0010 else Comp_Mode .TRADITIONAL
459+ self .comparator_mode = (
460+ Comp_Mode .WINDOW if config_value & 0x0010 else Comp_Mode .TRADITIONAL
461+ )
438462 self .comparator_polarity = (
439- Comp_Polarity .ACTIVE_HIGH if config_value & 0x0008 else Comp_Polarity .ACTIVE_LOW
463+ Comp_Polarity .ACTIVE_HIGH
464+ if config_value & 0x0008
465+ else Comp_Polarity .ACTIVE_LOW
440466 )
441467 self .comparator_latch = (
442468 Comp_Latch .LATCHING if config_value & 0x0004 else Comp_Latch .NONLATCHING
0 commit comments