代码拉取完成,页面将自动刷新
ST7735S display driver written in MicroPython.
Module Name :st7735s
Module color constant:RED,GREEN,BLUE,WHITE,CYAN,YELLOW,PURPLE,GREY
The module displays mode constants:PART,NORMAL,SCROLL,IDLE
rgb565(R, G, B) #Color generating function
st7735s.ST7735S(spi,*,dc,rst,cs,bl=None,width=128,height=160)
st7735s.deinit()
#An example of a scrolling display
import st7735s as st
from machine import SPI
from random import randint
import time,gbk
def main():
#spi uses hardware channel 1. According to the actual situation, modify the connection pins of spi and lcd
try:
font=gbk.font16x16()
spi = SPI(1,baudrate=40000000)
lcd=st.ST7735S(spi,dc=2,rst=0,cs=15,bl=12,width=128,height=160)
lcd.backlight(200)
lcd.rotate(0)
#Draws 12 lines of text in the middle scroll area
for i in range(20,140,10):
t=f'{i} '
lcd.text(t*(lcd.width//8//len(t)),0,i,st.rgb565(randint(0,255),randint(0,255),randint(0,255)))
#Draw top and bottom fixed area rectangles and text
lcd.rect(0,0,lcd.width,20,st.BLUE,1)
lcd.rect(0,140,lcd.width,20,st.BLUE,1)
lcd.drawText('顶部固定区TFA',10,2,font,st.YELLOW)
lcd.drawText('底部固定区BFA',10,142,font,st.YELLOW)
lcd.show()
#Scroll display for 10 seconds
lcd.setDisMode(st.SCROLL,20,120,20)
t,i=time.ticks_ms(),20
while time.ticks_diff(time.ticks_ms(),t)<10000:
lcd.setScrollStart(i)
i=i+1 if i<140 else 20
time.sleep_ms(30)
lcd.setDisMode(st.NORMAL)
finally:
font.deinit() #Close the database and related files
lcd.deinit() #Turn off the pwm output of the backlight
if __name__=='__main__':
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。