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

mattismyo
Posts: 29
Joined: Sat Jun 10, 2017 6:56 am

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

Postby mattismyo » Wed Aug 02, 2017 4:14 pm

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.

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

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

Postby ESP_krzychb » Wed Aug 02, 2017 5:15 pm

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

Who is online

Users browsing this forum: No registered users and 123 guests