undo that, and do this?

This commit is contained in:
2026-03-21 20:33:01 +01:00
parent 3d8239617d
commit e948a15a7f
+14
View File
@@ -136,18 +136,22 @@ def process_command(tef: AutoFMAM, data: bytes, state: State, conn: socket.socke
case Modulation.AM: case Modulation.AM:
tef.Tune_To(TEF6686.TuneTo_Mode.Preset, freq) tef.Tune_To(TEF6686.TuneTo_Mode.Preset, freq)
state.last_tune_am = freq state.last_tune_am = freq
out += f"T{freq}\nM{tef.modulation}\n".encode()
elif cmd.startswith(b"G"): elif cmd.startswith(b"G"):
eqims = int(cmd.decode().removeprefix("G").strip(), 2) eqims = int(cmd.decode().removeprefix("G").strip(), 2)
tef.FM_Set_ChannelEqualizer((eqims & 1) == 1) tef.FM_Set_ChannelEqualizer((eqims & 1) == 1)
tef.FM_Set_MphSuppression((eqims & 2) == 2) tef.FM_Set_MphSuppression((eqims & 2) == 2)
out += f"G{bin(eqims).removeprefix('0b').zfill(2)}\n".encode()
state.last_eqims = eqims state.last_eqims = eqims
elif cmd.startswith(b"B"): elif cmd.startswith(b"B"):
state.forced_mono = bool(int(cmd.decode().removeprefix("B").strip(), 2)) state.forced_mono = bool(int(cmd.decode().removeprefix("B").strip(), 2))
tef.FM_Set_Stereo_Min(2 if state.forced_mono else 0) 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"): elif cmd.startswith(b"D"):
state.deemp = int(cmd.decode().removeprefix("D").strip()) state.deemp = int(cmd.decode().removeprefix("D").strip())
dtime = 500 if state.deemp == 0 else (750 if state.deemp == 1 else 0) dtime = 500 if state.deemp == 0 else (750 if state.deemp == 1 else 0)
tef.FM_Set_Deemphasis(dtime) 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.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"X"): tef.APPL_Set_OperationMode(True) # turn off
elif cmd.startswith(b"W"): 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 if tef.modulation == Modulation.FM: state.bw_fm = bw
else: state.bw_am = bw else: state.bw_am = bw
tef.Set_Bandwidth(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"?"): out += b">XRD Python driver\n"
elif cmd.startswith(b"S"): elif cmd.startswith(b"S"):
cmd = cmd[1:] cmd = cmd[1:]