Skip to content

Commit f493d66

Browse files
committed
Add _SET_DIGITAL_READ_CMD command handler type and set_digital_read command handler.
1 parent 602250a commit f493d66

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
_SET_PIN_MODE_CMD = const(0x50)
101101
_SET_DIGITAL_WRITE_CMD = const(0x51)
102102
_SET_ANALOG_WRITE_CMD = const(0x52)
103+
_SET_DIGITAL_READ_CMD = const(0x53)
103104

104105
_START_CMD = const(0xE0)
105106
_END_CMD = const(0xEE)
@@ -779,6 +780,16 @@ def set_analog_write(self, pin, analog_value):
779780
if resp[0][0] != 1:
780781
raise RuntimeError("Failed to write to pin")
781782

783+
def set_digital_read(self, pin):
784+
"""
785+
Get the digital input value of pin.
786+
787+
:param int pin: ESP32 GPIO pin to read from.
788+
"""
789+
resp = self._send_command_get_response(_SET_DIGITAL_READ_CMD,
790+
((pin,),))[0]
791+
return resp[0]
792+
782793
def get_time(self):
783794
"""The current unix timestamp"""
784795
if self.status == WL_CONNECTED:

0 commit comments

Comments
 (0)