I modified the countdown example from GitHub - myvobot/dock-mini-apps: Apps for Vobot Dock Mini. However, when I attempt to display non-ascii (Chinese and Japanese) characters, they appear as squares. As I am new to MicroPython development, do anyone have any suggestions on how to resolve this issue?
You most likely need to use a different font. However, most fonts, which are in use, only have ASCII characters. See How to increase font size of a label? - #2 by Vobot (and maybe Interface Guide - Vobot Mini Dock) for reference.
If you want to change the font, you can do this by
label.set_style_text_font(lv.font_numbers_92, 0)
Be aware, that the demo countdown app should not be used to actually do a countdown! The reason is, that the on_running_foreground
method is called ever 200ms or so and it only determines if the next second should be displayed. The delta can be anything between 1.0 seconds and 1.9 seconds. Therefore, you rather quickly get a drift in time.
Instead, note the start time and then always calculate the time difference to the start time. This way, you are safe and you always get the correct time. You can have a look at my countdown clone for reference: minidock_countdown/__init__.py at 198a65f23aad1e71e248d833556b8b1f597a96d6 · ToBeHH/minidock_countdown · GitHub
Thank you for your advice! I successfully created my custom font using the LVGL Font Converter. Here’s the code I used to load the binary font and apply it to a label:
font_chinese = lv.binfont_create("A:apps/app_name/fonts/NotoSansTC_22_bpp2.bin")
label = lv.label(scr)
label.set_style_text_font(font_chinese, 0)
P.S. I really appreciate your countdown clock app—it’s fantastic! Thank you for sharing the code.