small updates towards energy saving

This commit is contained in:
Stefan Schmidt-Bilkenroth 2021-05-26 12:17:29 +02:00
parent bebd86b6fa
commit 3eac0cd0ea
3 changed files with 31 additions and 8 deletions

View file

@ -5,13 +5,13 @@ dauer = 5
[pfad] [pfad]
lokal = /home/pi/Documents/green-signals/slideshow lokal = /home/pi/Documents/green-signals/slideshow
remote = https://wolke.netzbegruenung.de/s/CE7CASzEeGF4px2/download remote =
[debug] [debug]
preview = 1 preview = 1
[energy] [energy]
mode = 1 mode = 2
start = 23:30 start = 23:30
stop = 6:00 stop = 6:00

View file

@ -20,6 +20,8 @@ import operator
import zipfile import zipfile
# used for downloading the fles from remote # used for downloading the fles from remote
import requests import requests
# used to call to shutdown or vcgencmd
import subprocess
# below lines for develepment only # below lines for develepment only
# When DEBUG_PREVIEW is set to True, then te dislay will only cover # When DEBUG_PREVIEW is set to True, then te dislay will only cover
@ -172,6 +174,10 @@ class HiddenRoot(tk.Tk):
self.window.pixNum = self.window.pixNum + len(self.window.mediaList) self.window.pixNum = self.window.pixNum + len(self.window.mediaList)
self.window.nextMedia() self.window.nextMedia()
def shutdown(self):
subprocess.check_call(["shutdown","--no-wall","+1"])
self.destroy()
def destroy(self): def destroy(self):
self.window.player.stop() self.window.player.stop()
self.window.destroy() self.window.destroy()
@ -319,7 +325,7 @@ class MySlideShow(tk.Toplevel):
self.after_cancel(self.timer) self.after_cancel(self.timer)
self.timer=None self.timer=None
return return
print(self.pixNum) #print(self.pixNum)
media = self.mediaList[self.pixNum] media = self.mediaList[self.pixNum]
self.pixNum = (self.pixNum + 1) % len(self.mediaList) self.pixNum = (self.pixNum + 1) % len(self.mediaList)
self.showMedia(media) self.showMedia(media)
@ -378,6 +384,18 @@ class MySlideShow(tk.Toplevel):
self.resumePlayback() self.resumePlayback()
self.nextMedia() self.nextMedia()
def blankScreenOn(self):
#energy savings - start blank screen
self.pausePlayback()
subprocess.check_call(["vcgencmd","display_power","0"])
time.sleep(10)
self.blankScreenOff()
def blankScreenOff(self):
#energy savings - end blank screen
self.updateMedia()
subprocess.check_call(["vcgencmd","display_power","1"])
def GetHandle(self): def GetHandle(self):
return self.videopanel.winfo_id() return self.videopanel.winfo_id()
@ -389,7 +407,12 @@ slideShow = HiddenRoot()
slideShow.bind("<Escape>", lambda e: slideShow.destroy()) # exit on esc slideShow.bind("<Escape>", lambda e: slideShow.destroy()) # exit on esc
slideShow.bind("<Right>", lambda e: slideShow.nextMedia()) # right-arrow key for next image slideShow.bind("<Right>", lambda e: slideShow.nextMedia()) # right-arrow key for next image
slideShow.bind("<Left>", lambda e: slideShow.previousMedia()) # left-arrow key for previous image slideShow.bind("<Left>", lambda e: slideShow.previousMedia()) # left-arrow key for previous image
slideShow.bind("U", lambda e: slideShow.window.updateMedia()) # start dwnload of new media slideShow.bind("U", lambda e: slideShow.window.updateMedia()) # start download of new media
slideShow.bind("P", lambda e: slideShow.window.togglePlayback()) # toggle playback slideShow.bind("P", lambda e: slideShow.window.togglePlayback()) # toggle playback
slideShow.bind("i", lambda e: slideShow.window.toggleInfo()) # toggle display of info widget slideShow.bind("i", lambda e: slideShow.window.toggleInfo()) # toggle display of info widget
if DEBUG_PREVIEW == 1:
#some featurres are only availade whith DEBUG Preview enabled
slideShow.bind("B", lambda e: slideShow.window.blankScreenOn()) # briefly test blank screen feature
slideShow.bind("S", lambda e: slideShow.shutdown()) # schedule shutdown and exit the slideshow
slideShow.mainloop() slideShow.mainloop()

View file

@ -18,10 +18,10 @@ try:
except: except:
modules.append("python-vlc") modules.append("python-vlc")
try: # try:
import crontab # import crontab
except: # except:
modules.append("python-crontab") # modules.append("python-crontab")
#init variables used in config file and some other places #init variables used in config file and some other places
doAutostart=tk.IntVar() doAutostart=tk.IntVar()