Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions main-ui/devices/miyoo/flip/miyoo_flip.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
class MiyooFlip(MiyooDevice):
OUTPUT_MIXER = 2
SOUND_DISABLED = 0
HP_VOLUME_MAX = 15 # Headphone amp gain cap (0-63). Stock is 58 which is way too loud.
MIYOO_STOCK_CONFIG_LOCATION = "/userdata/system.json"

def __init__(self, device_name, main_ui_mode):
Expand Down Expand Up @@ -328,6 +329,11 @@ def _set_volume(self, volume):
)

if(self.are_headphones_plugged_in()):
hp_vol = volume * MiyooFlip.HP_VOLUME_MAX // 100
ProcessRunner.run(
["amixer", "cset", "name='headphone volume'", str(hp_vol)],
print=False
)
ProcessRunner.run(["amixer","sset","Playback Path","HP"], print=False)
else:
ProcessRunner.run(["amixer","sset","Playback Path","SPK"], print=False)
Expand Down Expand Up @@ -397,6 +403,8 @@ def fix_sleep_sound_bug(self):
ProcessRunner.run(["amixer", "cset","numid=5", "0"])
if(self.are_headphones_plugged_in()):
ProcessRunner.run(["amixer", "cset","numid=2", "3"])
hp_vol = config_volume * MiyooFlip.HP_VOLUME_MAX // 100
ProcessRunner.run(["amixer", "cset", "name='headphone volume'", str(hp_vol)])
elif(0 == config_volume):
ProcessRunner.run(["amixer", "cset","numid=2", "0"])
else:
Expand Down
6 changes: 5 additions & 1 deletion main-ui/devices/miyoo/flip/miyoo_flip_poller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ def __init__(self, device):
self.device = device

def check_audio(self):

try:
new_headphone_status = self.device.get_device().are_headphones_plugged_in()
if(new_headphone_status != self.headphone_status):
self.headphone_status = new_headphone_status
if(self.headphone_status):
from devices.miyoo.flip.miyoo_flip import MiyooFlip
volume = self.device.get_device().system_config.get_volume()
hp_vol = volume * MiyooFlip.HP_VOLUME_MAX // 100
ProcessRunner.run(["amixer", "cset", "name='headphone volume'", str(hp_vol)])
ProcessRunner.run(["amixer","sset","Playback Path","HP"])
else:
ProcessRunner.run(["amixer","sset","Playback Path","SPK"])
Expand Down