mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 23:27:49 +01:00
real working wake button
This commit is contained in:
@@ -16,6 +16,8 @@ public:
|
|||||||
void reset_slow_isr(); // FIXME:
|
void reset_slow_isr(); // FIXME:
|
||||||
void delay(int slow_ms, int normal_ms);
|
void delay(int slow_ms, int normal_ms);
|
||||||
|
|
||||||
|
void install_isr();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PowerHelper();
|
PowerHelper();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
class Shutdowner {
|
class Shutdowner {
|
||||||
public:
|
public:
|
||||||
static Shutdowner& get();
|
static Shutdowner& get();
|
||||||
|
void install_isr();
|
||||||
private:
|
private:
|
||||||
Shutdowner();
|
Shutdowner();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,9 +43,13 @@ extern "C" void app_main() {
|
|||||||
printf("Hello world!\n");
|
printf("Hello world!\n");
|
||||||
// TODO: Where to put that?
|
// TODO: Where to put that?
|
||||||
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup());
|
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();
|
PowerHelper::get();
|
||||||
Shutdowner::get();
|
Shutdowner::get();
|
||||||
|
ESP_ERROR_CHECK(gpio_install_isr_service(0));
|
||||||
|
Shutdowner::get().install_isr();
|
||||||
|
PowerHelper::get().install_isr();
|
||||||
Buttons::get();
|
Buttons::get();
|
||||||
I2cGlobal::get();
|
I2cGlobal::get();
|
||||||
BatMon::get();
|
BatMon::get();
|
||||||
|
|||||||
@@ -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_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_wakeup_enable(DIRECT_BTN, GPIO_INTR_HIGH_LEVEL));
|
||||||
// ESP_ERROR_CHECK(gpio_install_isr_service(0));
|
// 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);
|
set_slow(false);
|
||||||
}
|
}
|
||||||
@@ -67,3 +67,4 @@ void PowerHelper::delay(int slow_ms, int normal_ms) {
|
|||||||
vTaskDelay(normal_ms / portTICK_PERIOD_MS);
|
vTaskDelay(normal_ms / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void PowerHelper::install_isr() { gpio_isr_handler_add(DIRECT_BTN, wakeup, this); }
|
||||||
|
|||||||
@@ -33,5 +33,7 @@ Shutdowner::Shutdowner() {
|
|||||||
ESP_ERROR_CHECK(gpio_wakeup_enable(PWR_INT, GPIO_INTR_LOW_LEVEL));
|
ESP_ERROR_CHECK(gpio_wakeup_enable(PWR_INT, GPIO_INTR_LOW_LEVEL));
|
||||||
// ESP_ERROR_CHECK(gpio_install_isr_service(0));
|
// ESP_ERROR_CHECK(gpio_install_isr_service(0));
|
||||||
ESP_ERROR_CHECK(gpio_hold_en(PWR_KILL));
|
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); }
|
||||||
|
|||||||
Reference in New Issue
Block a user