From e948a15a7f043487d4d2a8512ed2ab8a50d5dadb Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Sat, 21 Mar 2026 20:33:01 +0100 Subject: [PATCH] undo that, and do this? --- xrd.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xrd.py b/xrd.py index 0b2a999..db7f65d 100644 --- a/xrd.py +++ b/xrd.py @@ -136,18 +136,22 @@ def process_command(tef: AutoFMAM, data: bytes, state: State, conn: socket.socke case Modulation.AM: tef.Tune_To(TEF6686.TuneTo_Mode.Preset, freq) state.last_tune_am = freq + out += f"T{freq}\nM{tef.modulation}\n".encode() elif cmd.startswith(b"G"): eqims = int(cmd.decode().removeprefix("G").strip(), 2) tef.FM_Set_ChannelEqualizer((eqims & 1) == 1) tef.FM_Set_MphSuppression((eqims & 2) == 2) + out += f"G{bin(eqims).removeprefix('0b').zfill(2)}\n".encode() state.last_eqims = eqims elif cmd.startswith(b"B"): state.forced_mono = bool(int(cmd.decode().removeprefix("B").strip(), 2)) tef.FM_Set_Stereo_Min(2 if state.forced_mono else 0) + out += f"B{int(state.forced_mono)}\n".encode() elif cmd.startswith(b"D"): state.deemp = int(cmd.decode().removeprefix("D").strip()) dtime = 500 if state.deemp == 0 else (750 if state.deemp == 1 else 0) tef.FM_Set_Deemphasis(dtime) + out += f"D{state.deemp}\n".encode() elif cmd.startswith(b"x"): tef.Tune_To(TEF6686.TuneTo_Mode.Preset, tef.last_tune) elif cmd.startswith(b"X"): tef.APPL_Set_OperationMode(True) # turn off elif cmd.startswith(b"W"): @@ -155,6 +159,16 @@ def process_command(tef: AutoFMAM, data: bytes, state: State, conn: socket.socke if tef.modulation == Modulation.FM: state.bw_fm = bw else: state.bw_am = bw tef.Set_Bandwidth(bw) + + if tef.modulation == Modulation.FM: out += f"W{bw}\n".encode() + else: + out_bw = bw + match out_bw: + case 3000: out_bw = 56000 + case 4000: out_bw = 64000 + case 6000: out_bw = 72000 + case 8000: out_bw = 84000 + out += f"W{out_bw}\n".encode() elif cmd.startswith(b"?"): out += b">XRD Python driver\n" elif cmd.startswith(b"S"): cmd = cmd[1:]