Reset interaction timeout on wake
Prevents the device from immediately going back to sleep, rendering it less responsive.
This commit is contained in:
parent
e6ee237dbf
commit
5fe1d93b7d
1 changed files with 9 additions and 2 deletions
|
@ -498,6 +498,10 @@ public:
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!awake) {
|
||||
awake = true;
|
||||
last_interaction_time = current_time;
|
||||
}
|
||||
if (current_time >= next_clock_update) {
|
||||
ESP_LOGD("LifeTracker", "Updating clock and battery display");
|
||||
next_clock_update = next_minute(current_time);
|
||||
|
@ -505,6 +509,8 @@ public:
|
|||
drawBattery();
|
||||
} else {
|
||||
if (current_time - last_interaction_time > INACTIVITY_THRESHOLD) {
|
||||
awake = false;
|
||||
drawBattery();
|
||||
int seconds = next_clock_update - current_time;
|
||||
ESP_LOGD("LifeTracker", "Sleep for %d seconds", seconds);
|
||||
M5.Power.lightSleep(seconds * 1000000, true); // Delay in microseconds
|
||||
|
@ -518,6 +524,7 @@ public:
|
|||
protected:
|
||||
enum Mode {Playing, CommanderDamage, ConfirmReset};
|
||||
Mode mode;
|
||||
bool awake = true;
|
||||
struct Rect {
|
||||
int x;
|
||||
int y;
|
||||
|
@ -739,7 +746,7 @@ protected:
|
|||
canvas.setTextColor(TFT_WHITE);
|
||||
canvas.setRotation(3);
|
||||
int battery = M5.Power.getBatteryLevel();
|
||||
canvas.printf("%3d%%", battery);
|
||||
canvas.printf("%3d%% %s", battery, awake ? " " : "zZ");
|
||||
canvas.pushSprite(0, M5.Display.height() - canvas.width());
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue