stuff
This commit is contained in:
parent
b8eb657dc2
commit
413dee8b7f
1 changed files with 40 additions and 40 deletions
80
animation.py
80
animation.py
|
|
@ -105,45 +105,20 @@ WIND = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# sparkling or steaming beverage, 4 frames
|
# sparkling or steaming beverage, 4 frames
|
||||||
DRINK = [
|
DRINK = [[2, 0, 8, 31, 31, 31, 31, 0],
|
||||||
[0B00010,
|
[0, 8, 0, 31, 31, 31, 31, 0],
|
||||||
0B00000,
|
[8, 0, 2, 31, 31, 31, 31, 0],
|
||||||
0B01000,
|
[0, 2, 0, 31, 31, 31, 31, 0]]
|
||||||
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]
|
|
||||||
]
|
|
||||||
|
|
||||||
class animator:
|
# hand, two frames
|
||||||
def __init__(self, lcd, slot, slides, delay):
|
|
||||||
self.lcd = lcd
|
HAND = [[0x00,0x00,0x00,0x0F,0x01,0x01,0x00,0x00],
|
||||||
self.slot = slot
|
[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.slides = slides
|
||||||
self.delay = delay
|
self.delay = delay
|
||||||
self.running = False
|
self.running = False
|
||||||
|
|
@ -152,8 +127,33 @@ class animator:
|
||||||
self.running = True
|
self.running = True
|
||||||
while self.running:
|
while self.running:
|
||||||
for slide in self.slides:
|
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)
|
await asyncio.sleep(self.delay)
|
||||||
|
|
||||||
async def stop(self):
|
async def pause(self):
|
||||||
self.running = False
|
self.running = False
|
||||||
|
|
||||||
|
async def stop(self):
|
||||||
|
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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue