feat(ui-lvgl): power saving, review fixes, shared helpers

Power: the UI loop sleeps until something is due (never with packets
queued); screen off puts the CPU at 80 MHz, the GT911 to sleep (unless a
tap wakes the screen) and the LP5814 in standby. GPS off now cuts the
L76K's rail and UART on the L2 (L2GpsProvider). The battery divider is
powered only for a reading (measured: settles at once); readings within
2 s are reused. The SD mount is retried at most every 5 s.

Fixes: WiFi left on after leaving a scan, live tiles' WiFi kept with the
screen off on the map, an ADC read every second for the status bar, touch
polled on every pass while dark, a scan cutting an update's WiFi, relay
count not refreshing in a channel thread, raw @[nick] in room previews.
Labels skip unchanged text (no redraw).

Helpers: scrollList, dimOverlay, settingRow, flexBox, nvs::get/put,
trailFilePath (a second save in the same minute no longer overwrites),
unreadTotal. Dead code removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-09-27 00:12:08 +02:00
co-authored by Claude Opus 5.5
parent f5206f10b4
commit 23caa11f51
23 changed files with 337 additions and 347 deletions
+18 -7
View File
@@ -33,6 +33,7 @@ class WioTrackerL2Backlight : public lgfx::v1::ILight {
static constexpr uint8_t REG_LED0_PWM = 0x18;
uint8_t _brightness = 153; // 60%
bool _standby = false; // chip disabled (the screen is off)
void writeReg(uint8_t reg, uint8_t value) {
Wire.beginTransmission(LP5814_I2C_ADDR);
@@ -41,13 +42,7 @@ class WioTrackerL2Backlight : public lgfx::v1::ILight {
Wire.endTransmission();
}
public:
bool init(uint8_t brightness) override {
Wire.beginTransmission(LP5814_I2C_ADDR);
if (Wire.endTransmission() != 0) {
return false; // LP5814 not found
}
void configure() {
writeReg(REG_DEVICE_CONFIG0, 0x01); // chip enable
writeReg(REG_MAX_CURRENT, 0x01); // 51 mA max current
writeReg(REG_ENABLE_CONTROL, 0x00); // outputs off while configuring
@@ -59,12 +54,28 @@ public:
writeReg(REG_ENABLE_CONTROL, 0x0F); // enable all 4 channels
writeReg(REG_UPDATE, 0x55); // latch (LP5814 requires 0x55)
delay(5);
}
public:
bool init(uint8_t brightness) override {
Wire.beginTransmission(LP5814_I2C_ADDR);
if (Wire.endTransmission() != 0) {
return false; // LP5814 not found
}
configure();
setBrightness(brightness);
return true;
}
// 0 (LovyanGFX's sleep()) puts the chip in standby; the next level brings it
// back, set up again.
void setBrightness(uint8_t brightness) override {
if (brightness == 0) {
writeReg(REG_DEVICE_CONFIG0, 0x00); // chip disable: standby
_standby = true;
return;
}
if (_standby) { configure(); _standby = false; }
for (uint8_t i = 0; i < 4; i++) {
writeReg(REG_LED0_PWM + i, brightness);
}