feat(rlcd): runtime font size selector in Settings->Display

- device.properties bump default to 20
- lvgl_fonts add runtime override API (g_runtime_font_size + externs for all Montserrat sizes)
- DisplaySettings add fontSize field persisted in properties
- Display app adds Font size dropdown 14-28 applying immediately
- Lvgl.cpp applies saved runtime font on boot
- device.py new bucket <=20 includes all fonts for runtime switching (~150KB)

Co-authored-by: internal-model
This commit is contained in:
Adolfo Reyna
2026-07-18 15:10:42 -04:00
parent 12035f2f39
commit e29e9b4a66
8 changed files with 177 additions and 18 deletions
+45 -1
View File
@@ -1,11 +1,11 @@
#include <Tactility/Tactility.h>
#include <tactility/lvgl_icon_shared.h>
#include <tactility/lvgl_fonts.h>
#ifdef ESP_PLATFORM
#include <Tactility/service/displayidle/DisplayIdleService.h>
#endif
#include <Tactility/Logger.h>
#include <Tactility/app/App.h>
#include <Tactility/hal/display/DisplayDevice.h>
@@ -156,6 +156,21 @@ class DisplayApp final : public App {
}
}
static void onFontSizeChanged(lv_event_t* event) {
auto* app = static_cast<DisplayApp*>(lv_event_get_user_data(event));
auto* dropdown = static_cast<lv_obj_t*>(lv_event_get_target(event));
uint32_t idx = lv_dropdown_get_selected(dropdown);
// Map dropdown index to font size: 0=default (compile-time), 1=14, 2=16, 3=18, 4=20, 5=24, 6=28
static const uint8_t font_sizes[] = {0, 14, 16, 18, 20, 24, 28};
if (idx < sizeof(font_sizes)/sizeof(font_sizes[0])) {
uint8_t new_size = font_sizes[idx];
app->displaySettings.fontSize = new_size;
app->displaySettingsUpdated = true;
// Apply immediately for next screens - current screen keeps old fonts until reopen
lvgl_set_runtime_font_size(new_size);
}
}
static void onTimeoutChanged(lv_event_t* event) {
auto* app = static_cast<DisplayApp*>(lv_event_get_user_data(event));
auto* dropdown = static_cast<lv_obj_t*>(lv_event_get_target(event));
@@ -427,6 +442,35 @@ public:
}
}
// Runtime font size selector
{
auto* font_wrapper = lv_obj_create(main_wrapper);
lv_obj_set_size(font_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_pad_all(font_wrapper, 0, LV_STATE_DEFAULT);
lv_obj_set_style_border_width(font_wrapper, 0, LV_STATE_DEFAULT);
auto* font_label = lv_label_create(font_wrapper);
lv_label_set_text(font_label, "Font size");
lv_obj_align(font_label, LV_ALIGN_LEFT_MID, 0, 0);
auto* font_dropdown = lv_dropdown_create(font_wrapper);
lv_dropdown_set_options(font_dropdown, "Default\n14 Small\n16\n18\n20\n24 Next\n28 Large");
lv_obj_align(font_dropdown, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_add_event_cb(font_dropdown, onFontSizeChanged, LV_EVENT_VALUE_CHANGED, this);
// Map current fontSize to dropdown index
uint8_t fs = displaySettings.fontSize;
uint32_t idx = 0;
if (fs == 14) idx = 1;
else if (fs == 16) idx = 2;
else if (fs == 18) idx = 3;
else if (fs == 20) idx = 4;
else if (fs == 24) idx = 5;
else if (fs == 28) idx = 6;
else idx = 0; // 0 = compile-time default (currently 20)
lv_dropdown_set_selected(font_dropdown, idx);
}
if (hasCalibratableTouchDevice()) {
auto* calibrate_wrapper = lv_obj_create(main_wrapper);
lv_obj_set_size(calibrate_wrapper, LV_PCT(100), LV_SIZE_CONTENT);