diff options
author | Connor <[email protected]> | 2020-10-22 11:58:44 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-22 20:58:44 +0200 |
commit | 6eeebfeb5c2423f34a031de70682905efee293d0 (patch) | |
tree | bdae6f816e329490a41750a2e70eba5af66a0735 /src/machine/machine_esp8266.go | |
parent | 6ab0106af37abf65bdc9e41912d7e8a46db9bd8d (diff) | |
download | tinygo-6eeebfeb5c2423f34a031de70682905efee293d0.tar.gz tinygo-6eeebfeb5c2423f34a031de70682905efee293d0.zip |
WIP: Esp8266 Get Function (#1438)
machine/esp8266: add Pin Get() support
Diffstat (limited to 'src/machine/machine_esp8266.go')
-rw-r--r-- | src/machine/machine_esp8266.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/machine/machine_esp8266.go b/src/machine/machine_esp8266.go index 78eccc059..5570e7e02 100644 --- a/src/machine/machine_esp8266.go +++ b/src/machine/machine_esp8266.go @@ -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 { |