You've already forked TEF6686_Driver
switch to struct for reading
This commit is contained in:
202
tef.py
202
tef.py
@@ -27,11 +27,9 @@ def pack(*values: int, signed: bool = False): return struct.pack(">" + (("h" if
|
|||||||
|
|
||||||
class TEF6686(BaseTEF668X):
|
class TEF6686(BaseTEF668X):
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Tune_To(self, mode: int, frequency: int | None):
|
def FM_Tune_To(self, mode: int, frequency: int | None): return b"\x20\x01\x01" + (pack(mode, frequency) if frequency is not None else pack(mode)), None, None
|
||||||
return b"\x20\x01\x01" + (pack(mode, frequency) if frequency is not None else pack(mode)), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Tune_To(self, mode: int, frequency: int | None):
|
def AM_Tune_To(self, mode: int, frequency: int | None): return b"\x21\x01\x01" + (pack(mode, frequency) if frequency is not None else pack(mode)), None, None
|
||||||
return b"\x21\x01\x01" + (pack(mode, frequency) if frequency is not None else pack(mode)), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Tune_Options(self, afu_bw_mode: bool = False, afu_bandwidth: int = 2360, afu_mute_time: int = 1000, afu_sample_time: int = 2000):
|
def FM_Set_Tune_Options(self, afu_bw_mode: bool = False, afu_bandwidth: int = 2360, afu_mute_time: int = 1000, afu_sample_time: int = 2000):
|
||||||
@@ -40,85 +38,68 @@ class TEF6686(BaseTEF668X):
|
|||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
@overload
|
@overload
|
||||||
def FM_Set_Bandwidth(self, mode: bool = True, bandwidth: int = 2360, control_sensitivity: int = 1000, low_level_sensitivity: int = 1000, min_bandwidth: int = 560, nominal_bandwidth: int = 2360, control_attack: int = 300):
|
def FM_Set_Bandwidth(self, mode: bool = True, bandwidth: int = 2360, control_sensitivity: int = 1000, low_level_sensitivity: int = 1000, min_bandwidth: int = 560, nominal_bandwidth: int = 2360, control_attack: int = 300):
|
||||||
"""
|
"""Minimal bandwidth requires p2.13, while nominal_bandwidth and control_attack require p2.17 (we have p2.24)"""
|
||||||
Minimal bandwidth requires p2.13, while nominal_bandwidth and control_attack require p2.17 (we have p2.24)
|
|
||||||
"""
|
|
||||||
return b"\x20\x0a\x01" + pack(mode, bandwidth, control_sensitivity, low_level_sensitivity, min_bandwidth, nominal_bandwidth, control_attack), None, None
|
return b"\x20\x0a\x01" + pack(mode, bandwidth, control_sensitivity, low_level_sensitivity, min_bandwidth, nominal_bandwidth, control_attack), None, None
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Bandwidth(self, mode: bool = True, bandwidth: int = 2360, control_sensitivity: int = 1000, low_level_sensitivity: int = 1000):
|
def FM_Set_Bandwidth(self, mode: bool = True, bandwidth: int = 2360, control_sensitivity: int = 1000, low_level_sensitivity: int = 1000):
|
||||||
return b"\x20\x0a\x01" + pack(mode, bandwidth, control_sensitivity, low_level_sensitivity), None, None
|
return b"\x20\x0a\x01" + pack(mode, bandwidth, control_sensitivity, low_level_sensitivity), None, None
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_Bandwidth(self, bandwidth: int = 40):
|
def AM_Set_Bandwidth(self, bandwidth: int = 40): return b"\x21\x0a\x01\x00\x00" + pack(bandwidth), None, None
|
||||||
return b"\x21\x0a\x01\x00\x00" + pack(bandwidth), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_RFAGC(self, start: int = 920, extension: bool = False):
|
def FM_Set_RFAGC(self, start: int = 920, extension: bool = False): return b"\x20\x0b\x01" + pack(start, extension), None, None
|
||||||
return b"\x20\x0b\x01" + pack(start, extension), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_RFAGC(self, start: int = 1000):
|
def AM_Set_RFAGC(self, start: int = 1000): return b"\x21\x0b\x01" + pack(start), None, None
|
||||||
return b"\x21\x0b\x01" + pack(start), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_Antenna(self, attenuation: int = 0):
|
def AM_Set_Antenna(self, attenuation: int = 0): return b"\x21\x0c\x01" + pack(attenuation), None, None
|
||||||
return b"\x21\x0c\x01" + pack(attenuation), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_CoChannelDet(self, mode: bool = True, restart: int = 2, sensitivity: int = 1000, count: int = 3):
|
def AM_Set_CoChannelDet(self, mode: bool = True, restart: int = 2, sensitivity: int = 1000, count: int = 3):
|
||||||
return b"\x21\x0e\x01" + pack(mode, restart, sensitivity, count), None, None
|
return b"\x21\x0e\x01" + pack(mode, restart, sensitivity, count), None, None
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_MphSuppression(self, mode: bool = False):
|
def FM_Set_MphSuppression(self, mode: bool = False): return b"\x20\x14\x01" + pack(mode), None, None
|
||||||
return b"\x20\x14\x01" + pack(mode), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_ChannelEqualizer(self, mode: bool = False):
|
def FM_Set_ChannelEqualizer(self, mode: bool = False): return b"\x20\x16\x01" + pack(mode), None, None
|
||||||
return b"\x20\x16\x01" + pack(mode), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
@overload
|
@overload
|
||||||
def FM_Set_NoiseBlanker(self, mode: bool = True, sensitivity: int = 1000, modulation: int = 900, offset: int = 1, attack: int = 140, decay: int = 2800):
|
def FM_Set_NoiseBlanker(self, mode: bool = True, sensitivity: int = 1000, modulation: int = 900, offset: int = 1, attack: int = 140, decay: int = 2800):
|
||||||
return b"\x20\x17\x01" + pack(mode, sensitivity, 0, modulation, offset, attack, decay), None, None
|
return b"\x20\x17\x01" + pack(mode, sensitivity, 0, modulation, offset, attack, decay), None, None
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_NoiseBlanker(self, mode: bool = True, sensitivity: int = 1000):
|
def FM_Set_NoiseBlanker(self, mode: bool = True, sensitivity: int = 1000): return b"\x20\x17\x01" + pack(mode, sensitivity), None, None
|
||||||
return b"\x20\x17\x01" + pack(mode, sensitivity), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_NoiseBlanker_Options(self, blank_time: int = 210, blank_time2: int = 210, blank_modulation: int = 250):
|
def FM_Set_NoiseBlanker_Options(self, blank_time: int = 210, blank_time2: int = 210, blank_modulation: int = 250): return b"\x20\x18\x01" + pack(blank_time, blank_time2, blank_modulation), None, None
|
||||||
return b"\x20\x18\x01" + pack(blank_time, blank_time2, blank_modulation), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
@overload
|
@overload
|
||||||
def AM_Set_NoiseBlanker(self, mode: bool = True, sensitivity: int = 1000, gain: int = 1000, blank_time: int = 56):
|
def AM_Set_NoiseBlanker(self, mode: bool = True, sensitivity: int = 1000, gain: int = 1000, blank_time: int = 56): return b"\x21\x17\x01" + pack(mode, sensitivity, gain, blank_time), None, None
|
||||||
return b"\x21\x17\x01" + pack(mode, sensitivity, gain, blank_time), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_NoiseBlanker(self, mode: bool = True, sensitivity: int = 1000):
|
def AM_Set_NoiseBlanker(self, mode: bool = True, sensitivity: int = 1000): return b"\x21\x17\x01" + pack(mode, sensitivity), None, None
|
||||||
return b"\x21\x17\x01" + pack(mode, sensitivity), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
@overload
|
@overload
|
||||||
def AM_Set_NoiseBlanker_Audio(self, mode: bool = True, sensitivity: int = 1000, blank_time: int = 800):
|
def AM_Set_NoiseBlanker_Audio(self, mode: bool = True, sensitivity: int = 1000, blank_time: int = 800): return b"\x21\x18\x01" + pack(mode, sensitivity, 0, blank_time), None, None
|
||||||
return b"\x21\x18\x01" + pack(mode, sensitivity, 0, blank_time), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_NoiseBlanker_Audio(self, mode: bool = True, sensitivity: int = 1000):
|
def AM_Set_NoiseBlanker_Audio(self, mode: bool = True, sensitivity: int = 1000): return b"\x21\x18\x01" + pack(mode, sensitivity), None, None
|
||||||
return b"\x21\x18\x01" + pack(mode, sensitivity), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Deemphasis(self, timeconstant: int = 500):
|
def FM_Set_Deemphasis(self, timeconstant: int = 500): return b"\x20\x1f\x01" + pack(timeconstant), None, None
|
||||||
return b"\x20\x1f\x01" + pack(timeconstant), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_LevelStep(self, step1: int = -20, step2: int = -30, step3: int = -40, step4: int = -50, step5: int = -60, step6: int = -60, step7: int = -60):
|
def FM_Set_LevelStep(self, step1: int = -20, step2: int = -30, step3: int = -40, step4: int = -50, step5: int = -60, step6: int = -60, step7: int = -60):
|
||||||
return b"\x20\x26\x01" + pack(step1, step2, step3, step4, step5, step6, step7), None, None
|
return b"\x20\x26\x01" + pack(step1, step2, step3, step4, step5, step6, step7), None, None
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_LevelStep(self, step1: int = -10, step2: int = -20, step3: int = -30, step4: int = -40, step5: int = -50, step6: int = -60, step7: int = -60):
|
def AM_Set_LevelStep(self, step1: int = -10, step2: int = -20, step3: int = -30, step4: int = -40, step5: int = -50, step6: int = -60, step7: int = -60):
|
||||||
return b"\x21\x26\x01" + pack(step1, step2, step3, step4, step5, step6, step7), None, None
|
return b"\x21\x26\x01" + pack(step1, step2, step3, step4, step5, step6, step7), None, None
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_LevelOffset(self, offset: int = 0):
|
def FM_Set_LevelOffset(self, offset: int = 0): return b"\x20\x27\x01" + pack(offset, signed=True), None, None
|
||||||
return b"\x20\x27\x01" + pack(offset, signed=True), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_LevelOffset(self, offset: int = 0):
|
def AM_Set_LevelOffset(self, offset: int = 0): return b"\x21\x27\x01" + pack(offset, signed=True), None, None
|
||||||
return b"\x21\x27\x01" + pack(offset, signed=True), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Softmute_Time(self, slow_attack: int = 120, slow_decay: int = 500, fast_attack: int = 20, fast_decay: int = 20):
|
def FM_Set_Softmute_Time(self, slow_attack: int = 120, slow_decay: int = 500, fast_attack: int = 20, fast_decay: int = 20):
|
||||||
@@ -127,8 +108,7 @@ class TEF6686(BaseTEF668X):
|
|||||||
def AM_Set_Softmute_Time(self, slow_attack: int = 120, slow_decay: int = 500, fast_attack: int = 120, fast_decay: int = 500):
|
def AM_Set_Softmute_Time(self, slow_attack: int = 120, slow_decay: int = 500, fast_attack: int = 120, fast_decay: int = 500):
|
||||||
return b"\x21\x28\x01" + slow_attack.to_bytes(2, "big") + slow_decay.to_bytes(2, "big") + fast_attack.to_bytes(2, "big") + fast_decay.to_bytes(2, "big"), None, None
|
return b"\x21\x28\x01" + slow_attack.to_bytes(2, "big") + slow_decay.to_bytes(2, "big") + fast_attack.to_bytes(2, "big") + fast_decay.to_bytes(2, "big"), None, None
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_Softmute_Mod(self, mode: bool = False, start: int = 210, slope: int = 120, shift: int = 260):
|
def AM_Set_Softmute_Mod(self, mode: bool = False, start: int = 210, slope: int = 120, shift: int = 260): return b"\x21\x29\x01" + pack(mode, start, slope, shift), None, None
|
||||||
return b"\x21\x29\x01" + pack(mode, start, slope, shift), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Softmute_Level(self, mode: int = 0, start: int = 150, slope: int = 220):
|
def FM_Set_Softmute_Level(self, mode: int = 0, start: int = 150, slope: int = 220):
|
||||||
return b"\x20\x2A\x01" + mode.to_bytes(2, "big") + start.to_bytes(2, "big") + slope.to_bytes(2, "big"), None, None
|
return b"\x20\x2A\x01" + mode.to_bytes(2, "big") + start.to_bytes(2, "big") + slope.to_bytes(2, "big"), None, None
|
||||||
@@ -155,50 +135,35 @@ class TEF6686(BaseTEF668X):
|
|||||||
def AM_Set_Highcut_Time(self, slow_attack: int = 500, slow_decay: int = 2000, fast_attack: int = 12, fast_decay: int = 50):
|
def AM_Set_Highcut_Time(self, slow_attack: int = 500, slow_decay: int = 2000, fast_attack: int = 12, fast_decay: int = 50):
|
||||||
return b"\x21\x32\x01" + pack(slow_attack, slow_decay, fast_attack, fast_decay), None, None
|
return b"\x21\x32\x01" + pack(slow_attack, slow_decay, fast_attack, fast_decay), None, None
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Highcut_Mod(self, mode: bool = False, start: int = 250, slope: int = 130, shift: int = 500):
|
def FM_Set_Highcut_Mod(self, mode: bool = False, start: int = 250, slope: int = 130, shift: int = 500): return b"\x20\x33\x01" + pack(mode, start, slope, shift), None, None
|
||||||
return b"\x20\x33\x01" + pack(mode, start, slope, shift), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_Highcut_Mod(self, mode: bool = False, start: int = 250, slope: int = 130, shift: int = 500):
|
def AM_Set_Highcut_Mod(self, mode: bool = False, start: int = 250, slope: int = 130, shift: int = 500): return b"\x21\x33\x01" + pack(mode, start, slope, shift), None, None
|
||||||
return b"\x21\x33\x01" + pack(mode, start, slope, shift), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Highcut_Level(self, mode: int = 3, start: int = 360, slope: int = 300):
|
def FM_Set_Highcut_Level(self, mode: int = 3, start: int = 360, slope: int = 300): return b"\x20\x34\x01" + pack(mode, start, slope), None, None
|
||||||
return b"\x20\x34\x01" + pack(mode, start, slope), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_Highcut_Level(self, mode: int = 2, start: int = 400, slope: int = 200):
|
def AM_Set_Highcut_Level(self, mode: int = 2, start: int = 400, slope: int = 200): return b"\x21\x34\x01" + pack(mode, start, slope), None, None
|
||||||
return b"\x21\x34\x01" + pack(mode, start, slope), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Highcut_Noise(self, mode: int = 2, start: int = 360, slope: int = 300):
|
def FM_Set_Highcut_Noise(self, mode: int = 2, start: int = 360, slope: int = 300): return b"\x20\x35\x01" + pack(mode, start, slope), None, None
|
||||||
return b"\x20\x35\x01" + pack(mode, start, slope), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Highcut_Mph(self, mode: int = 2, start: int = 360, slope: int = 300):
|
def FM_Set_Highcut_Mph(self, mode: int = 2, start: int = 360, slope: int = 300): return b"\x20\x36\x01" + pack(mode, start, slope), None, None
|
||||||
return b"\x20\x36\x01" + pack(mode, start, slope), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Highcut_Max(self, mode: bool = True, limit: int = 4000):
|
def FM_Set_Highcut_Max(self, mode: bool = True, limit: int = 4000): return b"\x20\x37\x01" + pack(mode, limit), None, None
|
||||||
return b"\x20\x37\x01" + pack(mode, limit), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_Highcut_Max(self, mode: bool = True, limit: int = 1800):
|
def AM_Set_Highcut_Max(self, mode: bool = True, limit: int = 1800): return b"\x21\x37\x01" + pack(mode, limit), None, None
|
||||||
return b"\x21\x37\x01" + pack(mode, limit), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Highcut_Min(self, mode: bool = False, limit: int = 10000):
|
def FM_Set_Highcut_Min(self, mode: bool = False, limit: int = 10000): return b"\x20\x38\x01" + pack(mode, limit), None, None
|
||||||
return b"\x20\x38\x01" + pack(mode, limit), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_Highcut_Min(self, mode: bool = False, limit: int = 6000):
|
def AM_Set_Highcut_Min(self, mode: bool = False, limit: int = 6000): return b"\x21\x38\x01" + pack(mode, limit), None, None
|
||||||
return b"\x21\x38\x01" + pack(mode, limit), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Lowcut_Max(self, mode: bool = True, limit: int = 120):
|
def FM_Set_Lowcut_Max(self, mode: bool = True, limit: int = 120): return b"\x20\x39\x01" + pack(mode, limit), None, None
|
||||||
return b"\x20\x39\x01" + pack(mode, limit), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_Lowcut_Max(self, mode: bool = True, limit: int = 120):
|
def AM_Set_Lowcut_Max(self, mode: bool = True, limit: int = 120): return b"\x21\x39\x01" + pack(mode, limit), None, None
|
||||||
return b"\x21\x39\x01" + pack(mode, limit), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Lowcut_Min(self, mode: bool = False, limit: int = 20):
|
def FM_Set_Lowcut_Min(self, mode: bool = False, limit: int = 20): return b"\x20\x3A\x01" + pack(mode, limit), None, None
|
||||||
return b"\x20\x3A\x01" + pack(mode, limit), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AM_Set_Lowcut_Min(self, mode: bool = True, limit: int = 20):
|
def AM_Set_Lowcut_Min(self, mode: bool = True, limit: int = 20): return b"\x21\x3A\x01" + pack(mode, limit), None, None
|
||||||
return b"\x21\x3A\x01" + pack(mode, limit), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Highcut_Options(self, mode: int = 1):
|
def FM_Set_Highcut_Options(self, mode: int = 1): return b"\x20\x3b\x01" + pack(mode), None, None
|
||||||
return b"\x20\x3b\x01" + pack(mode), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Stereo_Time(self, slow_attack: int = 1000, slow_decay: int = 4000, fast_attack: int = 80, fast_decay: int = 80):
|
def FM_Set_Stereo_Time(self, slow_attack: int = 1000, slow_decay: int = 4000, fast_attack: int = 80, fast_decay: int = 80):
|
||||||
@@ -207,84 +172,60 @@ class TEF6686(BaseTEF668X):
|
|||||||
def FM_Set_Stereo_Mod(self, mode: bool = False, start: int = 210, slope: int = 90, shift: int = 500):
|
def FM_Set_Stereo_Mod(self, mode: bool = False, start: int = 210, slope: int = 90, shift: int = 500):
|
||||||
return b"\x20\x3d\x01" + pack(mode, start, slope, shift), None, None
|
return b"\x20\x3d\x01" + pack(mode, start, slope, shift), None, None
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Stereo_Level(self, mode: int = 3, start: int = 460, slope: int = 240):
|
def FM_Set_Stereo_Level(self, mode: int = 3, start: int = 460, slope: int = 240): return b"\x20\x3e\x01" + pack(mode, start, slope), None, None
|
||||||
return b"\x20\x3e\x01" + pack(mode, start, slope), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Stereo_Noise(self, mode: int = 3, start: int = 240, slope: int = 200):
|
def FM_Set_Stereo_Noise(self, mode: int = 3, start: int = 240, slope: int = 200): return b"\x20\x3f\x01" + pack(mode, start, slope), None, None
|
||||||
return b"\x20\x3f\x01" + pack(mode, start, slope), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Stereo_Mph(self, mode: int = 3, start: int = 240, slope: int = 200):
|
def FM_Set_Stereo_Mph(self, mode: int = 3, start: int = 240, slope: int = 200): return b"\x20\x40\x01" + pack(mode, start, slope), None, None
|
||||||
return b"\x20\x40\x01" + pack(mode, start, slope), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Stereo_Max(self, mode: bool = True):
|
def FM_Set_Stereo_Max(self, mode: bool = True): return b"\x20\x41\x01" + pack(mode), None, None
|
||||||
return b"\x20\x41\x01" + pack(mode), None, None
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Stereo_Min(self, mode: int = 0, limit: int = 400):
|
def FM_Set_Stereo_Min(self, mode: int = 0, limit: int = 400): return b"\x20\x42\x01" + pack(mode, limit), None, None
|
||||||
return b"\x20\x42\x01" + pack(mode, limit), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_RDS(self, mode: int = 0, restart: int = 2, interface: int = 0):
|
def FM_Set_RDS(self, mode: int = 0, restart: int = 2, interface: int = 0): return b"\x20\x51\x01" + pack(mode, restart, interface), None, None
|
||||||
return b"\x20\x51\x01" + pack(mode, restart, interface), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Specials(self, mode: int = 0):
|
def FM_Set_Specials(self, mode: int = 0): return b"\x20\x55\x01" + pack(mode), None, None
|
||||||
return b"\x20\x55\x01" + pack(mode), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Set_Bandwidth_Options(self, modulation: int = 950):
|
def FM_Set_Bandwidth_Options(self, modulation: int = 950): return b"\x20\x56\x01" + pack(modulation), None, None
|
||||||
return b"\x20\x56\x01" + pack(modulation), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AUDIO_Set_Volume(self, volume: int = 0):
|
def AUDIO_Set_Volume(self, volume: int = 0): return b"\x30\x0a\x01" + pack(volume, signed=True), None, None
|
||||||
return b"\x30\x0a\x01" + pack(volume, signed=True), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AUDIO_Set_Mute(self, mute: bool = True):
|
def AUDIO_Set_Mute(self, mute: bool = True): return b"\x30\x0b\x01" + pack(mute), None, None
|
||||||
return b"\x30\x0b\x01" + pack(mute), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AUDIO_Set_Input(self, source: int = 0):
|
def AUDIO_Set_Input(self, source: int = 0): return b"\x30\x0c\x01" + pack(source), None, None
|
||||||
return b"\x30\x0c\x01" + pack(source), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AUDIO_Set_Output_Source(self, signal: int, source: int = 224):
|
def AUDIO_Set_Output_Source(self, signal: int, source: int = 224): return b"\x30\x0d\x01" + pack(signal, source), None, None
|
||||||
return b"\x30\x0d\x01" + pack(signal, source), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AUDIO_Set_Ana_Out(self, signal: int, mode: bool = True):
|
def AUDIO_Set_Ana_Out(self, signal: int, mode: bool = True): return b"\x30\x15\x01" + pack(signal, mode), None, None
|
||||||
return b"\x30\x15\x01" + pack(signal, mode), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AUDIO_Set_Dig_IO(self, signal: int, mode: int = 0, format: int = 32, operation: int = 0, sample_rate: int = 4410):
|
def AUDIO_Set_Dig_IO(self, signal: int, mode: int = 0, format: int = 32, operation: int = 0, sample_rate: int = 4410): return b"\x30\x16\x01" + pack(signal, mode, format, operation, sample_rate), None, None
|
||||||
return b"\x30\x16\x01" + pack(signal, mode, format, operation, sample_rate), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AUDIO_Set_Input_Scaler(self, source: int, gain: int = 0):
|
def AUDIO_Set_Input_Scaler(self, source: int, gain: int = 0): return b"\x30\x17\x01" + pack(source) + pack(gain, signed=True), None, None
|
||||||
return b"\x30\x17\x01" + pack(source) + pack(gain, signed=True), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def AUDIO_Set_WaveGen(self, mode: int = 0, offset: int = 0, amplitude1: int = -200, frequency1: int = 400, amplitude2: int = -200, frequency2: int = 1000):
|
def AUDIO_Set_WaveGen(self, mode: int = 0, offset: int = 0, amplitude1: int = -200, frequency1: int = 400, amplitude2: int = -200, frequency2: int = 1000):
|
||||||
return b"\x30\x18\x01" + pack(mode) + offset.to_bytes(2, "big") + pack(amplitude1, signed=True) + pack(frequency1) + pack(amplitude2, signed=True) + pack(frequency2), None, None
|
return b"\x30\x18\x01" + pack(mode) + offset.to_bytes(2, "big") + pack(amplitude1, signed=True) + pack(frequency1) + pack(amplitude2, signed=True) + pack(frequency2), None, None
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def APPL_Set_OperationMode(self, mode: bool = True):
|
def APPL_Set_OperationMode(self, mode: bool = True): return b"\x40\x01\x01" + pack(mode), None, None
|
||||||
return b"\x40\x01\x01" + pack(mode), None, None
|
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def APPL_Set_GPIO(self, pin: int, module: int, feature: int):
|
def APPL_Set_GPIO(self, pin: int, module: int, feature: int): return b"\x40\x03\x01" + pack(pin, module, feature), None, None
|
||||||
return b"\x40\x03\x01" + pack(pin, module, feature), None, None
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_quality_data(data) -> tuple[None, None, None, None, None, None, None] | tuple[int, int, int, int, int, int, int]:
|
def _get_quality_data(data) -> None | tuple[int, int, int, int, int, int, int]:
|
||||||
if data[0] != 0: return None, None, None, None, None, None, None
|
if data[0] != 0: return None
|
||||||
status = (data[1] << 8) | data[2]
|
return struct.unpack(">HhHHhHH", data[1:])
|
||||||
level = int.from_bytes(bytes([data[3], data[4]]), "big", signed=True)
|
|
||||||
usn = (data[5] << 8) | data[6] # "noise" on AM
|
|
||||||
wam = (data[7] << 8) | data[8] # "co-channel" on AM
|
|
||||||
offset = int.from_bytes(bytes([data[9], data[10]]), "big", signed=True)
|
|
||||||
bandwidth = (data[11] << 8) | data[12]
|
|
||||||
modulation = (data[13] << 8) | data[14]
|
|
||||||
return status, level, usn, wam, offset, bandwidth, modulation
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
def FM_Get_Quality_Status(self):
|
def FM_Get_Quality_Status(self):
|
||||||
return b"\x20\x80\x01", 7*2, self._get_quality_data
|
return b"\x20\x80\x01", 7*2, self._get_quality_data
|
||||||
@@ -299,18 +240,12 @@ class TEF6686(BaseTEF668X):
|
|||||||
return b"\x21\x81\x01", 7*2, self._get_quality_data
|
return b"\x21\x81\x01", 7*2, self._get_quality_data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_rds_data_proc_decoder(data) -> tuple[None, None, None, None, None, None] | tuple[int, int, int, int, int, int]:
|
def _get_rds_data_proc_decoder(data) -> None | tuple[int, int, int, int, int, int]:
|
||||||
if data[0] != 0: return None, None, None, None, None, None
|
if data[0] != 0: return None
|
||||||
status = (data[1] << 8) | data[2]
|
return struct.unpack(">HHHHHH", data[1:])
|
||||||
A_block = (data[3] << 8) | data[4]
|
|
||||||
B_block = (data[5] << 8) | data[6]
|
|
||||||
C_block = (data[7] << 8) | data[8]
|
|
||||||
D_block = (data[9] << 8) | data[10]
|
|
||||||
dec_error = (data[11] << 8) | data[12]
|
|
||||||
return status, A_block, B_block, C_block, D_block, dec_error
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_rds_data_proc_demodulator(data):
|
def _get_rds_data_proc_demodulator(data):
|
||||||
if data[0] != 0: return None, None, None
|
if data[0] != 0: return None
|
||||||
status = (data[1] << 8) | data[2]
|
status = (data[1] << 8) | data[2]
|
||||||
raw_data_high = (data[3] << 8) | data[4]
|
raw_data_high = (data[3] << 8) | data[4]
|
||||||
raw_data_low = (data[5] << 8) | data[6]
|
raw_data_low = (data[5] << 8) | data[6]
|
||||||
@@ -335,9 +270,7 @@ class TEF6686(BaseTEF668X):
|
|||||||
"""
|
"""
|
||||||
def proc(data):
|
def proc(data):
|
||||||
if data[0] != 0: return None
|
if data[0] != 0: return None
|
||||||
input_att = (data[1] << 8) | data[2]
|
return struct.unpack(">HH", data[1:])
|
||||||
feedback_att = (data[3] << 8) | data[4]
|
|
||||||
return input_att, feedback_att
|
|
||||||
return b"\x20\x84\x01", 2*2, proc
|
return b"\x20\x84\x01", 2*2, proc
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
@@ -347,7 +280,7 @@ class TEF6686(BaseTEF668X):
|
|||||||
"""
|
"""
|
||||||
def proc(data):
|
def proc(data):
|
||||||
if data[0] != 0: return None
|
if data[0] != 0: return None
|
||||||
value = (data[-2] << 8) | data[-1]
|
value, *_ = struct.unpack(">H", data[1:])
|
||||||
return (value & (1 << 15)) != 0, (value & (1 << 14)) != 0
|
return (value & (1 << 15)) != 0, (value & (1 << 14)) != 0
|
||||||
return b"\x20\x85\x01", 2, proc
|
return b"\x20\x85\x01", 2, proc
|
||||||
|
|
||||||
@@ -355,11 +288,7 @@ class TEF6686(BaseTEF668X):
|
|||||||
def FM_Get_Processing_Status(self):
|
def FM_Get_Processing_Status(self):
|
||||||
def proc(data):
|
def proc(data):
|
||||||
if data[0] != 0: return None
|
if data[0] != 0: return None
|
||||||
softmute = (data[1] << 8) | data[2]
|
return struct.unpack(">HHHH", data[1:])
|
||||||
highcut = (data[3] << 8) | data[4]
|
|
||||||
stereo = (data[5] << 8) | data[6]
|
|
||||||
sthiblend = (data[7] << 8) | data[8]
|
|
||||||
return softmute, highcut, stereo, sthiblend
|
|
||||||
return b"\x20\x86\x01", 2*4, proc
|
return b"\x20\x86\x01", 2*4, proc
|
||||||
|
|
||||||
@_command_wrapper
|
@_command_wrapper
|
||||||
@@ -373,8 +302,5 @@ class TEF6686(BaseTEF668X):
|
|||||||
def APPL_Get_Identification(self):
|
def APPL_Get_Identification(self):
|
||||||
def proc(data):
|
def proc(data):
|
||||||
if data[0] != 0: return None
|
if data[0] != 0: return None
|
||||||
device = (data[1] << 8) | data[2]
|
return struct.unpack(">HHH", data[1:])
|
||||||
hw_version = (data[3] << 8) | data[4]
|
|
||||||
sw_version = (data[5] << 8) | data[6]
|
|
||||||
return device, hw_version, sw_version
|
|
||||||
return b"\x40\x82\x01", 2*3, proc
|
return b"\x40\x82\x01", 2*3, proc
|
||||||
11
xrd.py
11
xrd.py
@@ -108,7 +108,7 @@ def process_command(tef: TEF6686, data: bytes, state: dict, conn: socket.socket)
|
|||||||
for freq in range(state["scan_start"], state["scan_stop"] + state["scan_step"], state["scan_step"]):
|
for freq in range(state["scan_start"], state["scan_stop"] + state["scan_step"], state["scan_step"]):
|
||||||
tef.FM_Tune_To(2, freq) # Auto mutes, less commands sent
|
tef.FM_Tune_To(2, freq) # Auto mutes, less commands sent
|
||||||
time.sleep(0.0064)
|
time.sleep(0.0064)
|
||||||
_, level, *_ = tef.FM_Get_Quality_Data()
|
_, level, *_ = d if (d := tef.FM_Get_Quality_Data()) else (None, None)
|
||||||
if level is None: continue
|
if level is None: continue
|
||||||
conn.sendall(str(freq * 10).encode() + b" = " + str(level // 10).encode() + b", ")
|
conn.sendall(str(freq * 10).encode() + b" = " + str(level // 10).encode() + b", ")
|
||||||
conn.sendall(b"\n")
|
conn.sendall(b"\n")
|
||||||
@@ -121,8 +121,9 @@ def process_command(tef: TEF6686, data: bytes, state: dict, conn: socket.socket)
|
|||||||
def send_signal_status(tef: TEF6686, conn: socket.socket, state: dict):
|
def send_signal_status(tef: TEF6686, conn: socket.socket, state: dict):
|
||||||
_, _, stereo, _ = d if (d := tef.FM_Get_Processing_Status()) else (None, None, 1000, None)
|
_, _, stereo, _ = d if (d := tef.FM_Get_Processing_Status()) else (None, None, 1000, None)
|
||||||
|
|
||||||
status, level, usn, wam, _, bandwidth, _ = tef.FM_Get_Quality_Data()
|
res = tef.FM_Get_Quality_Data()
|
||||||
if status is None or level is None or wam is None or usn is None or bandwidth is None: return
|
if res is None: return
|
||||||
|
_, level, usn, wam, _, bandwidth, *_ = res
|
||||||
|
|
||||||
level = level / 10
|
level = level / 10
|
||||||
|
|
||||||
@@ -135,7 +136,9 @@ def send_signal_status(tef: TEF6686, conn: socket.socket, state: dict):
|
|||||||
conn.sendall(data)
|
conn.sendall(data)
|
||||||
|
|
||||||
def send_rds_data(tef: TEF6686, conn: socket.socket):
|
def send_rds_data(tef: TEF6686, conn: socket.socket):
|
||||||
status, A, B, C, D, dec_error = tef.FM_Get_RDS_Data__decoder()
|
res = tef.FM_Get_RDS_Data__decoder()
|
||||||
|
if res is None: return
|
||||||
|
status, A, B, C, D, dec_error = res
|
||||||
if status is None or A is None or B is None or C is None or D is None or dec_error is None: return # Fucking hate pyright
|
if status is None or A is None or B is None or C is None or D is None or dec_error is None: return # Fucking hate pyright
|
||||||
|
|
||||||
if (status & (1 << 9) == 0) or (status & (1 << 15) == 0): return
|
if (status & (1 << 9) == 0) or (status & (1 << 15) == 0): return
|
||||||
|
|||||||
Reference in New Issue
Block a user