From 1f6e32fae73463ed5ec110a304998d90f6dc3ac4 Mon Sep 17 00:00:00 2001 From: davidpkj Date: Sun, 22 Jan 2023 17:48:03 +0100 Subject: Change: colors & menu items --- src/displayapp/fonts/jetbrains_mono_i.c | 123 ++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/displayapp/fonts/jetbrains_mono_i.c (limited to 'src/displayapp/fonts/jetbrains_mono_i.c') diff --git a/src/displayapp/fonts/jetbrains_mono_i.c b/src/displayapp/fonts/jetbrains_mono_i.c new file mode 100644 index 00000000..41e7735e --- /dev/null +++ b/src/displayapp/fonts/jetbrains_mono_i.c @@ -0,0 +1,123 @@ +/******************************************************************************* + * Size: 52 px + * Bpp: 1 + * Opts: --size 52 --output jetbrains_mono_i.c --bpp 1 --format lvgl --no-compress --font JetBrainsMono-Regular.ttf --symbols i + ******************************************************************************/ + +#ifdef LV_LVGL_H_INCLUDE_SIMPLE +#include "lvgl.h" +#else +#include "lvgl/lvgl.h" +#endif + +#ifndef JETBRAINS_MONO_I +#define JETBRAINS_MONO_I 1 +#endif + +#if JETBRAINS_MONO_I + +/*----------------- + * BITMAPS + *----------------*/ + +/*Store the image of the glyphs*/ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { + /* U+0069 "i" */ + 0x0, 0x7c, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, + 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, + 0x7c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x7f, 0xfe, 0x0, 0x7f, + 0xfe, 0x0, 0x7f, 0xfe, 0x0, 0x7f, 0xfe, 0x0, + 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, + 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, + 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, + 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, + 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, + 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, + 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, + 0x0, 0x0, 0x3e, 0x0, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; + + +/*--------------------- + * GLYPH DESCRIPTION + *--------------------*/ + +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { + {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, + {.bitmap_index = 0, .adv_w = 499, .box_w = 24, .box_h = 40, .ofs_x = 4, .ofs_y = 0} +}; + +/*--------------------- + * CHARACTER MAPPING + *--------------------*/ + + + +/*Collect the unicode lists and glyph_id offsets*/ +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ + { + .range_start = 105, .range_length = 1, .glyph_id_start = 1, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + } +}; + + + +/*-------------------- + * ALL CUSTOM DATA + *--------------------*/ + +#if LV_VERSION_CHECK(8, 0, 0) +/*Store all the custom data of the font*/ +static lv_font_fmt_txt_glyph_cache_t cache; +static const lv_font_fmt_txt_dsc_t font_dsc = { +#else +static lv_font_fmt_txt_dsc_t font_dsc = { +#endif + .glyph_bitmap = glyph_bitmap, + .glyph_dsc = glyph_dsc, + .cmaps = cmaps, + .kern_dsc = NULL, + .kern_scale = 0, + .cmap_num = 1, + .bpp = 1, + .kern_classes = 0, + .bitmap_format = 0, +#if LV_VERSION_CHECK(8, 0, 0) + .cache = &cache +#endif +}; + + +/*----------------- + * PUBLIC FONT + *----------------*/ + +/*Initialize a public general font descriptor*/ +#if LV_VERSION_CHECK(8, 0, 0) +const lv_font_t jetbrains_mono_i = { +#else +lv_font_t jetbrains_mono_i = { +#endif + .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ + .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ + .line_height = 40, /*The maximum line height required by the font*/ + .base_line = 0, /*Baseline measured from the bottom of the line*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = -8, + .underline_thickness = 3, +#endif + .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ +}; + + + +#endif /*#if JETBRAINS_MONO_I*/ + -- cgit v1.2.3 From 0e8b9efae6866d589988c671e90753f93f66f22c Mon Sep 17 00:00:00 2001 From: davidpkj Date: Tue, 24 Jan 2023 14:35:11 +0100 Subject: Add: jetbrains i menu for info --- src/displayapp/fonts/CMakeLists.txt | 4 +-- src/displayapp/fonts/fonts.json | 4 +-- src/displayapp/fonts/jetbrains_mono_i.c | 41 +++++++++++------------ src/displayapp/screens/settings/QuickSettings.cpp | 4 ++- 4 files changed, 27 insertions(+), 26 deletions(-) (limited to 'src/displayapp/fonts/jetbrains_mono_i.c') diff --git a/src/displayapp/fonts/CMakeLists.txt b/src/displayapp/fonts/CMakeLists.txt index 84830cc0..5946d917 100644 --- a/src/displayapp/fonts/CMakeLists.txt +++ b/src/displayapp/fonts/CMakeLists.txt @@ -1,6 +1,6 @@ set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20 - jetbrains_mono_extrabold_compressed lv_font_navi_80 lv_font_sys_48 - open_sans_light) + jetbrains_mono_i jetbrains_mono_extrabold_compressed lv_font_navi_80 + lv_font_sys_48 open_sans_light) find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED HINTS "${CMAKE_SOURCE_DIR}/node_modules/.bin") message(STATUS "Using ${LV_FONT_CONV} to generate font files") diff --git a/src/displayapp/fonts/fonts.json b/src/displayapp/fonts/fonts.json index 884bb71f..a87a9d3d 100644 --- a/src/displayapp/fonts/fonts.json +++ b/src/displayapp/fonts/fonts.json @@ -38,11 +38,11 @@ "sources": [ { "file": "JetBrainsMono-Regular.ttf", - "symbols": "i" + "range": "0x69" } ], "bpp": 1, - "size": 52 + "size": 48 }, "jetbrains_mono_extrabold_compressed": { "sources": [ diff --git a/src/displayapp/fonts/jetbrains_mono_i.c b/src/displayapp/fonts/jetbrains_mono_i.c index 41e7735e..ab1c4869 100644 --- a/src/displayapp/fonts/jetbrains_mono_i.c +++ b/src/displayapp/fonts/jetbrains_mono_i.c @@ -1,7 +1,7 @@ /******************************************************************************* - * Size: 52 px + * Size: 48 px * Bpp: 1 - * Opts: --size 52 --output jetbrains_mono_i.c --bpp 1 --format lvgl --no-compress --font JetBrainsMono-Regular.ttf --symbols i + * Opts: --size 48 --output jetbrains_mono_i.c --bpp 1 --format lvgl --no-compress --font JetBrainsMono-Regular.ttf --range 0x69 ******************************************************************************/ #ifdef LV_LVGL_H_INCLUDE_SIMPLE @@ -23,21 +23,20 @@ /*Store the image of the glyphs*/ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { /* U+0069 "i" */ - 0x0, 0x7c, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x7c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x7f, 0xfe, 0x0, 0x7f, - 0xfe, 0x0, 0x7f, 0xfe, 0x0, 0x7f, 0xfe, 0x0, - 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, - 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, - 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, - 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, - 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, - 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, - 0x0, 0x3e, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x3e, - 0x0, 0x0, 0x3e, 0x0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + 0x0, 0x7c, 0x0, 0x1, 0xfc, 0x0, 0x3, 0xf8, + 0x0, 0x7, 0xf0, 0x0, 0xf, 0xe0, 0x0, 0xf, + 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x1, 0xff, 0xf0, 0x3, + 0xff, 0xe0, 0x7, 0xff, 0xc0, 0xf, 0xff, 0x80, + 0x0, 0xf, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x3c, + 0x0, 0x0, 0x78, 0x0, 0x0, 0xf0, 0x0, 0x1, + 0xe0, 0x0, 0x3, 0xc0, 0x0, 0x7, 0x80, 0x0, + 0xf, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x3c, 0x0, + 0x0, 0x78, 0x0, 0x0, 0xf0, 0x0, 0x1, 0xe0, + 0x0, 0x3, 0xc0, 0x0, 0x7, 0x80, 0x0, 0xf, + 0x0, 0x0, 0x1e, 0x0, 0x0, 0x3c, 0x1, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xe0 }; @@ -47,7 +46,7 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, - {.bitmap_index = 0, .adv_w = 499, .box_w = 24, .box_h = 40, .ofs_x = 4, .ofs_y = 0} + {.bitmap_index = 0, .adv_w = 461, .box_w = 23, .box_h = 37, .ofs_x = 4, .ofs_y = 0} }; /*--------------------- @@ -105,14 +104,14 @@ lv_font_t jetbrains_mono_i = { #endif .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ - .line_height = 40, /*The maximum line height required by the font*/ + .line_height = 37, /*The maximum line height required by the font*/ .base_line = 0, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, #endif #if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 - .underline_position = -8, - .underline_thickness = 3, + .underline_position = -7, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index fd12f160..1facd024 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -72,6 +72,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, lv_obj_set_style_local_text_font(btn1_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); lv_label_set_text_static(btn1_lvl, brightness.GetIcon()); +// btn2 = lv_btn_create(lv_scr_act(), nullptr); btn2->user_data = this; lv_obj_set_event_cb(btn2, ButtonEventHandler); @@ -81,8 +82,9 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, lv_obj_t* lbl_btn; lbl_btn = lv_label_create(btn2, nullptr); - // lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_i); + lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_i); lv_label_set_text_static(lbl_btn, "i"); +// btn3 = lv_btn_create(lv_scr_act(), nullptr); btn3->user_data = this; -- cgit v1.2.3