WIP: Esp8266 Get Function (#1438)

machine/esp8266: add Pin Get() support
This commit is contained in:
Connor
2020-10-22 11:58:44 -07:00
committed by GitHub
parent 6ab0106af3
commit 6eeebfeb5c
+9
View File
@@ -107,6 +107,15 @@ func (p Pin) Configure(config PinConfig) {
}
}
// Get returns the current value of a GPIO pin when the pin is configured as an
// input.
func (p Pin) Get() bool {
// See this document for details
// https://www.espressif.com/sites/default/files/documentation/esp8266-technical_reference_en.pdf
return esp.GPIO.GPIO_IN.Get()&(1<<p) != 0
}
// Set sets the output value of this pin to high (true) or low (false).
func (p Pin) Set(value bool) {
if value {