File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -21,17 +21,18 @@ class AnalogInput:
2121 :param ~adafruit_seesaw.seesaw.Seesaw seesaw: The device
2222 :param int pin: The pin number on the device"""
2323
24- def __init__ (self , seesaw , pin ):
24+ def __init__ (self , seesaw , pin , delay = 0.008 ):
2525 self ._seesaw = seesaw
2626 self ._pin = pin
27+ self ._delay = delay
2728
2829 def deinit (self ):
2930 pass
3031
3132 @property
3233 def value (self ):
3334 """The current analog value on the pin, as an integer from 0..65535 (inclusive)"""
34- return self ._seesaw .analog_read (self ._pin )
35+ return self ._seesaw .analog_read (self ._pin , self . _delay )
3536
3637 @property
3738 def reference_voltage (self ):
Original file line number Diff line number Diff line change @@ -242,7 +242,7 @@ def get_GPIO_interrupt_flag(self, delay=0.008):
242242 self .read (_GPIO_BASE , _GPIO_INTFLAG , buf , delay = delay )
243243 return struct .unpack (">I" , buf )[0 ]
244244
245- def analog_read (self , pin ):
245+ def analog_read (self , pin , delay = 0.008 ):
246246 """Read the value of an analog pin by number"""
247247 buf = bytearray (2 )
248248 if pin not in self .pin_mapping .analog_pins :
@@ -253,13 +253,8 @@ def analog_read(self, pin):
253253 elif self .chip_id == _SAMD09_HW_ID_CODE :
254254 offset = self .pin_mapping .analog_pins .index (pin )
255255
256- self .read (
257- _ADC_BASE ,
258- _ADC_CHANNEL_OFFSET + offset ,
259- buf ,
260- )
256+ self .read (_ADC_BASE , _ADC_CHANNEL_OFFSET + offset , buf , delay )
261257 ret = struct .unpack (">H" , buf )[0 ]
262- time .sleep (0.001 )
263258 return ret
264259
265260 def touch_read (self , pin ):
You can’t perform that action at this time.
0 commit comments