refactor(ui): audit-pass fixes + dead-code/redundancy cleanup

Fixes from a full ui-new audit (OLED + e-ink both build green):
- remove dead DisplayDriver::drawScrollArrows (all lists use drawScrollIndicator)
- SettingsScreen selection bar -> lineStep()-1, matching the drawList screens
- HomeScreen: don't force the 1s blink refresh on the CLOCK page (status icons
  are hidden there anyway)
- FullscreenMsgView: clamp KEY_DOWN scroll to a cached _max_scroll instead of
  over-incrementing and leaning on the next render to clamp
- DataStore: clamp use_lemon_font (>1 -> 0) on load, like the other enum fields
- move the ~1.5KB wrap scratch (trans/lines) off the render stack into shared
  file-scope statics in FullscreenMsgView (single-threaded UI; the fullscreen
  view and history list never lay out in the same frame)

Cleanup:
- drop dead members RingtoneEditorScreen::DUR_VALS and HomeScreen::sensors_scroll
- delete redundant manual scroll-clamps in handleInput across the drawList
  screens (drawList already reclamps each render); remove the now-unused _visible
  from QuickMsgScreen/NearbyScreen/BotScreen and BotScreen::scrollToSel()

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-06-16 08:54:11 +02:00
co-authored by Claude Opus 4.8
parent da161d49d2
commit f591cddf4f
10 changed files with 60 additions and 107 deletions
+5 -12
View File
@@ -11,8 +11,7 @@ class BotScreen : public UIScreen {
static const int ITEM_COUNT = 9;
int _sel;
int _scroll; // index of first visible item
int _visible; // items fitting on screen; updated each render, used by handleInput
int _scroll; // index of first visible item (managed by drawList in render)
bool _dirty;
// keyboard state (reused for trigger and reply fields)
@@ -32,12 +31,6 @@ class BotScreen : public UIScreen {
}
}
// Keep the selected row inside the visible window (_visible set by render()).
void scrollToSel() {
if (_sel < _scroll) _scroll = _sel;
else if (_sel >= _scroll + _visible) _scroll = _sel - _visible + 1;
}
// Returns index into _channel_indices[] for current bot_channel_idx, or -1 if not found/disabled.
int currentChannelListIdx() const {
if (!_prefs->bot_channel_enabled) return -1;
@@ -52,7 +45,6 @@ public:
void enter() {
_sel = 0;
_scroll = 0;
_visible = 1;
_kb_field = -1;
_dirty = false;
refreshChannels();
@@ -82,7 +74,7 @@ public:
static const char* labels[] = { "Enable", "Channel", "Trigger DM", "Reply DM",
"Trigger Ch", "Reply Ch", "Commands",
"Quiet from", "Quiet to" };
_visible = drawList(display, ITEM_COUNT, _sel, _scroll, [&](int i, int y, bool sel, int reserve) {
drawList(display, ITEM_COUNT, _sel, _scroll, [&](int i, int y, bool sel, int reserve) {
display.drawSelectionRow(0, y - 1, display.width() - reserve, display.lineStep() - 1, sel);
display.setCursor(2, y);
display.print(labels[i]);
@@ -153,8 +145,9 @@ public:
_task->gotoToolsScreen();
return true;
}
if (up && _sel > 0) { _sel--; scrollToSel(); return true; }
if (down && _sel < ITEM_COUNT - 1) { _sel++; scrollToSel(); return true; }
// drawList() reclamps _scroll from _sel every render.
if (up && _sel > 0) { _sel--; return true; }
if (down && _sel < ITEM_COUNT - 1) { _sel++; return true; }
if (_sel == 0 && (enter || left || right)) {
_prefs->bot_enabled ^= 1;