Skip to content

Commit

Permalink
Fix RCA to work with AmpliPi 0.2.0+, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahshader committed Oct 10, 2023
1 parent 243402b commit 6dd7020
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 30 deletions.
6 changes: 0 additions & 6 deletions src/app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ def set_stream(source_id, stream_id):
"""API call to change a source's input to a stream."""
_patch_safe(f'http://{_amplipi_ip}/api/sources/{source_id}', {"input": f'stream={stream_id}'})

def set_rca(source_id):
"""API call to change a source to use local input (RCA)"""
_patch_safe(f'http://{_amplipi_ip}/api/sources/{source_id}', {"input": 'local'})

def move_zone_to_source(zone_id, source_id):
"""API call to move a zone to a source"""
_patch_safe(f'http://{_amplipi_ip}/api/zones/{zone_id}', {"source_id": source_id})
Expand Down Expand Up @@ -222,8 +218,6 @@ def get_stream_id_from_source_dict(source):
if source is None:
return None
source_input = source['input']
if source_input.startswith('local'):
return None
source_split = source_input.split("=")
if len(source_split) == 2:
return int(source_split[1])
Expand Down
4 changes: 0 additions & 4 deletions src/app/audioconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ def change_stream(self, new_stream_id):
api.set_stream(self.source_id, new_stream_id)
self.__update_supported_cmds_from_source(api.get_source(self.source_id))

def use_rca(self):
api.set_rca(self.source_id)
self.__update_supported_cmds_from_source(api.get_source(self.source_id))

# changing the zone may also change the source and stream
def change_zone(self, new_zone_id) -> bool:
self.using_group = False
Expand Down
13 changes: 4 additions & 9 deletions src/app/pages/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@

def _change_stream_callback(index):
audioconf = AudioConfig()
if index == 0:
audioconf.use_rca()
else:
new_stream = _streams[index]
audioconf.change_stream(int(new_stream['id']))
new_stream = _streams[index]
audioconf.change_stream(int(new_stream['id']))
polling.invalid_group_handled()

# only call this when on this page
def load_stream_page():
"""Loads stream page contents. Should only be called when the display is on the stream page."""
global _streams
Expand All @@ -55,11 +51,10 @@ def load_stream_page():
names = []
types = []
else:
# filter rca streams that don't match the source id
_streams = [stream for stream in _streams if stream['type'] != 'rca' or stream['index'] == polling.get_source_id()]
names = [stream['name'] for stream in _streams] # if 'name' in stream
types = [displayserial.stream_type_to_pic_id(stream['type']) for stream in _streams]
_streams.insert(0, None) # RCA is handled differently in _change_stream_callback
names.insert(0, polling.source_name)
types.insert(0, displayserial.stream_type_to_pic_id('rca'))
print(f'{len(names)} streams: ')
print(names)

Expand Down
16 changes: 7 additions & 9 deletions src/app/polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
last_supported_cmds = []
is_muted = None
vol_f = 0.0
source_name = ''
source_id = 0
_skip_next_vol_f = False
_skip_next_playing = False
_skip_next_mute = False
Expand All @@ -30,7 +30,7 @@ def poll():
global _skip_next_playing
global _skip_next_mute
global _awaiting_user_input
global source_name
global source_id

zone = None
group = None
Expand All @@ -46,7 +46,6 @@ def poll():
source = get_source(source_id)
if source is None:
return
source_name = source['name']
_audioconf.stream_id = api.get_stream_id_from_source_dict(source)
stream = api.get_stream(_audioconf.stream_id)
if not _skip_next_vol_f:
Expand Down Expand Up @@ -170,12 +169,8 @@ def poll_stream_name(stream, source):
new_stream_type = None
new_stream_name = ''
if stream is not None:
if source['input'].startswith('local'):
new_stream_type = 'rca'
new_stream_name = source['name']
else:
new_stream_name = stream['name']
new_stream_type = stream['type']
new_stream_name = stream['name']
new_stream_type = stream['type']
if new_stream_name != stream_name:
stream_name = new_stream_name
send_stream_name(stream_name)
Expand Down Expand Up @@ -211,6 +206,9 @@ def set_muted(muted):
is_muted = muted
update_mute_button(is_muted)

def get_source_id():
return source_id

def skip_next_vol_f():
global _skip_next_vol_f
_skip_next_vol_f = True
Expand Down
4 changes: 2 additions & 2 deletions src/app/sysconsts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

VERSION = '0.2.15'
MIN_AMPLIPI_VERSION = '0.1.7'
VERSION = '0.2.16'
MIN_AMPLIPI_VERSION = '0.2.0'

WALL_PANEL_REPO = 'micro-nova/AmpliPiWallPanel'

Expand Down

0 comments on commit 6dd7020

Please sign in to comment.