修正背景色不一致的问题.

Signed-off-by: lion.chan <cy187lion@sina.com>
This commit is contained in:
lion.chan 2023-04-28 11:25:02 +08:00
parent c4fa12414f
commit a119c5ed82
1 changed files with 5 additions and 6 deletions

View File

@ -8,7 +8,7 @@ WHITE = (255, 255, 255)
def printCh(display, text, x, y, dic={}, size=1, color=(0,0,0), backcolor=(255,255,255)):
font_size = [0, 16, 24, 32, 40, 48] # 分别对应 size=1, 2, 3, 4, 5 的字体尺寸0 无效。
xs = x
# 定义字体颜色,RGB888转RGB565
# 定义字体颜色, RGB888 RGB565
fc = ((color[0]>>3)<<11) + ((color[1]>>2)<<5) + (color[2]>>3) # 字体
bc = ((backcolor[0]>>3)<<11) + ((backcolor[1]>>2)<<5) + (backcolor[2]>>3) # 字体背景颜色
#
@ -33,7 +33,7 @@ def printCh(display, text, x, y, dic={}, size=1, color=(0,0,0), backcolor=(255,2
#
xs += font_size[size]
else:
display.printStr(text[i], xs, y, color, size=size)
display.printStr(text[i], xs, y, color, backcolor=backcolor, size=size)
xs += int(font_size[size]/2)
# if
# for
@ -43,11 +43,10 @@ if __name__ == '__main__':
import fonts
from tftlcd import LCD24
########################
# 构建1.5寸LCD对象并初始化
# 构建 2.4 寸 LCD 对象并初始化
########################
d = LCD24(portrait=1) #默认方向竖屏
#
#填充白色
d = LCD24(portrait=1) # 默认方向竖屏
# 填充白色
d.fill(BLACK)
#
printCh(d, '零一科技01Tech', 0, 0, dic=fonts.hanzi_16x16_dict, size=1, color=RED, backcolor=BLACK)