feat(ui-lvgl): quick panel from the status bar; L2 fixes from rc1

The quick panel, as a phone's: pulled down from the status bar (or a tap
on it). Bluetooth, WiFi, GPS, sound, trail and live share switch at a
tap; Advert opens the advert popup (moved here from the Nodes header);
Lock locks the screen; a brightness slider. Holding a tile opens its
settings. Lock and sun glyphs added to the fonts.

Fixes from rc1 testing on the L2:
- GPS status icon: none when GPS is off (the module kept its last fix
  valid, so it stayed green); grey on, green with a fix. ensureGps()
  turns GPS on before trusting that stale fix.
- Screen wake: the panel wakes dark, a frame is drawn, then the
  backlight fades in -- no white flash. Off fades out first.
- Power off / flat battery: the chip wakes every 30 s to look for USB
  power and starts when plugged in (it slept with no wake source before,
  until the reset button). Plugged in when switched off: stays off until
  re-plugged.
- Message ages in a conversation refresh every 2 s, as on ui-new; the
  message popup keeps its age, repeaters heard and delivery up to date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-05 09:10:06 +02:00
co-authored by Claude Opus 5.5
parent d66f04ba94
commit b5e4845dae
17 changed files with 940 additions and 333 deletions
@@ -108,7 +108,43 @@ bool WioTrackerL2Board::initExpander() {
return true;
}
// Off -- Power off, or the battery ran down -- the chip sleeps, waking every
// OFF_POLL_SECS to look for USB power plugged in, and starts when it is: as
// an nRF board starts on its own once charged (a deep sleep with no wake
// source left it off until the reset button). Plugged in when switched off,
// it stays off until the cable is pulled and plugged in again. A look costs
// a boot as far as begin(), a fraction of a second.
static const uint32_t OFF_MAGIC = 0x4F464621; // "OFF!"
static const uint32_t OFF_POLL_SECS = 30;
RTC_NOINIT_ATTR static uint32_t s_off_magic;
RTC_NOINIT_ATTR static uint32_t s_off_vbus; // USB power at the last look
void WioTrackerL2Board::powerOff() {
s_off_vbus = isExternalPowered();
s_off_magic = OFF_MAGIC;
enterDeepSleep(OFF_POLL_SECS);
}
// Off and woken by the timer (or a brown-out of the flat battery): back to
// sleep unless USB power has come since the last look.
static void stayOffUnlessPlugged(WioTrackerL2Board& b) {
const esp_reset_reason_t r = esp_reset_reason();
if (s_off_magic != OFF_MAGIC || (r != ESP_RST_DEEPSLEEP && r != ESP_RST_BROWNOUT)) {
s_off_magic = 0;
return;
}
Wire.begin(PIN_BOARD_SDA, PIN_BOARD_SCL);
const bool vbus = b.isExternalPowered();
if (vbus && !s_off_vbus) { s_off_magic = 0; return; } // plugged in: start
s_off_vbus = vbus;
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL);
esp_sleep_enable_timer_wakeup(OFF_POLL_SECS * 1000000ULL);
esp_deep_sleep_start();
}
void WioTrackerL2Board::begin() {
stayOffUnlessPlugged(*this); // first: before the 3 s wait for a serial monitor below
// GNSS UART: NMEA arrives at ~500 B/s and the main loop can stall for
// hundreds of ms on SD tile decodes; the 256-byte default overflowed
Serial1.setRxBufferSize(1024);
@@ -82,6 +82,9 @@ public:
// VBUS presence via the AW35615 USB-C controller (I2C 0x22)
bool isExternalPowered() override;
// Off (Power off, or the battery ran down): see the .cpp
void powerOff() override;
private:
uint8_t out_shadow[2] = { 0xFF, 0xFF }; // TCA9535 output regs default high
uint8_t cfg_shadow[2] = { 0xFF, 0xFF }; // 1 = input (power-on default)
@@ -188,6 +188,20 @@ public:
class WioTrackerL2Display : public LGFXDisplay {
LGFX_WioTrackerL2 disp;
// The backlight from one PWM level to another over ~180 ms, on a square
// curve (the eye sees the low end's steps). Blocks; 0 ends in standby.
void fade(uint8_t from, uint8_t to) {
const int STEPS = 12;
for (int i = 1; i <= STEPS; i++) {
const int t = i * 256 / STEPS; // 0..256
const int k = from < to ? t * t / 256 : 256 - (256 - t) * (256 - t) / 256;
const int v = from + ((int)to - from) * k / 256;
display->panel()->setBrightness((uint8_t)(i == STEPS ? to : (v < 1 ? 1 : v)));
delay(15);
}
}
public:
WioTrackerL2Display() : LGFXDisplay(320, 240, disp) {}
@@ -197,6 +211,26 @@ public:
display->setBrightness(PWM[level > 4 ? 4 : level]);
}
// Screen off: the backlight fades out, then the panel sleeps. Screen on: the
// panel wakes with the light still off -- the caller draws a fresh frame
// first (the panel shows what's left in its memory for a moment, a white
// flash) -- and fadeIn() brings the light up.
void turnOff() override {
if (_isOn) {
fade(display->getBrightness(), 0);
display->sleep();
}
_isOn = false;
}
void turnOn() override {
if (!_isOn) {
display->panel()->setSleep(false);
delay(10); // the panel takes no pixels just out of sleep
}
_isOn = true;
}
void fadeIn() { fade(0, display->getBrightness()); }
// direct access to the LGFX device (LVGL flush/touch glue)
lgfx::LGFX_Device* lgfxDevice() { return &disp; }
Panel_WioTrackerL2& panel() { return disp.panelL2(); }