Skip to content

Commit

Permalink
Rebuild fonts, fix ballaswag#106
Browse files Browse the repository at this point in the history
  • Loading branch information
Max P authored and Max P committed Oct 13, 2024
1 parent 07409cb commit 5a24956
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ wpaclean:

clean:
rm -rf $(BUILD_DIR)
find ./ \( -name '*.d' -o -name '*.a' -o -name '*.o' \) -delete
rm -rf spdlog/build
rm -rf releases/

install:
install -d $(DESTDIR)$(bindir)
Expand Down
6 changes: 3 additions & 3 deletions lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ extern uint32_t custom_tick_get(void);
/*Optionally declare custom fonts here.
*You can use these fonts as default font too and they will be available globally.
*E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/
#define LV_FONT_CUSTOM_DECLARE
#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(notosemi_12) LV_FONT_DECLARE(notosemi_14) LV_FONT_DECLARE(notosemi_16) LV_FONT_DECLARE(notosemi_20)

/*Always set a default font*/
#define LV_FONT_DEFAULT &lv_font_montserrat_16
#define LV_FONT_DEFAULT &notosemi_20

/*Enable handling large font and/or fonts with a lot of characters.
*The limit depends on the font size, font face and bpp.
Expand All @@ -387,7 +387,7 @@ extern uint32_t custom_tick_get(void);
#define LV_USE_FONT_COMPRESSED 1

/*Enable subpixel rendering*/
#define LV_USE_FONT_SUBPX 0
#define LV_USE_FONT_SUBPX 1
#if LV_USE_FONT_SUBPX
/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/
#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/
Expand Down
5 changes: 2 additions & 3 deletions src/file_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace fs = std::experimental::filesystem;

#define THUMBSCALE = 0.78
#define THUMBSCALE = 0.5

FilePanel::FilePanel(lv_obj_t *parent)
: file_cont(lv_obj_create(parent))
Expand All @@ -26,7 +26,6 @@ FilePanel::FilePanel(lv_obj_t *parent)
lv_obj_set_width(fname_label, LV_PCT(90));
lv_label_set_long_mode(fname_label, LV_LABEL_LONG_SCROLL);
lv_obj_set_style_text_align(fname_label, LV_TEXT_ALIGN_CENTER, 0);


static lv_coord_t grid_main_row_dsc[] = {LV_GRID_FR(3), LV_GRID_FR(2), LV_GRID_TEMPLATE_LAST};
static lv_coord_t grid_main_col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
Expand Down Expand Up @@ -72,7 +71,7 @@ void FilePanel::refresh_view(json &j, const std::string &gcode_path) {

auto width_scale = (double)lv_disp_get_physical_hor_res(NULL) / 800.0;
auto thumb_detail = KUtils::get_thumbnail(gcode_path, j, width_scale);
std::string fullpath = thumb_detail.first;
std::string fullpath = thumb_detail.first;
if (fullpath.length() > 0) {
lv_label_set_text(detail_label, detail.c_str());
auto screen_width = lv_disp_get_physical_hor_res(NULL);
Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ static void hal_init(lv_color_t primary, lv_color_t secondary) {
spdlog::debug("resolution {} x {}", width, height);
lv_disp_t * disp = lv_disp_drv_register(&disp_drv);
lv_theme_t * th = height <= 480
? lv_theme_default_init(NULL, primary, secondary, true, &lv_font_montserrat_12)
: lv_theme_default_init(NULL, primary, secondary, true, &lv_font_montserrat_20);
? lv_theme_default_init(NULL, primary, secondary, true, &notosemi_16)
: lv_theme_default_init(NULL, primary, secondary, true, &notosemi_20);
lv_disp_set_theme(disp, th);

evdev_init();
Expand Down Expand Up @@ -142,8 +142,8 @@ static void hal_init(lv_color_t primary, lv_color_t secondary)

lv_disp_t * disp = lv_disp_drv_register(&disp_drv);
lv_theme_t * th = MONITOR_HOR_RES <= 480
? lv_theme_default_init(NULL, primary, secondary, true, &lv_font_montserrat_12)
: lv_theme_default_init(NULL, primary, secondary, true, &lv_font_montserrat_16);
? lv_theme_default_init(NULL, primary, secondary, true, &roboto_14)
: lv_theme_default_init(NULL, primary, secondary, true, &roboto_16);
lv_disp_set_theme(disp, th);

lv_group_t * g = lv_group_create();
Expand Down
24 changes: 12 additions & 12 deletions src/sysinfo_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ static std::map<int32_t, uint32_t> sleepsec_to_dd_idx = {

static std::map<std::string, uint32_t> sleep_label_to_sec = {
{"Never", -1}, // never
{"5 Minutes", 300}, // 5 min
{"10 Minutes", 600}, // 10 min
{"30 Minutes", 1800}, // 30 min
{"1 Hour", 3600}, // 1 hour
{"5 Hours", 18000} // 5 hour
{"5m", 300}, // 5 min
{"10m", 600}, // 10 min
{"30m", 1800}, // 30 min
{"1h", 3600}, // 1 hour
{"5h", 18000} // 5 hour
};

SysInfoPanel::SysInfoPanel()
Expand Down Expand Up @@ -90,12 +90,12 @@ SysInfoPanel::SysInfoPanel()
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW);

lv_obj_clear_flag(left_cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_size(left_cont, LV_PCT(50), LV_PCT(100));
lv_obj_set_size(left_cont, LV_PCT(60), LV_PCT(100));
lv_obj_set_flex_flow(left_cont, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(left_cont, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);

lv_obj_clear_flag(right_cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_size(right_cont, LV_PCT(50), LV_PCT(100));
lv_obj_set_size(right_cont, LV_PCT(40), LV_PCT(100));
lv_obj_set_flex_flow(right_cont, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(right_cont, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);

Expand All @@ -108,11 +108,11 @@ SysInfoPanel::SysInfoPanel()
lv_obj_align(display_sleep_dd, LV_ALIGN_RIGHT_MID, 0, 0);
lv_dropdown_set_options(display_sleep_dd,
"Never\n"
"5 Minutes\n"
"10 Minutes\n"
"30 Minutes\n"
"1 Hour\n"
"5 Hours");
"5m\n"
"10m\n"
"30m\n"
"1h\n"
"5h");

auto v = conf->get_json("/display_sleep_sec");
if (!v.is_null()) {
Expand Down

0 comments on commit 5a24956

Please sign in to comment.