mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 10:51:57 +00:00
refactor(eink): Text size and Icon size as schema settings, on opt-in builds only
Review follow-up: - The rows exist only where the build asks for them: Text size with EINK_FONT_SCALE, Icon size with STATUS_ICON_SCALE. The stock 2.13", the portrait builds and the L2 don't get them -- their screens are laid out for one cell size. The text override also applies in landscape only. - Stored in NodePrefs (ui_text_scale, ui_icon_scale) instead of a /ui_scale file, as rows in the schema's Display section: the usual row, save path and factory reset, and console keys display.text.size / display.icon.size. The hand-written Settings rows and the load/save code are gone; UITask::applyUiScale() applies the prefs at boot and on change (applyDisplayPrefs). On opt-in builds ui_text_scale starts at the build's EINK_FONT_SCALE (DataStore sanitize), so the row shows the scale in use. - EINK_FONT_SCALE, when set, now scales whichever landscape font the build picks (the 6x9, or the EINK_LARGE_FONT one); unset, it is stock as before. - setUiScale() skips the re-layout and full redraw when nothing changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2063,7 +2063,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
|
||||
applyBrightness();
|
||||
applyRotation();
|
||||
applyFullRefreshInterval();
|
||||
loadUiScale(); // Settings > Display > Text size / Icon size
|
||||
applyUiScale(); // Settings > Display > Text size / Icon size
|
||||
applyAllGpioModes(); // restore persisted pin modes to hardware before any UI/bot use
|
||||
// Locked above (a PIN, or the cover closed) before Home existed to be told.
|
||||
if (_locked) syncLockToHome();
|
||||
@@ -4163,57 +4163,17 @@ void UITask::applyFullRefreshInterval() {
|
||||
}
|
||||
}
|
||||
|
||||
// Text size and Icon size (Settings > Display), in their own /ui_scale file --
|
||||
// [text pixel scale (0 = build default), icon scale (0 = Auto)] -- so the
|
||||
// NodePrefs schema is untouched.
|
||||
static const char* UI_SCALE_FILE = "/ui_scale";
|
||||
static const uint8_t UI_TEXT_SCALE_MAX = 5;
|
||||
|
||||
void UITask::loadUiScale() {
|
||||
uint8_t b[2] = { 0, statusIconScaleSetting() };
|
||||
DataStore* ds = the_mesh.getDataStore();
|
||||
if (ds) {
|
||||
File f = ds->openRead(UI_SCALE_FILE);
|
||||
if (f) {
|
||||
f.read(b, 2);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
_ui_font_scale = b[0] <= UI_TEXT_SCALE_MAX ? b[0] : 0;
|
||||
if (b[1] <= STATUS_ICON_SCALE_MAX) statusIconScaleSetting() = b[1];
|
||||
if (_display != NULL && _ui_font_scale) _display->setUiScale(_ui_font_scale);
|
||||
}
|
||||
|
||||
void UITask::saveUiScale() {
|
||||
DataStore* ds = the_mesh.getDataStore();
|
||||
if (!ds) return;
|
||||
File f = ds->openWrite(UI_SCALE_FILE);
|
||||
if (f) {
|
||||
uint8_t b[2] = { _ui_font_scale, statusIconScaleSetting() };
|
||||
f.write(b, 2);
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t UITask::getUiFontScale() const {
|
||||
return _display != NULL ? (uint8_t)_display->pixelScale() : 1;
|
||||
}
|
||||
|
||||
void UITask::setUiFontScale(uint8_t s) {
|
||||
if (s < 1 || s > UI_TEXT_SCALE_MAX) s = 1;
|
||||
_ui_font_scale = s;
|
||||
if (_display != NULL) _display->setUiScale(s);
|
||||
_next_refresh = 0;
|
||||
saveUiScale();
|
||||
}
|
||||
|
||||
uint8_t UITask::getStatusIconScale() const { return statusIconScaleSetting(); }
|
||||
|
||||
void UITask::setStatusIconScale(uint8_t s) {
|
||||
if (s > STATUS_ICON_SCALE_MAX) s = 0;
|
||||
statusIconScaleSetting() = s;
|
||||
_next_refresh = 0; // the frame differs, so it's redrawn
|
||||
saveUiScale();
|
||||
// Text size and Icon size (Settings > Display, NodePrefs ui_text_scale /
|
||||
// ui_icon_scale), on the builds that offer them. Elsewhere the fields stay 0:
|
||||
// the build's font scale and Auto icons, as stock.
|
||||
void UITask::applyUiScale() {
|
||||
if (!_node_prefs) return;
|
||||
#ifdef EINK_FONT_SCALE
|
||||
if (_display != NULL) _display->setUiScale(_node_prefs->ui_text_scale);
|
||||
#endif
|
||||
#if STATUS_ICONS_SCALED
|
||||
statusIconScaleSetting() = _node_prefs->ui_icon_scale;
|
||||
#endif
|
||||
}
|
||||
|
||||
void UITask::applySoundPrefs() {
|
||||
|
||||
Reference in New Issue
Block a user