Code: Select all
esp_sleep_get_ext1_wakeup_status();
I would like to know if there is any design consideration while using these big switches, or if there is any hardware bug in older devkit modules that can cause this.
The code is pretty straight forward.
- void wake_up_pin()
- {
- esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();
- int GPIO_reason = esp_sleep_get_ext1_wakeup_status();
- if (wakeup_reason == ESP_SLEEP_WAKEUP_EXT1)
- {
- Serial.println("Waked up ext1");
- int k=(int)(log(GPIO_reason)/log(2));
- switch (k)
- {
- case 2:
- button[0].numberKeyPresses++;
- Serial.printf("Button 1 has been pressed %u times\n", button[0].numberKeyPresses);
- break;
- case 15:
- button[1].numberKeyPresses++;
- Serial.printf("Button 2 has been pressed %u times\n", button[1].numberKeyPresses);
- break;
- case 25:
- button[2].numberKeyPresses++;
- Serial.printf("Button 3 has been pressed %u times\n", button[2].numberKeyPresses);
- break;
- case 26:
- button[3].numberKeyPresses++;
- Serial.printf("Button 4 has been pressed %u times\n", button[3].numberKeyPresses);
- break;
- case 27:
- button[4].numberKeyPresses++;
- Serial.printf("Button 5 has been pressed %u times\n", button[4].numberKeyPresses);
- break;
- default:
- Serial.println(k);
- break;
- }
- }
- }
- setup()
- {
- esp_sleep_enable_ext1_wakeup(GPIO_SEL_2 | GPIO_SEL_15 | GPIO_SEL_25 | GPIO_SEL_26 | GPIO_SEL_27, ESP_EXT1_WAKEUP_ANY_HIGH);
- esp_deep_sleep_start();
- }