From fbd4e580291b24681e1162f5ec64b00d2a6cb650 Mon Sep 17 00:00:00 2001 From: uvok Date: Mon, 21 Jul 2025 07:47:08 +0200 Subject: Attempt to light sleep results in wdt error --- src/main.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 5dcd051..810a4f7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,6 +46,8 @@ void setup() void loop() { + static uint32_t lastActivity; + uint16_t pressDuration = de::uvok::badge::gpio_poll(); if (pressDuration < 64) { @@ -58,16 +60,15 @@ void loop() newNum = de::uvok::badge::display_refresh(); if (newNum != UINT8_MAX) + { de::uvok::badge::ble_set_image(newNum); + lastActivity = millis(); + } } else if (pressDuration > PRESS_TIME_BLE_ADV) { de::uvok::badge::ble_advertise(); - } - else if (pressDuration > PRESS_TIME_DRAW) - { - Serial.println("Drawing..."); - de::uvok::badge::display_demo(); + lastActivity = millis(); } { @@ -75,12 +76,14 @@ void loop() if (pollres.has_data) { de::uvok::badge::display_direct(pollres.new_template); + lastActivity = millis(); } } - // if (millis() - releasedTime > SLEEP_TIME && !pAdvertising->isAdvertising()) - // { - // Serial.println("Go to sleep..."); - // esp_light_sleep_start(); - // } + if (false && millis() - lastActivity > SLEEP_TIME && !de::uvok::badge::ble_is_advertising()) + { + // RTC watchdog??? + esp_sleep_enable_timer_wakeup(10 * 1000); + esp_light_sleep_start(); + } } -- cgit v1.2.3