From cfa221a38d9a95a4cf26ae9e8347b4c053eeb7b8 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Mon, 2 Jun 2025 13:26:21 +0200 Subject: [PATCH] Add showing only a single charset page --- buba/BubaAnimator.py | 32 +++++++++++++++++++++----------- buba/__main__.py | 2 +- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/buba/BubaAnimator.py b/buba/BubaAnimator.py index c19edd3..817a45f 100644 --- a/buba/BubaAnimator.py +++ b/buba/BubaAnimator.py @@ -17,33 +17,43 @@ class BubaAnimation: def __repr__(self): return f"<{type(self).__name__}>" + class BubaTime(BubaAnimation): def __init__(self, buba: BubaCmd): super().__init__(buba) def run(self): self.buba.simple_text(page=0, row=0, col=0, text="Buba") - self.buba.simple_text(page=0, row=1, col=0, text="CCC Hansestadt Hamburg") - self.buba.simple_text(page=0, row=2, col=0, text="") + self.buba.simple_text(page=0, row=1, col=0, text="Choas Computer Club") + self.buba.simple_text(page=0, row=2, col=0, text="Hansestadt Hamburg") self.buba.simple_text(page=0, row=3, col=0, text="Hello, world!") self.buba.set_page(0) - for i in range(15): + for i in range(5): self.buba.simple_text(page=0, row=0, col=93, text=datetime.now().strftime("%H:%M:%S")) sleep(1) class BubaCharset(BubaAnimation): - def __init__(self, buba: BubaCmd): + def __init__(self, buba: BubaCmd, single=None): super().__init__(buba) + self.charset = bytes(range(256)).decode("CP437") + self.single = single def run(self): - self.buba.simple_text(page=0, row=0, col=0, text=" !\"#$%&'()*+,-./0123456789:;<=>?") - self.buba.simple_text(page=0, row=1, col=0, text="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_") - self.buba.simple_text(page=0, row=2, col=0, text="`abcdefghijklmnopqrstuvwxyz{|}~") # ignore until we fix the mapping \u2302 - self.buba.simple_text(page=0, row=3, col=0, text="That's all, folks!") - sleep(10) + if self.single is not None: + while True: + self.render(self.single) + sleep(1) + else: + for page in range(16): + self.render(page) + sleep(5) + def render(self, page): + for row in range(4): + start = ((page + row) * 16) % 256 + self.buba.simple_text(page=0, row=row, col=0, text=f"${start:02x}: {self.charset[start:start + 16]}") class BubaAnimator: def __init__(self, buba: BubaCmd): @@ -62,5 +72,5 @@ class BubaAnimator: self.log.debug(f"Starting animation: {a}") a.run() - def add(self, animation): - self.animations.append(animation(self.buba)) \ No newline at end of file + def add(self, animation, *args, **kwargs): + self.animations.append(animation(self.buba, *args, **kwargs)) diff --git a/buba/__main__.py b/buba/__main__.py index 86ea6de..de0cffe 100644 --- a/buba/__main__.py +++ b/buba/__main__.py @@ -25,7 +25,7 @@ TEMPLATE_PATH.insert(0, config.templatepath) websocket_clients = WebSocketClients() buba = BubaCmd(config.serial, websocket_clients.send) animator = BubaAnimator(buba) -animator.add(BubaCharset) +animator.add(BubaCharset) #, single=12) animator.add(BubaTime) # bottle_helpers = BottleHelpers(auth, group=config.requires_group, allowed=config.allowed) # update_poller = UpdatePoller(websocket_clients, ccujack, 1 if config.debug else 0.1)