perf(l2): no redraws while nothing changes

Found by counting flushes on idle screens in the sim:
- The compose field's cursor blinked (a redraw every 400 ms) as soon as
  a conversation opened, the keyboard hidden: lv_keyboard_set_textarea()
  focuses the field, and LVGL only stops a blink when the cursor moves.
  fieldFocus() sets the state and nudges the blink; also used for the
  WiFi and channel fields, which left theirs running.
- lv_obj_align_to() restyles on every call, so the status bar's icons
  redrew every second; placeLeftOf() moves them only when they move.
- Text colours set every second (nav bar, GPS status, Diag errors) go
  through setTextColor(), which skips an unchanged colour.
- A LV_LABEL_LONG_DOT label writes its "..." into its own text, so
  setText() never matched and rewrote it every refresh (the nav bar's
  hint); labelShows() reads past the dots.
- The map area, the area-outline, trail and vector-label layers were
  invalidated on every map refresh (every 3 s, a full-map redraw); now
  only when the view or what they draw changed.

Idle map: 17 -> 1 flush in 5 s; list and settings screens: 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-09-30 23:22:31 +02:00
co-authored by Claude Opus 5.5
parent 74efb6addd
commit 1ff58d4a81
10 changed files with 102 additions and 43 deletions
+19 -10
View File
@@ -280,7 +280,16 @@ static void layoutNavTrail(double scale) {
using namespace navmap;
s_pts_n = 0;
if (!s_trail) return;
lv_obj_invalidate(s_trail);
{ // redrawn when the view or the trail changed, not on every map refresh
static double v_left = NAN, v_top, v_scale;
static int v_n;
static uint32_t v_gen, v_seq;
if (v_left != mapview::s_left || v_top != mapview::s_top || v_scale != scale || v_n != s_sync_n || v_gen != s_sync_gen || v_seq != s_sync_seq) {
v_left = mapview::s_left; v_top = mapview::s_top; v_scale = scale;
v_n = s_sync_n; v_gen = s_sync_gen; v_seq = s_sync_seq;
lv_obj_invalidate(s_trail);
}
}
int n = s_sync_n;
if (!s_pts || n < 2) return;
lv_area_t a;
@@ -393,12 +402,12 @@ void UITask::refreshNavBar() {
bool pos = navCurrentTarget(tlat, tlon, name, sizeof(name), person, set);
if (!set) {
setText(_nav_title, "No target");
lv_obj_set_style_text_color(_nav_title, lv_color_hex(theme::TEXT_MUTED), 0);
setTextColor(_nav_title, theme::TEXT_MUTED);
setText(_nav_info, "Tap here to pick a target, or hold the map on a spot");
lv_obj_add_flag(_nav_clear, LV_OBJ_FLAG_HIDDEN);
return;
}
lv_obj_set_style_text_color(_nav_title, lv_color_hex(theme::ACCENT), 0);
setTextColor(_nav_title, theme::ACCENT);
lv_obj_remove_flag(_nav_clear, LV_OBJ_FLAG_HIDDEN);
setTextFmt(_nav_title, "%s %s", navmap::s_tb.active() ? LV_SYMBOL_LOOP : person ? UI_SYMBOL_USERS : UI_SYMBOL_FLAG,
name);
@@ -1039,19 +1048,19 @@ void UITask::refreshNavTools() {
navmap::fmtDuration(dur, sizeof(dur), ts.elapsedSeconds());
const char* state = !ts.isActive() ? (ts.empty() ? "Not recording" : "Stopped")
: ts.isPaused() ? "Paused (standing still)" : "Recording";
if (ts.empty()) lv_label_set_text(_nav_trail_lbl, state);
else lv_label_set_text_fmt(_nav_trail_lbl, "%s - %s, %s, %d points", state, dist, dur, ts.count());
lv_label_set_text(_nav_trail_btn, ts.isActive() ? LV_SYMBOL_STOP " Stop" : LV_SYMBOL_PLAY " Record");
lv_label_set_text(_nav_tb_btn, navmap::s_tb.active() ? LV_SYMBOL_STOP " Stop back" : LV_SYMBOL_LOOP " Track back");
if (ts.empty()) setText(_nav_trail_lbl, state);
else setTextFmt(_nav_trail_lbl, "%s - %s, %s, %d points", state, dist, dur, ts.count());
setText(_nav_trail_btn, ts.isActive() ? LV_SYMBOL_STOP " Stop" : LV_SYMBOL_PLAY " Record");
setText(_nav_tb_btn, navmap::s_tb.active() ? LV_SYMBOL_STOP " Stop back" : LV_SYMBOL_LOOP " Track back");
if (_prefs->loc_share_enabled) {
char left[12];
navmap::fmtDuration(left, sizeof(left), _core->live_share.remainingSecs());
lv_label_set_text_fmt(_nav_share_lbl, "Sharing your position - %s left", left);
setTextFmt(_nav_share_lbl, "Sharing your position - %s left", left);
} else {
lv_label_set_text(_nav_share_lbl, "Off. Sends your position while you move, then stops by itself.");
setText(_nav_share_lbl, "Off. Sends your position while you move, then stops by itself.");
}
lv_label_set_text(_nav_share_btn, _prefs->loc_share_enabled ? LV_SYMBOL_STOP " Stop sharing" : LV_SYMBOL_PLAY " Share live");
setText(_nav_share_btn, _prefs->loc_share_enabled ? LV_SYMBOL_STOP " Stop sharing" : LV_SYMBOL_PLAY " Share live");
}
void UITask::navSetShareTarget(int sel) {