Page 1 of 1

Query state of button (pressed: yes/no?)

Posted: Wed Aug 02, 2017 4:14 pm
by mattismyo
How can i ask/query the state of a button? Like digitalread, if gpio == ghigh, etc in Arduino IDE? I found the gpio test example
https://github.com/espressif/esp-idf/bl ... pio_test.c
but i cant see how i can query the state of the button (which lines, searching simple example)? only thing i know is

Code: Select all

gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT)
to define my button as output.

Re: Query state of button (pressed: yes/no?)

Posted: Wed Aug 02, 2017 5:15 pm
by ESP_krzychb
This particular example is rather to demonstrate how to trigger interrupts depending on signal change on an input.

But it also contains a "simple" check for GPIO level in line: https://github.com/espressif/esp-idf/bl ... test.c#L55

The actual check is done for "io_num" by function "gpio_get_level(io_num)", see also: http://esp-idf.readthedocs.io/en/latest ... gpio_num_t