wire up sound card and DAC from Whisplay board
This commit is contained in:
@@ -8,6 +8,8 @@ import threading
|
||||
import signal
|
||||
import argparse
|
||||
|
||||
import subprocess
|
||||
|
||||
import RNS
|
||||
import LXMF
|
||||
from LXST.Primitives.Telephony import Telephone
|
||||
@@ -68,6 +70,7 @@ class ChannelClient:
|
||||
self.board = None
|
||||
self.selected_index = 0
|
||||
self._press_time = 0.0
|
||||
self._wm8960_device = None
|
||||
if use_whisplay and _WHISPLAY_AVAILABLE and _HAS_PIL:
|
||||
try:
|
||||
self._init_whisplay()
|
||||
@@ -155,6 +158,36 @@ class ChannelClient:
|
||||
if hasattr(self.board, "start_event_listener"):
|
||||
self.board.start_event_listener()
|
||||
self._load_fonts()
|
||||
self._setup_whisplay_audio()
|
||||
|
||||
def _find_wm8960_card(self):
|
||||
try:
|
||||
with open("/proc/asound/cards") as f:
|
||||
for line in f:
|
||||
if "wm8960" in line.lower():
|
||||
return line.split()[0]
|
||||
except Exception:
|
||||
return None
|
||||
return None
|
||||
|
||||
def _setup_whisplay_audio(self):
|
||||
card = self._find_wm8960_card()
|
||||
if card is None:
|
||||
RNS.log("Whisplay WM8960 sound card not found", RNS.LOG_WARNING)
|
||||
return
|
||||
mixer_cmds = [
|
||||
["amixer", "-c", card, "sset", "Left Output Mixer PCM", "on"],
|
||||
["amixer", "-c", card, "sset", "Right Output Mixer PCM", "on"],
|
||||
["amixer", "-c", card, "sset", "Speaker", "121"],
|
||||
["amixer", "-c", card, "sset", "Playback", "230"],
|
||||
]
|
||||
for cmd in mixer_cmds:
|
||||
try:
|
||||
subprocess.run(cmd, check=False, capture_output=True, text=True)
|
||||
except Exception:
|
||||
pass
|
||||
self._wm8960_device = f"plughw:{card},0"
|
||||
RNS.log(f"Whisplay audio: WM8960 card {card} ready", RNS.LOG_DEBUG)
|
||||
|
||||
def _load_fonts(self):
|
||||
def load(size, bold=False):
|
||||
@@ -410,6 +443,10 @@ class ChannelClient:
|
||||
def _init_telephone(self):
|
||||
if self.telephone is None:
|
||||
self.telephone = Telephone(self.identity)
|
||||
if self._wm8960_device:
|
||||
self.telephone.set_speaker(self._wm8960_device)
|
||||
self.telephone.set_microphone(self._wm8960_device)
|
||||
self.telephone.set_ringer(self._wm8960_device)
|
||||
self.telephone.set_established_callback(self._on_call_established)
|
||||
self.telephone.set_ended_callback(self._on_call_ended)
|
||||
self.telephone.announce()
|
||||
|
||||
Reference in New Issue
Block a user