machine/esp8266: add Pin Get() support
Этот коммит содержится в:
Connor 2020-10-22 11:58:44 -07:00 коммит произвёл GitHub
родитель 6ab0106af3
коммит 6eeebfeb5c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23

Просмотреть файл

@ -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 {