【Digi-Key Follow me Issue 2】Task 1: Control the screen to display Chinese
[Copy link]
1. There is a problem with the experimental board
I was very happy when I first received the experimental board. After unpacking and checking, everything was normal as shown in the following picture.
Figure 1: Unboxing
But the power-on is abnormal, the screen has only backlight, no display, as shown in the following figure.
Figure 2: No display
I thought the firmware was not flashed properly or lost after testing, so I searched the official website for various factory reset files and flashed them. The files were all flashed, and the USB port display was normal, but it just didn't display. I basically determined that there was something wrong with the screen. Then I contacted Dejie to exchange it, but the reply I got was that it would take until October or later, and the specific time was not yet determined, so it was recommended to return the product.
I thought I would miss this event, but by chance I pressed the bottom of the screen with my finger and it actually displayed text. It seems that the screen is not broken, but most likely it is not soldered properly. I carefully lifted the screen and re-soldered the FPC pads one by one, as shown in the following figure.
Figure 3. Welding screen FPC
Then power on again, and it shows normal display, and the previously flashed programs can work normally, as shown in the figure below.
Figure 4: The screen can display
Unexpectedly, it was fixed with just a little welding. It was like a light bulb turning into a silver lining. I can now carry out the board task.
2. Display Chinese
CircuitPython itself can only display English characters, without a Chinese character library. To display Chinese characters, you need to use a custom library. By studying the relevant documents of CircuitPython, you can use the Bitmap character library to call a custom Chinese character library to achieve Chinese display.
The corresponding library is: adafruit_bitmap_font
Since the font library in PCF format runs faster, I directly copied the ready-made font library shared by the big guys in the group.
CircuitPython programming is basically just about understanding the calls to each library used, which is relatively simple. The following code implements switching between fonts and displaying two fonts, while the backlight gradually changes from dark to bright.
Code
import board
import digitalio
import time
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
display = board.DISPLAY
board.DISPLAY.brightness = 0.5
board.DISPLAY.rotation = 0
str_disp = "恭喜发财!"
font = bitmap_font.load_font("opposans_m_12.pcf")
color = 0xE60000
text_area = label.Label(font, text=str_disp, color=color)
text_area.x = 93
text_area.y = 62
display.show(text_area)
font_cs = 0
while True:
# Fade up the backlight
for i in range(100):
board.DISPLAY.brightness = 0.01 * i
time.sleep(0.01)
if(font_cs == 0):
font_cs = 1
font = bitmap_font.load_font("sanjiruosixingkai_m_16.pcf")
else:
font_cs = 0
font = bitmap_font.load_font("opposans_m_12.pcf")
text_area = label.Label(font, text=str_disp, color=color)
text_area.x = 88
text_area.y = 62
display.show(text_area)
The effect after running is as shown in the video below.
005
|