This commit is contained in:
Benjamin Tayehanpour 2026-10-05 21:28:58 +00:00
parent b8eb657dc2
commit 413dee8b7f

View file

@ -105,45 +105,20 @@ WIND = [
]
# sparkling or steaming beverage, 4 frames
DRINK = [
[0B00010,
0B00000,
0B01000,
0B11111,
0B11111,
0B11111,
0B11111,
0B00000],
[0B00000,
0B01000,
0B00000,
0B11111,
0B11111,
0B11111,
0B11111,
0B00000],
[0B01000,
0B00000,
0B00010,
0B11111,
0B11111,
0B11111,
0B11111,
0B00000],
[0B00000,
0B00010,
0B00000,
0B11111,
0B11111,
0B11111,
0B11111,
0B00000]
]
DRINK = [[2, 0, 8, 31, 31, 31, 31, 0],
[0, 8, 0, 31, 31, 31, 31, 0],
[8, 0, 2, 31, 31, 31, 31, 0],
[0, 2, 0, 31, 31, 31, 31, 0]]
class animator:
def __init__(self, lcd, slot, slides, delay):
self.lcd = lcd
self.slot = slot
# hand, two frames
HAND = [[0x00,0x00,0x00,0x0F,0x01,0x01,0x00,0x00],
[0x00,0x00,0x0F,0x01,0x01,0x00,0x00, 0x00]]
class cchar:
def __init__(self, disp, slides, delay):
self.disp = disp
self.slot = self.disp.alloc_cchar()
self.slides = slides
self.delay = delay
self.running = False
@ -152,8 +127,33 @@ class animator:
self.running = True
while self.running:
for slide in self.slides:
await self.lcd.async_set_char(self.slot, slide)
await self.disp.device.async_set_char(self.slot, slide)
await asyncio.sleep(self.delay)
async def pause(self):
self.running = False
async def stop(self):
self.running = False
self.pause()
self.disp.free_cchar(self.slot)
class scene:
def __init__(self, disp, act, cchars = None, delays = None):
self.disp = disp
self.allocs = []
for idx, custom_char in enumerate(cchars):
self.allocs.append(cchar(disp, custom_char, delays[idx]))
act = act.replace(f"CCHAR{idx}", chr(idx))
self.act = act
self.line = None
async def action(self, row, offset = 0):
self.line = row
self.disp.write(self.line, self.act, offset)
async def cut(self):
self.disp.write(self.line, " " * self.disp.width)
async def wrap(self):
for alloc in self.allocs:
alloc.stop()