perf(ui-lvgl): lower clock when idle, fewer redraws, wake on BLE frames

- CPU at 80 MHz with the screen on after 2 s without touch or animation;
  a touch restores the full clock before its frame is drawn
- setText(): periodic refreshes no longer redraw unchanged labels
  (status bar, Home, lock, Diag, GPS, compass, clock, map, nav, nearby)
- map markers kept across the 3 s rebuild when unchanged
- app connected: the loop blocks until a BLE frame arrives
  (serialFrameArrived / hasPendingFrames) instead of polling every 2 ms
- PSRAM: boot frame sprite and the HTTP response buffer released

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-09-29 11:51:18 +02:00
co-authored by Claude Opus 5.5
parent bc266a4f5c
commit 4ab9d949ec
19 changed files with 188 additions and 82 deletions
+4
View File
@@ -25,6 +25,10 @@ public:
// isConnected() so single-transport interfaces are unchanged.
virtual bool isClientConnected() const { return isConnected(); }
// For a loop that sleeps between passes: frames waiting to be read or sent.
// An interface that can't tell says true (poll it often).
virtual bool hasPendingFrames() const { return true; }
virtual bool isWriteBusy() const = 0;
virtual size_t writeFrame(const uint8_t src[], size_t len) = 0;
virtual size_t checkRecvFrame(uint8_t dest[]) = 0;
+5
View File
@@ -52,6 +52,11 @@ public:
bool isClientConnected() const override { return isBLEConnected(); }
#endif
// USB can't tell without reading it.
bool hasPendingFrames() const override {
return (_ble_enabled && _ble.isConnected()) ? _ble.hasPendingFrames() : true;
}
bool isWriteBusy() const override {
return (_ble_enabled && _ble.isConnected()) ? _ble.isWriteBusy() : _usb.isWriteBusy();
}
+3
View File
@@ -10,6 +10,8 @@
#define ADVERT_RESTART_DELAY 1000 // millis
__attribute__((weak)) void serialFrameArrived() {}
// As the nRF52 interface: 20-30 ms for the first 30 s (the app finds it at
// once), then 152.5 ms. Left alone, the library advertises every 30-60 ms
// for as long as nothing is connected. Units of 0.625 ms.
@@ -187,6 +189,7 @@ void SerialBLEInterface::onWrite(BLECharacteristic* pCharacteristic, esp_ble_gat
if (xQueueSend(recv_queue, &frame, 0) != pdTRUE) {
BLE_DEBUG_PRINTLN("ERROR: onWrite(), recv_queue is full!");
}
serialFrameArrived();
}
}
+5
View File
@@ -8,6 +8,10 @@
#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>
// A frame from the app was queued (the BLE stack's task). Weak, empty by
// default: a firmware whose loop blocks between passes defines it to wake it.
void serialFrameArrived();
class SerialBLEInterface : public BaseSerialInterface, BLESecurityCallbacks, BLEServerCallbacks, BLECharacteristicCallbacks {
BLEServer *pServer;
BLEService *pService;
@@ -102,6 +106,7 @@ public:
bool isConnected() const override;
bool hasPendingFrames() const override { return send_queue_len > 0 || uxQueueMessagesWaiting(recv_queue) > 0; }
bool isWriteBusy() const override;
size_t writeFrame(const uint8_t src[], size_t len) override;
size_t checkRecvFrame(uint8_t dest[]) override;