real working wake button

This commit is contained in:
2025-03-04 11:53:52 +01:00
parent dd661e10fd
commit f17034ddcf
5 changed files with 13 additions and 4 deletions

View File

@@ -16,6 +16,8 @@ public:
void reset_slow_isr(); // FIXME:
void delay(int slow_ms, int normal_ms);
void install_isr();
private:
PowerHelper();

View File

@@ -9,7 +9,7 @@
class Shutdowner {
public:
static Shutdowner& get();
void install_isr();
private:
Shutdowner();
};

View File

@@ -43,9 +43,13 @@ extern "C" void app_main() {
printf("Hello world!\n");
// TODO: Where to put that?
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup());
ESP_ERROR_CHECK(gpio_install_isr_service(0));
// For some reason, calling it here hangs on startup, sometimes
// ESP_ERROR_CHECK(gpio_install_isr_service(0));
PowerHelper::get();
Shutdowner::get();
ESP_ERROR_CHECK(gpio_install_isr_service(0));
Shutdowner::get().install_isr();
PowerHelper::get().install_isr();
Buttons::get();
I2cGlobal::get();
BatMon::get();

View File

@@ -47,7 +47,7 @@ PowerHelper::PowerHelper() : _event_group(xEventGroupCreate()) {
ESP_ERROR_CHECK(gpio_set_intr_type(DIRECT_BTN, GPIO_INTR_HIGH_LEVEL));
ESP_ERROR_CHECK(gpio_wakeup_enable(DIRECT_BTN, GPIO_INTR_HIGH_LEVEL));
// ESP_ERROR_CHECK(gpio_install_isr_service(0));
gpio_isr_handler_add(DIRECT_BTN, wakeup, this);
// gpio_isr_handler_add(DIRECT_BTN, wakeup, this);
set_slow(false);
}
@@ -67,3 +67,4 @@ void PowerHelper::delay(int slow_ms, int normal_ms) {
vTaskDelay(normal_ms / portTICK_PERIOD_MS);
}
}
void PowerHelper::install_isr() { gpio_isr_handler_add(DIRECT_BTN, wakeup, this); }

View File

@@ -33,5 +33,7 @@ Shutdowner::Shutdowner() {
ESP_ERROR_CHECK(gpio_wakeup_enable(PWR_INT, GPIO_INTR_LOW_LEVEL));
// ESP_ERROR_CHECK(gpio_install_isr_service(0));
ESP_ERROR_CHECK(gpio_hold_en(PWR_KILL));
gpio_isr_handler_add(PWR_INT, shutdown, nullptr);
// gpio_isr_handler_add(PWR_INT, shutdown, nullptr);
}
void Shutdowner::install_isr() { gpio_isr_handler_add(PWR_INT, shutdown, nullptr); }