Skip to content

Commit 2eb122f

Browse files
committed
Add _SET_ANALOG_READ_CMD command handler type and set_analog_read command handler.
1 parent f493d66 commit 2eb122f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
_SET_DIGITAL_WRITE_CMD = const(0x51)
102102
_SET_ANALOG_WRITE_CMD = const(0x52)
103103
_SET_DIGITAL_READ_CMD = const(0x53)
104+
_SET_ANALOG_READ_CMD = const(0x54)
104105

105106
_START_CMD = const(0xE0)
106107
_END_CMD = const(0xEE)
@@ -790,6 +791,19 @@ def set_digital_read(self, pin):
790791
((pin,),))[0]
791792
return resp[0]
792793

794+
def set_analog_read(self, pin):
795+
"""
796+
Get the analog input value of pin.
797+
798+
:param int pin: ESP32 GPIO pin to read from.
799+
"""
800+
resp = self._send_command_get_response(_SET_ANALOG_READ_CMD,
801+
((pin,),))[0]
802+
resp_a = struct.unpack('<i', resp[0])
803+
if resp_a == (-1,):
804+
raise ValueError("_SET_ANALOG_READ parameter error -1")
805+
return resp_time
806+
793807
def get_time(self):
794808
"""The current unix timestamp"""
795809
if self.status == WL_CONNECTED:

0 commit comments

Comments
 (0)