summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-03-27 23:30:39 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-03-27 23:30:39 (GMT)
commitfc0e6f8b45571378376264954b99d626628a0dd3 (patch)
tree5103d9af3bca938af47d12b47cd1fc2edeaaedd7
parenta2b714f9f8b48f85e345b7aa5b57b4cbda667ffe (diff)
add ing neofont15 (9x15 px)
-rw-r--r--src/displayapp/fonts/neofont.c131
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp6
-rw-r--r--src/libs/lv_conf.h7
3 files changed, 139 insertions, 5 deletions
diff --git a/src/displayapp/fonts/neofont.c b/src/displayapp/fonts/neofont.c
index 12a467a..5ff6ca9 100644
--- a/src/displayapp/fonts/neofont.c
+++ b/src/displayapp/fonts/neofont.c
@@ -554,6 +554,137 @@ lv_font_t neofont1 = {
.user_data = 0 /*Optionally some extra user data*/
};
+static bool neofont15_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next)
+{
+ /*Your code here*/
+
+ /* Store the result.
+ * For example ...
+ */
+
+ // ######..######
+ // ##::::..::##::
+ // ######..::##::
+ // ::::##..::##::
+ // ######..::##::
+
+ // ######..######..
+ // ######..######..
+ // ##::::..::##::..
+ // ##::::..::##::..
+ // ######..::##::..
+ // ######..::##::..
+ // ::::##..::##::..
+ // ::::##..::##::..
+ // ######..::##::..
+ // ######..::##::..
+
+ dsc_out->adv_w = 12; /*Horizontal space required by the glyph in [px]*/
+ dsc_out->box_h = 15; /*Height of the bitmap in [px]*/
+ dsc_out->box_w = 9; /*Width of the bitmap in [px]*/
+ dsc_out->ofs_x = 1; /*X offset of the bitmap in [pf]*/
+ dsc_out->ofs_y = 0; /*Y offset of the bitmap measured from the as line*/
+ dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/
+
+ return true; /*true: glyph found; false: glyph was not found*/
+}
+
+
+/* Get the bitmap of `unicode_letter` from `font`. */
+static const uint8_t * neofont15_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter)
+{
+ const uint8_t *u = neofont0_glyph_bitmap_cb(font, unicode_letter);
+ static uint8_t v[17];
+ uint8_t u0 = u[0];
+ uint8_t u1 = u[1];
+
+ // .. .. .. .. .2 .2 .1 .1 .0 .0
+ // .9 .8 .7 .6 .5 .4 .3 .2 .1 .0
+ // .. .. .. .. .2 .2 .1 .1 .0 .0
+ // 19 18 17 16 15 14 13 12 11 10
+ // .. .. .. .5 .5 .4 .4 .3 .3 ..
+ // 29 28 27 26 25 24 23 22 21 20
+ // .. .. .. .5 .5 .4 .4 .3 .3 ..
+ // 39 38 37 36 35 34 33 32 31 30
+
+ // v[7] = 0x00;
+
+ uint8_t a,b,c, d,e,f, g,h,i, j,k,l, m,n,o;
+ a = (u0>>7)&1; u0 <<= 1;
+ b = (u0>>7)&1; u0 <<= 1;
+ c = (u0>>7)&1; u0 <<= 1;
+ d = (u0>>7)&1; u0 <<= 1;
+ e = (u0>>7)&1; u0 <<= 1;
+ f = (u0>>7)&1; u0 <<= 1;
+ g = (u0>>7)&1; u0 <<= 1;
+ h = (u0>>7)&1;
+ i = (u1>>7)&1; u1 <<= 1;
+ j = (u1>>7)&1; u1 <<= 1;
+ k = (u1>>7)&1; u1 <<= 1;
+ l = (u1>>7)&1; u1 <<= 1;
+ m = (u1>>7)&1; u1 <<= 1;
+ n = (u1>>7)&1; u1 <<= 1;
+ o = (u1>>7)&1;
+
+#define P(a,b,c,d, e,f,g,h) ((a<<7)|(b<<6)|(c<<5)|(d<<4)|(e<<3)|(f<<2)|(g<<1)|h)
+
+ v[0] = P(a,a,a,b,b,b,c,c);
+ v[1] = P(c,
+ a,a,a,b,b,b,c);
+ v[2] = P(c,c,
+ a,a,a,b,b,b);
+ v[3] = P(c,c,c,
+
+ d,d,d,e,e);
+ v[4] = P(e,f,f,f,
+ d,d,d,e);
+ v[5] = P(e,e,f,f,f,
+ d,d,d);
+ v[6] = P(e,e,e,f,f,f,
+
+ g,g);
+ v[7] = P(g,h,h,h,i,i,i,
+ g);
+ v[8] = P(g,g,h,h,h,i,i,i);
+ v[9] = P(g,g,g,h,h,h,i,i);
+ v[10] = P(i,
+
+ j,j,j,k,k,k,l);
+ v[11] = P(l,l,
+ j,j,j,k,k,k);
+ v[12] = P(l,l,l,
+ j,j,j,k,k);
+ v[13] = P(k,l,l,l,
+
+ m,m,m,n);
+ v[14] = P(n,n,o,o,o,
+ m,m,m);
+ v[15] = P(n,n,n,o,o,o,
+ m,m);
+ v[16] = P(m,n,n,n,o,o,o,0);
+
+#undef P
+
+ return v; /*Or NULL if not found*/
+}
+
+/*Describe the properties of a font*/
+lv_font_t neofont15 = {
+ .get_glyph_dsc = neofont15_glyph_dsc_cb, /*Set a callback to get info about gylphs*/
+ .get_glyph_bitmap = neofont15_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/
+ .line_height = 18, /*The real line height where any text fits*/
+ .base_line = 2,
+ .dsc = 0, /*Store any implementation specific data here*/
+#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 = 0,
+ .underline_thickness = 0,
+#endif
+ .user_data = 0 /*Optionally some extra user data*/
+};
+
/* Get info about glyph of `unicode_letter` in `font` font.
* Store the result in `dsc_out`.
* The next letter (`unicode_letter_next`) might be used to calculate the width required by this glyph (kerning)
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index 0bb2bf6..8178d22 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -61,7 +61,7 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
label_temp = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(label_temp, lv_scr_act(), LV_ALIGN_CENTER, 0, -60);
lv_obj_set_style_local_text_color( label_temp, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
- lv_obj_set_style_local_text_font( label_temp, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont1);
+ lv_obj_set_style_local_text_font( label_temp, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont15);
lv_label_set_text_fmt(label_temp, "T? [?,?]");
label_time = lv_label_create(lv_scr_act(), nullptr);
@@ -119,12 +119,14 @@ void WatchFaceDigital::Refresh() {
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
- // systemTask.motionSensor.RefreshTemperature();
+#ifndef INFINISIM
+ systemTask.motionSensor.RefreshTemperature();
lv_label_set_text_fmt(label_temp, "T%d [%d,%d]",
((int)(systemTask.motionSensor.temperature_last_read_value+23)),
((int)(systemTask.motionSensor.temperature_last_result)),
((int)(systemTask.motionSensor.temperature_read_counter))
);
+#endif
currentDateTime = dateTimeController.CurrentDateTime();
diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h
index 58a8593..dfec64a 100644
--- a/src/libs/lv_conf.h
+++ b/src/libs/lv_conf.h
@@ -413,9 +413,10 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in
* LV_FONT_DECLARE(my_font_2)
*/
-#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(neofont0) \
- LV_FONT_DECLARE(neofont1) \
- LV_FONT_DECLARE(neofont2) \
+#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(neofont0) \
+ LV_FONT_DECLARE(neofont1) \
+ LV_FONT_DECLARE(neofont15) \
+ LV_FONT_DECLARE(neofont2) \
LV_FONT_DECLARE(lv_font_sys_48)
/* Enable it if you have fonts with a lot of characters.