feat(ui/clock): stacked big-digit clock on portrait e-ink

On a tall portrait e-ink panel the clock and lock screens wasted most of
the vertical space on a small inline "HH:MM". Render HH and MM on two
lines in a new size-4 font (built-in GFX scaled 7×, ~42×56 px) so the
digits roughly double in height and fill the narrow width. Wide panels
(OLED, landscape e-ink) keep the classic single-line size-2 layout.

- New shared drawClockTime() helper used by both the Clock home page and
  the lock screen; returns the y below the time block so the date and
  dashboard rows flow beneath it.
- GxEPDDisplay: size 4 = built-in font × BIG_TEXT_SCALE (7); getCharWidth /
  getLineHeight / setTextSize handle it; fontAscender stays 0 (built-in is
  top-left origin).
- Centre the big digits on their visible glyph width — the built-in font
  advances 6 px per char but the glyph is 5 px wide, so getTextWidth over-
  reports by one trailing column and the digits would sit ~half a column
  left of centre. AM/PM rendered one size larger (size 2).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-06-02 23:32:27 +02:00
parent 49536cb3a5
commit 5b25d1eb32
3 changed files with 73 additions and 24 deletions

View File

@@ -141,6 +141,12 @@ void GxEPDDisplay::setTextSize(int sz) {
// Size 3 always uses FreeSans18pt for large headings.
int sc = scale();
switch (sz) {
case 4:
// Huge clock digits: built-in font scaled up. Cursor stays top-left
// (fontAscender returns 0 for the built-in font), so layout maths is plain.
display.setFont(NULL);
display.setTextSize(BIG_TEXT_SCALE);
break;
case 3:
display.setFont(&FreeSans18pt7b);
display.setTextSize(1);

View File

@@ -93,16 +93,21 @@ public:
// 1 = FreeSans9pt (lineH=16, charW≈9)
// 2 = FreeSansBold12pt (lineH=20, charW≈12)
// 3 = FreeSans18pt (lineH=28, charW≈17)
// Built-in font scale used for size 4 (huge clock digits): 6×8 cell × 7 = 42×56.
static const int BIG_TEXT_SCALE = 7;
// Size 1 scales with orientation (portrait 1×, landscape 2×); size 2 is always 12×16;
// size 3 is FreeSans18pt (~17×28). Landscape = width >= height.
// size 3 is FreeSans18pt (~17×28); size 4 is the built-in font at 7× (~42×56),
// used only for the stacked HH/MM clock on portrait e-ink. Landscape = width >= height.
int getCharWidth() const override {
int sc = scale();
if (_text_sz == 4) return 6 * BIG_TEXT_SCALE;
if (_text_sz == 3) return 17;
if (_text_sz == 2) return 12 * sc;
return (_use_lemon ? 5 : 6) * sc;
}
int getLineHeight() const override {
int sc = scale();
if (_text_sz == 4) return 8 * BIG_TEXT_SCALE;
if (_text_sz == 3) return 28;
if (_text_sz == 2) return 16 * sc;
return (_use_lemon ? 10 : 8) * sc;