UncleRus / esp-idf-lib

Component library for ESP32-xx and ESP8266
https://esp-idf-lib.readthedocs.io/en/latest/
1.39k stars 437 forks source link

When using the Button component to implement buttons and building the project, an error message "BUTTON_PRESSED undeclared here" occurs. #515

Closed swkang0513 closed 1 year ago

swkang0513 commented 1 year ago

The issue

The code is unable to find the button_state_t type declared in the button.h header file. In the main.c file, both and are included, and functions and variables are written similar to the example. However, the following code was written for testing, but the build fails.

static const char *states[] = {
    [BUTTON_PRESSED] = "pressed",
    [BUTTON_RELEASED] = "released",
    [BUTTON_CLICKED] = "clicked",
    [BUTTON_PRESSED_LONG] = "pressed long",
};

// in app_main()
btn1.gpio = PIN_PW_BTN;
btn1.pressed_level = 1;
btn1.internal_pull = true;
btn1.autorepeat = false;
btn1.callback = on_button;

btn2.gpio = PIN_LI_BTN;
btn2.pressed_level = 1;
btn2.internal_pull = true;
btn2.autorepeat = false;
btn2.callback = on_button;

ESP_ERROR_CHECK(button_init(&btn1));
ESP_ERROR_CHECK(button_init(&btn2));

I am using ESP32-WROOM-32E and ESP-IDF v5.0.1.

Which SDK are you using?

esp-idf

Which version of SDK are you using?

master

Which build target have you used?

Component causing the issue

button

Anything in the logs that might be useful for us?

No response

Additional information or context

No response

Confirmation