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:
21
21
:param ~adafruit_seesaw.seesaw.Seesaw seesaw: The device
22
22
:param int pin: The pin number on the device"""
23
23
24
- def __init__ (self , seesaw , pin ):
24
+ def __init__ (self , seesaw , pin , delay = 0.008 ):
25
25
self ._seesaw = seesaw
26
26
self ._pin = pin
27
+ self ._delay = delay
27
28
28
29
def deinit (self ):
29
30
pass
30
31
31
32
@property
32
33
def value (self ):
33
34
"""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 )
35
36
36
37
@property
37
38
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):
242
242
self .read (_GPIO_BASE , _GPIO_INTFLAG , buf , delay = delay )
243
243
return struct .unpack (">I" , buf )[0 ]
244
244
245
- def analog_read (self , pin ):
245
+ def analog_read (self , pin , delay = 0.008 ):
246
246
"""Read the value of an analog pin by number"""
247
247
buf = bytearray (2 )
248
248
if pin not in self .pin_mapping .analog_pins :
@@ -253,13 +253,8 @@ def analog_read(self, pin):
253
253
elif self .chip_id == _SAMD09_HW_ID_CODE :
254
254
offset = self .pin_mapping .analog_pins .index (pin )
255
255
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 )
261
257
ret = struct .unpack (">H" , buf )[0 ]
262
- time .sleep (0.001 )
263
258
return ret
264
259
265
260
def touch_read (self , pin ):
You can’t perform that action at this time.
0 commit comments