LCD example library? (it's for a birthday present)
LCD example library? (it's for a birthday present)
I have got a Pyboard with the lcd160cr. I know the most basic commands and can get some basic writings on the lcd. However, I would like to get my girlfriend (who also has a Pyboard) a nice birthday message on her board. Using some running text and some images. Unfortunately it turns out my Micropython skills are way too bad for doing this all by myself. Are there some pre-build examples I could use? Some fancy looking messages on the lcd maybe? I want to learn, but I can't learn it all until tomorrow
Re: LCD example library? (it's for a birthday present)
Did you have a look at https://www.youtube.com/watch?v=OOz9U_YdstM ?
If there is a demo that matches your needs I will provide you with that code.
If there is a demo that matches your needs I will provide you with that code.
Re: LCD example library? (it's for a birthday present)
YES! I was so excited when I found this video and so sad when I realized that there's no code for it.
Thanks so much! It is a great demonstration!
I really don't know if I can ask for that much, but is it possible to get the codes for these?
-Rainbow background animation at 0:55.
-Also the Poor Man's Microbit scrolling text around 1:55 and 2:08.
-Wow, the 20th century text and starwars from 4:27 is perfect!
-Touch from 5:47
-Slide collection 6:14
I would be really, really gratefull!
Thanks so much! It is a great demonstration!
I really don't know if I can ask for that much, but is it possible to get the codes for these?
-Rainbow background animation at 0:55.
-Also the Poor Man's Microbit scrolling text around 1:55 and 2:08.
-Wow, the 20th century text and starwars from 4:27 is perfect!
-Touch from 5:47
-Slide collection 6:14
I would be really, really gratefull!
Re: LCD example library? (it's for a birthday present)
Just one for now....
Code: Select all
import lcd160cr
import uctypes
lcd = None
frame_cnt = 0
frame = None
rtc = pyb.RTC()
def idle_wait(dt=0):
pyb.delay(dt)
def d01_clock(dt=40, sh=1, fmt='%2d:%02d:%02d', init=0):
global frame_cnt
if init == 2:
return 'clock', -1
elif init == 3:
return
if init:
lcd.set_spi_win(2, 2, lcd.w-4, lcd.h-4)
desc = { "arr":(uctypes.ARRAY | 0, uctypes.UINT16 | 128*16) }
xx = uctypes.struct(uctypes.addressof(frame), desc, uctypes.NATIVE).arr
# 1,0,0 --> 1,1,0 --> 0,1,0 --> 0,1,1 --> 0,0,1 --> 1,0,1 --> 1,0,0
def rgb(r, g, b):
v = 150
return lcd.rgb((r*v) >> 8, (g*v) >> 8, (b*v) >> 8)
for i in range(0, 256, 4):
ix = i >> 2
xx[ix] = rgb(255, i, 0)
xx[ix+0x40] = rgb(255-i, 255, 0)
xx[ix+0x80] = rgb(0, 255, i)
xx[ix+0xc0] = rgb(0, 255-i, 255)
xx[ix+0x100] = rgb(i, 0, 255)
xx[ix+0x140] = rgb(255, 0, 255-i)
xx[ix+0x180] = rgb(255, i, 0)
xx[ix+0x1c0] = rgb(255-i, 255, 0)
xx[ix+0x200] = rgb(0, 255, i)
xx[ix+0x240] = rgb(0, 255-i, 255)
xx[ix+0x280] = rgb(i, 0, 255)
xx[ix+0x2c0] = rgb(255, 0, 255-i)
xx[ix+0x300] = rgb(255, i, 0)
xx[ix+0x340] = rgb(255-i, 255, 0)
if lcd.w < 160:
scale = 2
else:
scale = 3
lcd.set_font(0,scale,0,1)
if lcd.w < 160:
xoff = (lcd.w-8*4*3) // 2
yoff = (lcd.h-5*3) // 2
else:
xoff = (lcd.w-8*4*4) // 2
yoff = (lcd.h-5*4) // 2
if lcd.is_touched():
return False
spi = lcd.fast_spi()
for i in range(lcd.h-4):
ix = 8*(frame_cnt)+i & 0x3fe
spi.write(memoryview(frame)[ix:ix+(lcd.w-4)*2])
if dt:
res = rtc.datetime()
s = fmt % (res[4],res[5],res[6])
lcd.set_text_color(lcd.rgb(200, 200, 200), 0)
lcd.set_pos(xoff+sh, yoff+sh)
lcd.write(s)
lcd.set_pos(xoff-sh, yoff-sh)
lcd.write(s)
lcd.set_pos(xoff, yoff)
lcd.set_text_color(lcd.rgb(48, 88, 48), 0)
lcd.write(s)
idle_wait(dt)
frame_cnt += 1
return True
def main(connect='X'):
global lcd
global frame
lcd = lcd160cr.LCD160CR(connect)
frame = bytearray(lcd.w*lcd.h*2)
d01_clock()
d01_clock(init=1)
while d01_clock(init=0): pass
if __name__ == "__main__":
""" Use proper connection mode, X, Y, XY or YX
"""
main('XY')
Re: LCD example library? (it's for a birthday present)
I'm getting some strange error message, but thank you