sw: Implement livetime for screens
Also, implement volume screen.
This commit is contained in:
parent
69ae7e5d42
commit
fa50e271a6
@ -112,8 +112,14 @@ class display_manager(object):
|
|||||||
self.tick = 0
|
self.tick = 0
|
||||||
self.current_display = None
|
self.current_display = None
|
||||||
|
|
||||||
def set_display(self, disp):
|
def set_display(self, disp, live=-1):
|
||||||
self.current_display = disp
|
self.current_display = disp
|
||||||
|
self.current_display.live = live
|
||||||
|
|
||||||
|
def display_is_dead(self):
|
||||||
|
if (self.current_display):
|
||||||
|
return (self.current_display.live == 0)
|
||||||
|
return 0
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
if (self.current_display):
|
if (self.current_display):
|
||||||
@ -133,6 +139,8 @@ class display_manager(object):
|
|||||||
self.current_display.ltick = old_tick
|
self.current_display.ltick = old_tick
|
||||||
self.current_display.animate(self.tick - self.current_display.ltick)
|
self.current_display.animate(self.tick - self.current_display.ltick)
|
||||||
self.current_display.ltick = self.tick
|
self.current_display.ltick = self.tick
|
||||||
|
if (self.current_display.live > 0):
|
||||||
|
self.current_display.live -= ticks
|
||||||
# TODO: Consider also animating inactive screens... Might resolve some glitches when updating text while a screen is in the background (or pass `tick` to update funcs)
|
# TODO: Consider also animating inactive screens... Might resolve some glitches when updating text while a screen is in the background (or pass `tick` to update funcs)
|
||||||
|
|
||||||
class radioserv:
|
class radioserv:
|
||||||
@ -167,11 +175,16 @@ class radioserv:
|
|||||||
nvol = 0;
|
nvol = 0;
|
||||||
elif (nvol > 100):
|
elif (nvol > 100):
|
||||||
nvol = 100
|
nvol = 100
|
||||||
|
self.disp_info.update_text("{}%".format(nvol), True)
|
||||||
|
self.disp_info.update_info("Volume")
|
||||||
|
self.disp_mgr.set_display(self.disp_info, 40)
|
||||||
self.mpd.setvol(nvol)
|
self.mpd.setvol(nvol)
|
||||||
#print("Battery: {}".format(rdata[2]))
|
#print("Battery: {}".format(rdata[2]))
|
||||||
|
|
||||||
async def io_main(self):
|
async def io_main(self):
|
||||||
while True:
|
while True:
|
||||||
|
if self.disp_mgr.display_is_dead():
|
||||||
|
self.disp_mgr.set_display(self.disp_playback)
|
||||||
self.disp_mgr.animate(1)
|
self.disp_mgr.animate(1)
|
||||||
self.disp_mgr.render()
|
self.disp_mgr.render()
|
||||||
rdata = self.spi.xfer([100, 101, 102], 50000, 1000)
|
rdata = self.spi.xfer([100, 101, 102], 50000, 1000)
|
||||||
@ -250,6 +263,9 @@ class radioserv:
|
|||||||
self.disp_playback = display_playback()
|
self.disp_playback = display_playback()
|
||||||
self.disp_playback.update_text("Loading...")
|
self.disp_playback.update_text("Loading...")
|
||||||
|
|
||||||
|
self.disp_info = display_playback()
|
||||||
|
self.disp_info.update_text("---");
|
||||||
|
|
||||||
self.disp_mgr = display_manager()
|
self.disp_mgr = display_manager()
|
||||||
self.disp_mgr.set_display(self.disp_playback)
|
self.disp_mgr.set_display(self.disp_playback)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user