mirror of
https://github.com/pkali/piradio-mini.git
synced 2026-05-20 22:34:22 +02:00
Better source change from menu.
This commit is contained in:
@@ -414,7 +414,7 @@ def get_switch_states(lcd,radio,rss):
|
|||||||
unmuteRadio(lcd,radio)
|
unmuteRadio(lcd,radio)
|
||||||
|
|
||||||
if display_mode == radio.MODE_SOURCE:
|
if display_mode == radio.MODE_SOURCE:
|
||||||
radio.toggleSource()
|
radio.toggleSource(UP)
|
||||||
radio.setReload(True)
|
radio.setReload(True)
|
||||||
|
|
||||||
elif display_mode == radio.MODE_SEARCH:
|
elif display_mode == radio.MODE_SEARCH:
|
||||||
@@ -443,7 +443,7 @@ def get_switch_states(lcd,radio,rss):
|
|||||||
unmuteRadio(lcd,radio)
|
unmuteRadio(lcd,radio)
|
||||||
|
|
||||||
if display_mode == radio.MODE_SOURCE:
|
if display_mode == radio.MODE_SOURCE:
|
||||||
radio.toggleSource()
|
radio.toggleSource(DOWN)
|
||||||
radio.setReload(True)
|
radio.setReload(True)
|
||||||
|
|
||||||
elif display_mode == radio.MODE_SEARCH:
|
elif display_mode == radio.MODE_SEARCH:
|
||||||
|
|||||||
+17
-13
@@ -762,8 +762,10 @@ class Radio:
|
|||||||
|
|
||||||
# Handle toggling of source
|
# Handle toggling of source
|
||||||
def handle_source(self,key):
|
def handle_source(self,key):
|
||||||
if key == 'KEY_UP' or key == 'KEY_DOWN':
|
if key == 'KEY_UP':
|
||||||
self.toggleSource()
|
self.toggleSource(self.UP)
|
||||||
|
if key == 'KEY_DOWN':
|
||||||
|
self.toggleSource(self.DOWN)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Input Source RADIO, NETWORK or PLAYER
|
# Input Source RADIO, NETWORK or PLAYER
|
||||||
@@ -2089,21 +2091,23 @@ class Radio:
|
|||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
# Toggle the input source (Reload is done when Reload requested)
|
# Toggle the input source (Reload is done when Reload requested)
|
||||||
def toggleSource(self):
|
def toggleSource(self,direction):
|
||||||
if self.source == self.RADIO:
|
# Remember! RADIO=0, PLAYER=1, PANDORA=2 always!
|
||||||
self.source = self.PLAYER
|
if direction == self.UP:
|
||||||
sSource = language.getText('source_media')
|
self.source +=1
|
||||||
elif self.source == self.PLAYER:
|
if self.source == self.PANDORA and (not config.getPandoraAvailable()):
|
||||||
|
self.source +=1
|
||||||
|
elif direction == self.DOWN:
|
||||||
|
self.source -=1
|
||||||
|
if self.source < self.RADIO:
|
||||||
if config.getPandoraAvailable():
|
if config.getPandoraAvailable():
|
||||||
self.source = self.PANDORA
|
self.source = self.PANDORA
|
||||||
sSource = language.getText('source_pandora')
|
|
||||||
else:
|
else:
|
||||||
self.source = self.RADIO
|
self.source = self.PANDORA - 1 # PLAYER
|
||||||
sSource = language.getText('source_radio')
|
if self.source > self.PANDORA:
|
||||||
else:
|
|
||||||
self.source = self.RADIO
|
self.source = self.RADIO
|
||||||
sSource = language.getText('source_radio')
|
|
||||||
self.setReload(True)
|
self.setReload(True)
|
||||||
|
|
||||||
if self.speech:
|
if self.speech:
|
||||||
self.speak(sSource)
|
self.speak(sSource)
|
||||||
|
|||||||
Reference in New Issue
Block a user