set speaker and mic volume on startup
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import runtime.whisplay_client
|
import runtime.whisplay_client
|
||||||
@@ -22,6 +23,8 @@ class WhisplayInterface:
|
|||||||
self._prev_is_pressed = False
|
self._prev_is_pressed = False
|
||||||
self._prev_press_end = None
|
self._prev_press_end = None
|
||||||
|
|
||||||
|
self.set_wm8960_volume_stable(speaker=250, mic=30)
|
||||||
|
|
||||||
# -- Properties --
|
# -- Properties --
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -111,3 +114,14 @@ class WhisplayInterface:
|
|||||||
self._button_is_long_pressed = False
|
self._button_is_long_pressed = False
|
||||||
|
|
||||||
self._prev_is_pressed = is_pressed
|
self._prev_is_pressed = is_pressed
|
||||||
|
|
||||||
|
def set_wm8960_volume_stable(self, speaker: int = 0, mic: int = 0):
|
||||||
|
CARD_NAME = 'wm8960soundcard'
|
||||||
|
DEVICE_ARG = f'hw:{CARD_NAME}'
|
||||||
|
try:
|
||||||
|
subprocess.run(['amixer', '-D', DEVICE_ARG, 'sset', 'Speaker',
|
||||||
|
str(speaker)], check=False, capture_output=True)
|
||||||
|
subprocess.run(['amixer', '-D', DEVICE_ARG, 'sset',
|
||||||
|
'Capture', str(mic)], check=False, capture_output=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"ERROR: Failed to set volume: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user