mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-03 02:36:11 +00:00
- GxEPDDisplay: fontAscender only applies to sz=1 with Lemon; sz=2 (NULL font) was incorrectly getting a 16px cursor offset, causing clock text to render 16px lower than expected and overlap the date line - KeyboardWidget: compute cell_h from available screen height instead of lh+1; tighten sep_y to lh so the grid fits within 122px even with Lemon font (lh=20) - SettingsScreen renderBar: constrain box size to available width so the 5th buzzer-volume square doesn't overflow past the right edge with Lemon font - NearbyScreen discover detail: manually truncate b64 public key by charWidth to guarantee one-line rendering; use dynamic step = (height-hdr)/5 so Status line doesn't fall off the bottom of the screen - NearbyScreen contacts detail: merge dist+az into one line and use dynamic step to fit 5 lines within the display; removes the off-screen Seen: row - AutoAdvertScreen: replace lineStep() gap before hints with 4px fixed gap so both hint lines fit within the display with large fonts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
#pragma once
|
|
// Configures periodic automatic 0-hop advert with GPS position.
|
|
// Included by UITask.cpp after DashboardConfigScreen.h.
|
|
|
|
class AutoAdvertScreen : public UIScreen {
|
|
UITask* _task;
|
|
NodePrefs* _prefs;
|
|
bool _dirty;
|
|
|
|
static const int OPT_COUNT = 8;
|
|
static const uint32_t OPTS[OPT_COUNT];
|
|
static const char* OPT_LABELS[OPT_COUNT];
|
|
|
|
int currentIdx() const {
|
|
for (int i = 0; i < OPT_COUNT; i++)
|
|
if (OPTS[i] == _prefs->advert_auto_interval_sec) return i;
|
|
return 0;
|
|
}
|
|
|
|
public:
|
|
AutoAdvertScreen(UITask* task, NodePrefs* prefs) : _task(task), _prefs(prefs) {}
|
|
|
|
void enter() { _dirty = false; }
|
|
|
|
int render(DisplayDriver& display) override {
|
|
display.setTextSize(1);
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
int label_y = display.listStart();
|
|
int bar_y = label_y + display.lineStep();
|
|
int bar_h = display.lineStep();
|
|
int tip_y = bar_y + bar_h + 4;
|
|
|
|
display.drawTextCentered(display.width() / 2, 0, "AUTO-ADVERT");
|
|
display.fillRect(0, display.headerH() - 1, display.width(), 1);
|
|
|
|
display.setCursor(2, label_y);
|
|
display.print("Interval:");
|
|
|
|
int idx = currentIdx();
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
display.fillRect(0, bar_y, display.width(), bar_h);
|
|
display.setColor(DisplayDriver::DARK);
|
|
display.drawTextCentered(display.width() / 2, bar_y + 1, OPT_LABELS[idx]);
|
|
display.setColor(DisplayDriver::LIGHT);
|
|
|
|
display.setCursor(2, tip_y);
|
|
display.print("< > to change");
|
|
display.setCursor(2, tip_y + display.lineStep());
|
|
display.print("[Esc] to save");
|
|
return 500;
|
|
}
|
|
|
|
bool handleInput(char c) override {
|
|
if (c == KEY_CANCEL || c == KEY_CONTEXT_MENU) {
|
|
if (_dirty) the_mesh.savePrefs();
|
|
_task->gotoToolsScreen();
|
|
return true;
|
|
}
|
|
bool right = (c == KEY_RIGHT || c == KEY_NEXT || c == KEY_ENTER);
|
|
bool left = (c == KEY_LEFT || c == KEY_PREV);
|
|
if (right || left) {
|
|
int idx = currentIdx();
|
|
idx = right ? (idx + 1) % OPT_COUNT : (idx + OPT_COUNT - 1) % OPT_COUNT;
|
|
_prefs->advert_auto_interval_sec = OPTS[idx];
|
|
_dirty = true;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
const uint32_t AutoAdvertScreen::OPTS[AutoAdvertScreen::OPT_COUNT] = { 0, 30, 60, 120, 300, 600, 1800, 3600 };
|
|
const char* AutoAdvertScreen::OPT_LABELS[AutoAdvertScreen::OPT_COUNT] = { "off", "30s", "1min", "2min", "5min", "10min", "30min", "1h" };
|