mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
WIP: Esp8266 Get Function (#1438)
machine/esp8266: add Pin Get() support
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user