mirror of
https://github.com/pkali/piradio-mini.git
synced 2026-05-20 22:34:22 +02:00
Pandora watchdog added (6s timer).
This commit is contained in:
@@ -215,6 +215,9 @@ class MyDaemon(Daemon):
|
|||||||
msg = "m"
|
msg = "m"
|
||||||
elif input_source == radio.PANDORA:
|
elif input_source == radio.PANDORA:
|
||||||
msg = "p"
|
msg = "p"
|
||||||
|
# sprawdzamy czy minal czas na potwierdzenie z Pandory i jesli tak to zerujemy flage potwierdzenia
|
||||||
|
if radio.pandora_watchdog_time <= int(time.time()):
|
||||||
|
radio.setReload(True)
|
||||||
msg = msg + ' ' + todaysdate # extra space before time (Pecus)
|
msg = msg + ' ' + todaysdate # extra space before time (Pecus)
|
||||||
if radio.getStreaming():
|
if radio.getStreaming():
|
||||||
msg = msg + ' *'
|
msg = msg + ' *'
|
||||||
|
|||||||
+12
-3
@@ -114,6 +114,9 @@ class Radio:
|
|||||||
ONEDAYSECS = 86400 # Day in seconds
|
ONEDAYSECS = 86400 # Day in seconds
|
||||||
ONEDAYMINS = 1440 # Day in minutes
|
ONEDAYMINS = 1440 # Day in minutes
|
||||||
|
|
||||||
|
DECISION_SEC = 3 # 3 sekundy na potwierdzenie OK (pandora)
|
||||||
|
WATCHDOG_SEC = 6 # 6 sekund na info z pandory
|
||||||
|
|
||||||
version = "0.0"
|
version = "0.0"
|
||||||
boardrevision = 2 # Raspberry board version type
|
boardrevision = 2 # Raspberry board version type
|
||||||
cores = 0 # number of processor cores
|
cores = 0 # number of processor cores
|
||||||
@@ -132,6 +135,7 @@ class Radio:
|
|||||||
pandora_stationIDs = ['']
|
pandora_stationIDs = ['']
|
||||||
pandora_decision = OK # jesli nie OK to zostal wcisniety kursor i czekamy na potwierdzenie decyzji (+, -, ban) przyciskiem OK, w czasie oczekiwania na potwierdzenie zmienna przyjmuje wartosc kierunku kursora
|
pandora_decision = OK # jesli nie OK to zostal wcisniety kursor i czekamy na potwierdzenie decyzji (+, -, ban) przyciskiem OK, w czasie oczekiwania na potwierdzenie zmienna przyjmuje wartosc kierunku kursora
|
||||||
pandora_decision_time = 0 # czas (godzina z zegara) po ktorym uplywa czekanie na decyzje
|
pandora_decision_time = 0 # czas (godzina z zegara) po ktorym uplywa czekanie na decyzje
|
||||||
|
pandora_watchdog_time = 0 # czas (godzina z zegara) o ktorej ostatnio przyszlo info z pandory
|
||||||
source = RADIO # Source RADIO or Player
|
source = RADIO # Source RADIO or Player
|
||||||
reload = False # Reload radio stations or player playlists
|
reload = False # Reload radio stations or player playlists
|
||||||
artist = "" # Artist (Search routines)
|
artist = "" # Artist (Search routines)
|
||||||
@@ -511,17 +515,17 @@ class Radio:
|
|||||||
self.pandora_decision = self.OK
|
self.pandora_decision = self.OK
|
||||||
elif key == 'KEY_UP':
|
elif key == 'KEY_UP':
|
||||||
self.pandora_decision = self.UP
|
self.pandora_decision = self.UP
|
||||||
self.pandora_decision_time = int(time.time()) + 3 # 3 sekundy na potwierdzenie OK
|
self.pandora_decision_time = int(time.time()) + self.DECISION_SEC
|
||||||
# kursor w gore - lubie
|
# kursor w gore - lubie
|
||||||
# ale czekamy sekunde na potwierdzenie OK
|
# ale czekamy sekunde na potwierdzenie OK
|
||||||
# no i tu trzeba cos wykombinowac :)
|
# no i tu trzeba cos wykombinowac :)
|
||||||
pass
|
pass
|
||||||
elif key == 'KEY_DOWN':
|
elif key == 'KEY_DOWN':
|
||||||
self.pandora_decision = self.DOWN
|
self.pandora_decision = self.DOWN
|
||||||
self.pandora_decision_time = int(time.time()) + 3 # 3 sekundy na potwierdzenie OK
|
self.pandora_decision_time = int(time.time()) + self.DECISION_SEC
|
||||||
elif key == 'KEY_LEFT':
|
elif key == 'KEY_LEFT':
|
||||||
self.pandora_decision = self.LEFT
|
self.pandora_decision = self.LEFT
|
||||||
self.pandora_decision_time = int(time.time()) + 3 # 3 sekundy na potwierdzenie OK
|
self.pandora_decision_time = int(time.time()) + self.DECISION_SEC
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -1624,6 +1628,7 @@ class Radio:
|
|||||||
self.storeTimer(self.timerValue)
|
self.storeTimer(self.timerValue)
|
||||||
|
|
||||||
self.setDisplayMode(display_mode)
|
self.setDisplayMode(display_mode)
|
||||||
|
self.pandora_watchdog_time = int(time.time()) + self.WATCHDOG_SEC
|
||||||
return
|
return
|
||||||
|
|
||||||
# Set any option you like here
|
# Set any option you like here
|
||||||
@@ -1699,6 +1704,7 @@ class Radio:
|
|||||||
self.pandora_song_name = '---------------------'
|
self.pandora_song_name = '---------------------'
|
||||||
log.message("radio.getPandoraStations error - no station list from pianobar", log.ERROR)
|
log.message("radio.getPandoraStations error - no station list from pianobar", log.ERROR)
|
||||||
self.max_pandora_id = len(names)
|
self.max_pandora_id = len(names)
|
||||||
|
self.pandora_watchdog_time = int(time.time()) + self.WATCHDOG_SEC
|
||||||
return names, ids
|
return names, ids
|
||||||
|
|
||||||
# Pobranie co tam wyswietla aktualnie pianobar
|
# Pobranie co tam wyswietla aktualnie pianobar
|
||||||
@@ -1744,6 +1750,7 @@ class Radio:
|
|||||||
x = self.pianobar.expect(['\r', pexpect.TIMEOUT], timeout=1)
|
x = self.pianobar.expect(['\r', pexpect.TIMEOUT], timeout=1)
|
||||||
if x == 0:
|
if x == 0:
|
||||||
self.pandora_progress = self.pianobar.before
|
self.pandora_progress = self.pianobar.before
|
||||||
|
self.pandora_watchdog_time = int(time.time()) + self.WATCHDOG_SEC
|
||||||
if x == 4:
|
if x == 4:
|
||||||
# 'Error:' - gramy dalej cisze i zamiast nazwy stacji dajemy komunikat o bledzie
|
# 'Error:' - gramy dalej cisze i zamiast nazwy stacji dajemy komunikat o bledzie
|
||||||
x = self.pianobar.expect(['\r\n', pexpect.TIMEOUT], timeout=0)
|
x = self.pianobar.expect(['\r\n', pexpect.TIMEOUT], timeout=0)
|
||||||
@@ -2353,6 +2360,7 @@ class Radio:
|
|||||||
# stacji itp. I program glupieje
|
# stacji itp. I program glupieje
|
||||||
self.execCommand ("rm /home/pi/.config/pianobar/state")
|
self.execCommand ("rm /home/pi/.config/pianobar/state")
|
||||||
log.message("radio.pandora_start", log.DEBUG)
|
log.message("radio.pandora_start", log.DEBUG)
|
||||||
|
self.pandora_watchdog_time = int(time.time()) + self.WATCHDOG_SEC + 30 # + 30 dodatkowe na ewentualny czas startu
|
||||||
#self.pandora_stop() # dla pewnosci
|
#self.pandora_stop() # dla pewnosci
|
||||||
self.pandora_decision = self.OK
|
self.pandora_decision = self.OK
|
||||||
log.message("radio.pandora_start Spawning pianobar...", log.DEBUG)
|
log.message("radio.pandora_start Spawning pianobar...", log.DEBUG)
|
||||||
@@ -2399,6 +2407,7 @@ class Radio:
|
|||||||
self.pandora_station_name = '** ' + pmessage + ' **'
|
self.pandora_station_name = '** ' + pmessage + ' **'
|
||||||
self.pandora_song_name = '---------------------'
|
self.pandora_song_name = '---------------------'
|
||||||
self.isPandoraPaused = True
|
self.isPandoraPaused = True
|
||||||
|
self.pandora_watchdog_time = int(time.time()) + self.WATCHDOG_SEC
|
||||||
return
|
return
|
||||||
|
|
||||||
#Load Pandora
|
#Load Pandora
|
||||||
|
|||||||
Reference in New Issue
Block a user