From 413dee8b7f95881e7217d5b9282bd54648f55404 Mon Sep 17 00:00:00 2001 From: Benjamin Tayehanpour Date: Mon, 5 Oct 2026 21:28:58 +0000 Subject: [PATCH] stuff --- animation.py | 80 ++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/animation.py b/animation.py index 6a6489f..cce2351 100644 --- a/animation.py +++ b/animation.py @@ -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 \ No newline at end of file + 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() \ No newline at end of file