Add two animations

This commit is contained in:
Stefan Bethke 2025-06-01 19:03:00 +02:00
commit ece40868e5
3 changed files with 51 additions and 13 deletions

View file

@ -6,19 +6,59 @@ from time import sleep
from buba.BubaCmd import BubaCmd
class BubaAnimation:
def __init__(self, buba: BubaCmd):
self.buba = buba
pass
def run(self):
pass
class BubaTime(BubaAnimation):
def __init__(self, buba: BubaCmd):
super().__init__(buba)
def run(self):
self.buba.simple_text(page=0, row=1, col=1, text="Buba")
self.buba.simple_text(page=0, row=2, col=1, text="CCC Hansestadt Hamburg")
self.buba.simple_text(page=0, row=3, col=1, text="")
self.buba.simple_text(page=0, row=4, col=1, text="Hello, world!")
self.buba.set_page(0)
for i in range(15):
self.buba.simple_text(page=0, row=1, col=94, text=datetime.now().strftime("%H:%M:%S"))
sleep(1)
class BubaCharset(BubaAnimation):
def __init__(self, buba: BubaCmd):
super().__init__(buba)
def run(self):
self.buba.simple_text(page=0, row=1, col=1, text=" !\"#$%&'()*+,-./0123456789:;<=>?")
self.buba.simple_text(page=0, row=2, col=1, text="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_")
self.buba.simple_text(page=0, row=3, col=1, text="`abcdefghijklmnopqrstuvwxyz{|}~\u2302")
self.buba.simple_text(page=0, row=4, col=1, text="That's all, folks!")
sleep(10)
class BubaAnimator:
def __init__(self, buba: BubaCmd):
self.log = logging.getLogger(__name__)
self.buba = buba
self.animations = []
Thread(target=self.run, daemon=True).start()
def run(self):
while True:
self.buba.simple_text(page=0, row=2, col=1, text="")
self.buba.simple_text(page=0, row=3, col=1, text="")
self.buba.simple_text(page=0, row=4, col=1, text="")
if len(self.animations) == 0:
a = BubaTime(self.buba)
a.run()
else:
for a in self.animations:
self.log.debug(f"Starting animation: {a}")
a.run()
self.buba.simple_text(page=0, row=1, col=1, text="CCCHH Buba")
self.buba.simple_text(page=0, row=1, col=94, text=datetime.now().strftime("%H:%M:%S"))
self.buba.set_page(0)
sleep(1)
def add(self, animation):
self.animations.append(animation(self.buba))

View file

@ -6,7 +6,7 @@ from bottle_websocket import websocket, GeventWebSocketServer
from geventwebsocket.websocket import WebSocket
from buba.AppConfig import AppConfig
from buba.BubaAnimator import BubaAnimator
from buba.BubaAnimator import BubaAnimator, BubaTime, BubaCharset
from buba.BubaCmd import BubaCmd
from buba.websocketcomm import WebSocketClients
@ -24,6 +24,8 @@ TEMPLATE_PATH.insert(0, config.templatepath)
websocket_clients = WebSocketClients()
buba = BubaCmd(config.serial, websocket_clients.send)
animator = BubaAnimator(buba)
animator.add(BubaTime)
animator.add(BubaCharset)
# bottle_helpers = BottleHelpers(auth, group=config.requires_group, allowed=config.allowed)
# update_poller = UpdatePoller(websocket_clients, ccujack, 1 if config.debug else 0.1)

View file

@ -64,10 +64,6 @@ export default class {
}
}
}
let c = 1
this.applyText(1, 1, " !\"#$%&'()*+,-./0123456789:;<=>?");
this.applyText(2, 1, "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_");
this.applyText(3, 1, "`abcdefghijklmnopqrstuvwxyz{|}~\u2302");
}
eraseCol(row, col) {