Add showing only a single charset page
This commit is contained in:
parent
027e87ab3d
commit
37caa00e5b
2 changed files with 22 additions and 12 deletions
|
@ -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))
|
||||
def add(self, animation, *args, **kwargs):
|
||||
self.animations.append(animation(self.buba, *args, **kwargs))
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue