离线
离线
离线
你这个资源正是我要找的,非常感谢!
一起学习共同进步.
达哥你这是睡得晚, 还是起得早呢? 笑哭.gif
离线
又找到一个段码字体: https://fontmeme.com/fonts/seven-segment-font/
ttf段码字体本站下载: seven-segment.zip
littlevgl 字体生成:
lv_font_conv --no-compress --format lvgl --font "D:\8899\7 Segment.ttf" -o font_segment_64.c --bpp 4 --size 64 --symbols "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ " -r 0x20-0x7F
lv_obj_t* label2 = lv_label_create(button2, NULL);
lv_obj_set_style_local_text_font(label2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &font_segment_64);
lv_label_set_text(label2, "0123456789");
lv_obj_t* button3 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_pos(button3, 150, 250);
lv_obj_set_size(button3, 500, 64);
lv_obj_t* label3 = lv_label_create(button3, NULL);
lv_obj_set_style_local_text_font(label3, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &font_segment_64);
lv_label_set_text(label3, "ABCDEFGHIJK");
离线
代码:
void lv_test2()
{
lv_task_create(task2, 1000, LV_TASK_PRIO_LOWEST, NULL);
lv_obj_t* button2 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_pos(button2, 10, 10);
lv_obj_set_size(button2, 550, 64);
lv_obj_t* label2 = lv_label_create(button2, NULL);
lv_obj_set_style_local_text_font(label2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &font_segment_64);
lv_obj_set_style_local_text_color(label2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
lv_label_set_text(label2, "2020-07-05 10:17:33");
lv_obj_t* button3 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_pos(button3, 10, 80);
lv_obj_set_size(button3, 500, 64);
lv_obj_t* label3 = lv_label_create(button3, NULL);
lv_obj_set_style_local_text_font(label3, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &font_segment_64);
lv_obj_set_style_local_text_color(label3, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
lv_label_set_text(label3, "ABCDEFGHIJK");
lv_obj_t* label4 = lv_label_create(lv_scr_act(), NULL);
lv_obj_set_pos(label4, 10, 250);
lv_obj_set_size(label4, 650, 128);
lv_obj_set_style_local_text_font(label4, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &font_segment_128);
lv_obj_set_style_local_text_color(label4, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE);
lv_label_set_text(label4, "2020-07-05");
}
字体生成:
lv_font_conv --no-compress --format lvgl --font "D:\8899\7 Segment.ttf" -o font_segment_64.c --bpp 4 --size 64 --symbols "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ " -r 0x20-0x7F
lv_font_conv --no-compress --format lvgl --font "D:\8899\7 Segment.ttf" -o font_segment_128.c --bpp 4 --size 128 --symbols "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ: " -r 0x20-0x7F
离线
void task2(lv_task_t* task)
{
char strdate[16];
char strtime[16];
time_t t = time(NULL);
struct tm tm = *localtime(&t);
snprintf(strdate, sizeof(strdate) - 1, "%04d-%02d-%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
snprintf(strtime, sizeof(strtime) - 1, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
lv_label_set_text(labelDate, strdate);
lv_label_set_text(labelTime, strtime);
}
void lv_test2()
{
labelDate = lv_label_create(lv_scr_act(), NULL);
lv_obj_set_pos(labelDate, 10, 160);
lv_obj_set_size(labelDate, 650, 128);
lv_obj_set_style_local_text_font(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &font_segment_64);
lv_obj_set_style_local_text_color(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE);
lv_label_set_text(labelDate, "");
labelTime = lv_label_create(lv_scr_act(), NULL);
lv_obj_set_pos(labelTime, 10, 220);
lv_obj_set_size(labelTime, 650, 128);
lv_obj_set_style_local_text_font(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &font_segment_128);
lv_obj_set_style_local_text_color(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE);
lv_label_set_text(labelTime, "");
lv_task_create(task2, 900, LV_TASK_PRIO_LOWEST, NULL);
//lv_task_ready(task2);
}
离线
这字体真好看
不完美, 因为不等宽.
我去找一个等宽字体看看.
离线
离线
lv_font_conv --no-compress --format lvgl --font "D:\8899\digital-7\digital-7 (mono).ttf" -o lv_font_segment_24.c --bpp 4 --size 24 --symbols "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ: " -r 0x20-0x7F
lv_font_conv --no-compress --format lvgl --font "D:\8899\digital-7\digital-7 (mono).ttf" -o lv_font_segment_32.c --bpp 4 --size 32 --symbols "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ: " -r 0x20-0x7F
lv_font_conv --no-compress --format lvgl --font "D:\8899\digital-7\digital-7 (mono).ttf" -o lv_font_segment_48.c --bpp 4 --size 48 --symbols "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ: " -r 0x20-0x7F
lv_font_conv --no-compress --format lvgl --font "D:\8899\digital-7\digital-7 (mono).ttf" -o lv_font_segment_64.c --bpp 4 --size 64 --symbols "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ: " -r 0x20-0x7F
lv_font_conv --no-compress --format lvgl --font "D:\8899\digital-7\digital-7 (mono).ttf" -o lv_font_segment_128.c --bpp 4 --size 128 --symbols "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ: " -r 0x20-0x7F
离线