mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-01 10:21:59 +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:
@@ -29,7 +29,7 @@ class EinkGfxDisplay : public DisplayDriver {
|
||||
uint16_t _curr;
|
||||
const GFXfont* _font;
|
||||
int _cell_w = 6, _cell_h = 9; // the font's cell, before _px and the text size
|
||||
int _px = 1; // pixel doubling (landscape without EINK_LARGE_FONT)
|
||||
int _px = 1; // pixel multiplier (landscape: EINK_FONT_PX, or Text size)
|
||||
uint8_t _px_override = 0; // Settings > Display > Text size (0 = build default)
|
||||
int _text_sz = 1;
|
||||
int _cx = 0, _cy = 0; // cursor, top of the text row
|
||||
@@ -77,7 +77,11 @@ public:
|
||||
bool isEink() override { return true; }
|
||||
// Runtime text scale (Settings > Display > Text size): re-lays out and forces
|
||||
// a full redraw. 0 = the build default (EINK_FONT_SCALE).
|
||||
void setUiScale(uint8_t font_scale) override { _px_override = font_scale; updateLayout(); }
|
||||
void setUiScale(uint8_t font_scale) override {
|
||||
if (font_scale == _px_override) return; // unchanged: no full redraw
|
||||
_px_override = font_scale;
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
void startFrame(Color bkg = DARK) override;
|
||||
void setTextSize(int sz) override;
|
||||
|
||||
@@ -3,11 +3,15 @@
|
||||
// the font tables below are static arrays.
|
||||
|
||||
#include "EinkGfxDisplay.h"
|
||||
// EINK_FONT_SCALE=<n>: pixel multiplier for the 6x9 font on a landscape panel
|
||||
// without EINK_LARGE_FONT (default 2). 4 on an 800x480 panel = 24x36 cells,
|
||||
// ~33 characters x 13 lines. Settings > Display > Text size overrides it at run time.
|
||||
#ifndef EINK_FONT_SCALE
|
||||
#define EINK_FONT_SCALE 2
|
||||
// EINK_FONT_SCALE=<n>: pixel multiplier for the landscape font -- the 6x9, or
|
||||
// the EINK_LARGE_FONT one if the build picks it. 4 on an 800x480 panel with the
|
||||
// 6x9 = 24x36 cells, ~33 characters x 13 lines. Setting it also adds Settings >
|
||||
// Display > Text size, which overrides it at run time. Unset: stock, the 6x9 at
|
||||
// 2x or the large font at its own size.
|
||||
#ifdef EINK_FONT_SCALE
|
||||
#define EINK_FONT_PX EINK_FONT_SCALE
|
||||
#else
|
||||
#define EINK_FONT_PX (EINK_LARGE_FONT ? 1 : 2)
|
||||
#endif
|
||||
#include "MiscFixedRenderer.h"
|
||||
#if EINK_LARGE_FONT == 2
|
||||
@@ -26,8 +30,8 @@ EinkGfxDisplay::EinkGfxDisplay(int w, int h, Adafruit_GFX& gfx, uint16_t ink, ui
|
||||
void EinkGfxDisplay::updateLayout() {
|
||||
const bool landscape = width() >= height();
|
||||
_font = (EINK_LARGE_FONT && landscape) ? &EINK_LARGE_GFXFONT : &MiscFixed;
|
||||
_px = (!EINK_LARGE_FONT && landscape) ? EINK_FONT_SCALE : 1;
|
||||
if (_px_override) _px = _px_override;
|
||||
_px = landscape ? EINK_FONT_PX : 1;
|
||||
if (_px_override && landscape) _px = _px_override; // portrait screens are laid out for 1x
|
||||
_cell_w = miscFixedCellW(*_font);
|
||||
_cell_h = _font->yAdvance;
|
||||
_vw_dirty = true;
|
||||
|
||||
Reference in New Issue
Block a user