Add firmware font size setting

This commit is contained in:
Adolfo Reyna
2026-07-24 21:28:24 -04:00
parent 56bbd6a90e
commit d8c5a55fe8
9 changed files with 200 additions and 3 deletions
+45
View File
@@ -13,6 +13,7 @@
#include <tactility/device.h>
#include <tactility/drivers/backlight.h>
#include <tactility/log.h>
#include <tactility/lvgl_fonts.h>
#include <tactility/lvgl_module.h>
#include <tactility/lvgl_pointer.h>
#include <tactility/module.h>
@@ -27,6 +28,49 @@ bool isStarted() {
return module_is_started(&lvgl_module);
}
void applyFontSize(settings::display::FontSize fontSize) {
LvglFontScale scale;
switch (fontSize) {
using enum settings::display::FontSize;
case Small:
scale = FONT_SCALE_SMALL;
break;
case Large:
scale = FONT_SCALE_LARGE;
break;
case Default:
default:
scale = FONT_SCALE_DEFAULT;
break;
}
lvgl_set_text_font_scale(scale);
const lv_font_t* font = lvgl_get_text_font(FONT_SIZE_DEFAULT);
for (lv_display_t* display = lv_display_get_next(nullptr);
display != nullptr;
display = lv_display_get_next(display)) {
#if LV_USE_THEME_DEFAULT
if (lv_display_get_theme(display) == lv_theme_default_get()) {
lv_obj_t* screen = lv_display_get_screen_active(display);
lv_theme_default_init(
display,
lv_theme_get_color_primary(screen),
lv_theme_get_color_secondary(screen),
LV_THEME_DEFAULT_DARK,
font
);
}
#endif
// The display layers are independent inheritance roots. Updating all of them makes
// the new size visible immediately in regular screens, overlays, and the status bar.
lv_obj_set_style_text_font(lv_display_get_screen_active(display), font, LV_PART_MAIN);
lv_obj_set_style_text_font(lv_display_get_layer_top(display), font, LV_PART_MAIN);
lv_obj_set_style_text_font(lv_display_get_layer_sys(display), font, LV_PART_MAIN);
lv_obj_set_style_text_font(lv_display_get_layer_bottom(display), font, LV_PART_MAIN);
}
}
void attachDevices() {
LOG_I(TAG, "Adding devices");
@@ -55,6 +99,7 @@ void attachDevices() {
if (rotation != lv_display_get_rotation(primary_lvgl_display)) {
lv_display_set_rotation(primary_lvgl_display, rotation);
}
applyFontSize(settings.fontSize);
}
// Start touch