mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 19:02:00 +00:00
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:
@@ -72,6 +72,14 @@ struct Grid {
|
||||
bool tiled = false; // every visible cell holds a tile: grid and fill are under them
|
||||
};
|
||||
static Grid s_grid; // the main map's
|
||||
|
||||
// The view moved (or the step changed): the grid with it, and the area
|
||||
// redrawn -- not when a refresh finds it where it was.
|
||||
static void setGrid(lv_obj_t* area, Grid& g, double left, double top, double step_px) {
|
||||
if (g.left == left && g.top == top && g.step_px == step_px) return;
|
||||
g.left = left; g.top = top; g.step_px = step_px;
|
||||
lv_obj_invalidate(area);
|
||||
}
|
||||
static lv_obj_t* s_scale_bar = nullptr;
|
||||
static lv_obj_t* s_scale_lbl = nullptr;
|
||||
|
||||
@@ -280,10 +288,7 @@ static void onMapMarker(lv_event_t* e) {
|
||||
|
||||
// The centre-on-me button in the accent colour while the map follows you.
|
||||
static void followShown(lv_obj_t* btn, bool on) {
|
||||
if (!btn) return;
|
||||
lv_obj_t* l = lv_obj_get_child(btn, 0);
|
||||
lv_color_t c = lv_color_hex(on ? theme::ACCENT : theme::TEXT);
|
||||
if (!lv_color_eq(lv_obj_get_style_text_color(l, LV_PART_MAIN), c)) lv_obj_set_style_text_color(l, c, 0);
|
||||
if (btn) setTextColor(lv_obj_get_child(btn, 0), on ? theme::ACCENT : theme::TEXT);
|
||||
}
|
||||
|
||||
static lv_obj_t* mapButton(lv_obj_t* parent, const char* text, lv_event_cb_t cb) {
|
||||
@@ -505,12 +510,11 @@ void UITask::layoutMap() {
|
||||
{ // the grid under the tiles, the scale bar
|
||||
char sl[16];
|
||||
double lat = atan(sinh(M_PI * (1 - 2 * _map_cy / (double)(1 << _map_z)))) * 180.0 / M_PI;
|
||||
mapview::s_grid = { left, top, mapview::gridStep(_map_z, lat, _prefs && _prefs->units_imperial, 56, sl, sizeof(sl)) };
|
||||
mapview::setGrid(_map_area, mapview::s_grid, left, top, mapview::gridStep(_map_z, lat, _prefs && _prefs->units_imperial, 56, sl, sizeof(sl)));
|
||||
if (mapview::s_scale_lbl) {
|
||||
setText(mapview::s_scale_lbl, sl);
|
||||
lv_obj_set_width(mapview::s_scale_bar, (int)lround(mapview::s_grid.step_px));
|
||||
}
|
||||
lv_obj_invalidate(_map_area);
|
||||
}
|
||||
int tx0 = (int)floor(left / mapview::TILE_PX), ty0 = (int)floor(top / mapview::TILE_PX);
|
||||
int n = 1 << _map_z;
|
||||
|
||||
Reference in New Issue
Block a user