fancontrol/animation.py
2026-10-03 15:24:28 +00:00

159 lines
No EOL
2.3 KiB
Python

import asyncio
# animated tile set
# fan, four frames
FAN = [
[0b00000,
0b00100,
0b00100,
0b11111,
0b00100,
0b00100,
0b00000,
0b00000],
[0b00000,
0b00010,
0b11010,
0b00100,
0b01011,
0b01000,
0b00000,
0b00000],
[0b00000,
0b10001,
0b01010,
0b00100,
0b01010,
0b10001,
0b00000,
0b00000],
[0b00000,
0b01000,
0b01011,
0b00100,
0b11010,
0b00010,
0b00000,
0b00000]
]
# different fan, four frames
FAN2 = [
[0x01,
0x01,
0x1D,
0x12,
0x1D,
0x11,
0x11,
0x10],
[0x00,
0x01,
0x1D,
0x12,
0x1D,
0x11,
0x10,
0x10],
[0x00,
0x00,
0x1D,
0x12,
0x1D,
0x10,
0x10,
0x10],
[0x00,
0x01,
0x1D,
0x12,
0x1D,
0x11,
0x10,
0x10]
]
# wind, three frames
WIND = [
[0b01101,
0b10010,
0b00000,
0b01101,
0b10010,
0b00000,
0b01101,
0b10010],
[0b10110,
0b01001,
0b00000,
0b10110,
0b01001,
0b00000,
0b10110,
0b01001],
[0b11011,
0b00100,
0b00000,
0b11011,
0b00100,
0b00000,
0b11011,
0b00100]
]
# 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]
]
class animator:
def __init__(self, lcd, slot, slides, delay):
self.lcd = lcd
self.slot = slot
self.slides = slides
self.delay = delay
self.running = False
async def start(self):
self.running = True
while self.running:
for slide in self.slides:
await self.lcd.async_set_char(self.slot, slide)
await asyncio.sleep(self.delay)
async def stop(self):
self.running = False