This commit is contained in:
parent
cf44c61759
commit
82b3e3a0e6
6 changed files with 31 additions and 27 deletions
|
@ -5,13 +5,12 @@ from bottle_log import LoggingPlugin
|
|||
from bottle_websocket import websocket, GeventWebSocketServer
|
||||
from geventwebsocket.websocket import WebSocket
|
||||
|
||||
from buba.animations.dbf import DBFAnimation
|
||||
from buba.animations.icalevents import IcalEvents
|
||||
from buba.animations.time import BubaTime
|
||||
from buba.appconfig import AppConfig
|
||||
from buba.bubaanimator import BubaAnimator
|
||||
from buba.animations.time import BubaTime
|
||||
from buba.bubacmd import BubaCmd
|
||||
|
||||
from buba.animations.dbf import DBFAnimation
|
||||
from buba.websocketcomm import WebSocketClients
|
||||
|
||||
config = AppConfig()
|
||||
|
@ -25,7 +24,6 @@ if config.debug:
|
|||
app.install(LoggingPlugin(app.config))
|
||||
TEMPLATE_PATH.insert(0, config.templatepath)
|
||||
|
||||
|
||||
websocket_clients = WebSocketClients()
|
||||
buba = BubaCmd(config.serial, websocket_clients.send)
|
||||
animator = BubaAnimator(buba)
|
||||
|
@ -33,7 +31,9 @@ animator = BubaAnimator(buba)
|
|||
animator.add(BubaTime)
|
||||
animator.add(DBFAnimation, ds100="AHST", station="Holstenstraße")
|
||||
animator.add(DBFAnimation, ds100="AHS", station="Altona", count=9)
|
||||
animator.add(IcalEvents, url="https://cloud.hamburg.ccc.de/remote.php/dav/public-calendars/QJAdExziSnNJEz5g?export", title="CCCHH Events")
|
||||
animator.add(IcalEvents, url="https://cloud.hamburg.ccc.de/remote.php/dav/public-calendars/QJAdExziSnNJEz5g?export",
|
||||
title="CCCHH Events")
|
||||
|
||||
|
||||
@app.route("/static/<filepath>")
|
||||
def server_static(filepath):
|
||||
|
@ -45,6 +45,7 @@ def server_static(filepath):
|
|||
def root():
|
||||
return {}
|
||||
|
||||
|
||||
@app.get('/ws', apply=[websocket])
|
||||
def websocket_endpoint(ws: WebSocket):
|
||||
try:
|
||||
|
|
|
@ -64,6 +64,7 @@ class DBFAnimation(BubaAnimation):
|
|||
|
||||
# Recalculate the timedelta
|
||||
return BubaAnimation.countdown(datetime.datetime.combine(dep_date, dep_time))
|
||||
|
||||
# dep_td = datetime.datetime.combine(dep_date, dep_time) - now
|
||||
# return round(dep_td.total_seconds() / 60)
|
||||
|
||||
|
@ -78,6 +79,8 @@ class DBFAnimation(BubaAnimation):
|
|||
station = station[:-8]
|
||||
if station == "Hbf":
|
||||
station = "Hauptbahnhof"
|
||||
if station == "Wedel(Holst)":
|
||||
station = "Wedel"
|
||||
return station
|
||||
|
||||
@staticmethod
|
||||
|
@ -118,10 +121,12 @@ class DBFAnimation(BubaAnimation):
|
|||
else:
|
||||
when = self.countdown(train['actualDeparture'])
|
||||
self.buba.text(page=0, row=i + 1, col_start=0, col_end=11, text=self.short_train(train['train']))
|
||||
self.buba.text(page=0, row=i + 1, col_start=12, col_end=104, text=self.short_station(train['destination']))
|
||||
self.buba.text(page=0, row=i + 1, col_start=12, col_end=104,
|
||||
text=self.short_station(train['destination']))
|
||||
self.buba.text(page=0, row=i + 1, col_start=105, col_end=119,
|
||||
text=when, align=BubaCmd.ALIGN_RIGHT)
|
||||
self.buba.set_page(0)
|
||||
for i in range(5):
|
||||
self.buba.text(page=0, row=0, col_start=93, col_end=119, text=datetime.datetime.now().strftime("%H:%M"), align=BubaCmd.ALIGN_RIGHT)
|
||||
self.buba.text(page=0, row=0, col_start=93, col_end=119, text=datetime.datetime.now().strftime("%H:%M"),
|
||||
align=BubaCmd.ALIGN_RIGHT)
|
||||
sleep(2)
|
||||
|
|
|
@ -33,7 +33,8 @@ class IcalEvents(BubaAnimation):
|
|||
for (page, events) in enumerate(self.chunk(self.events, 3)):
|
||||
if len(self.events) > 3:
|
||||
self.buba.text(page=0, row=0, col_start=0, col_end=119,
|
||||
text=f"{self.title} ({page + 1}/{int((len(self.events)+2) / 3)})", align=BubaCmd.ALIGN_LEFT)
|
||||
text=f"{self.title} ({page + 1}/{int((len(self.events) + 2) / 3)})",
|
||||
align=BubaCmd.ALIGN_LEFT)
|
||||
else:
|
||||
self.buba.text(page=0, row=0, col_start=0, col_end=119, text=self.title, align=BubaCmd.ALIGN_LEFT)
|
||||
for i in range(3):
|
||||
|
|
|
@ -17,5 +17,6 @@ class BubaTime(BubaAnimation):
|
|||
self.buba.set_page(0)
|
||||
|
||||
for i in range(3):
|
||||
self.buba.text(page=0, row=0, col_start=93, col_end=119, text=datetime.now().strftime("%H:%M"), align=BubaCmd.ALIGN_RIGHT)
|
||||
self.buba.text(page=0, row=0, col_start=93, col_end=119, text=datetime.now().strftime("%H:%M"),
|
||||
align=BubaCmd.ALIGN_RIGHT)
|
||||
sleep(2)
|
||||
|
|
|
@ -51,7 +51,6 @@ class BubaAnimation:
|
|||
return dt.strftime("%a") # weekday
|
||||
return dt.strftime("%d.%m.")
|
||||
|
||||
|
||||
@staticmethod
|
||||
def ellipsis(text, max=28):
|
||||
"""
|
||||
|
|
|
@ -50,7 +50,6 @@ class BubaCmd:
|
|||
'align': align,
|
||||
})
|
||||
|
||||
|
||||
def text(self, page, row, col_start, col_end, text, align=MIS1TextDisplay.ALIGN_LEFT):
|
||||
"""
|
||||
Send text to the specified row, placing it between col_start and col_end.
|
||||
|
@ -78,7 +77,6 @@ class BubaCmd:
|
|||
'align': align,
|
||||
})
|
||||
|
||||
|
||||
def set_page(self, page):
|
||||
"""
|
||||
Display the given page.
|
||||
|
@ -88,7 +86,6 @@ class BubaCmd:
|
|||
"""
|
||||
return self.set_pages([(page, 255)])
|
||||
|
||||
|
||||
def set_pages(self, pages):
|
||||
"""
|
||||
Configure automatic paging.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue