say ok on login, not x
This commit is contained in:
+16
-27
@@ -19,10 +19,10 @@ def _command_wrapper(func: Callable[Concatenate[TEF6686, P], tuple[bytes, int |
|
||||
data, read_bytes, out_parser = func(self, *args, **kwargs)
|
||||
data, read_bytes, out_parser = self._pre_command_(func, data, read_bytes, out_parser)
|
||||
|
||||
if read_bytes: data = self.p.write_read_i2c(self.address, data, read_bytes)
|
||||
if read_bytes:
|
||||
data = self.p.write_read_i2c(self.address, data, read_bytes)
|
||||
else: data = self.p.write_i2c(self.address, data)
|
||||
if out_parser: return out_parser(data)
|
||||
return data
|
||||
return out_parser(data) if out_parser else data
|
||||
return inner
|
||||
|
||||
class SignedInt(int): ...
|
||||
@@ -53,14 +53,10 @@ class TEF6686(BaseTEF668X):
|
||||
return b"\x20\x02\x01" + pack(afu_bw_mode, afu_bandwidth, afu_mute_time, afu_sample_time), None, None
|
||||
|
||||
@_command_wrapper
|
||||
@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):
|
||||
"""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
|
||||
@_command_wrapper
|
||||
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
|
||||
@_command_wrapper
|
||||
def AM_Set_Bandwidth(self, bandwidth: int = 40): return b"\x21\x0a\x01\x00\x00" + pack(bandwidth), None, None
|
||||
|
||||
@_command_wrapper
|
||||
@@ -81,11 +77,8 @@ class TEF6686(BaseTEF668X):
|
||||
def FM_Set_ChannelEqualizer(self, mode: bool = False): return b"\x20\x16\x01" + pack(mode), None, None
|
||||
|
||||
@_command_wrapper
|
||||
@overload
|
||||
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
|
||||
@_command_wrapper
|
||||
def FM_Set_NoiseBlanker(self, mode: bool = True, sensitivity: int = 1000): return b"\x20\x17\x01" + pack(mode, sensitivity), None, None
|
||||
|
||||
@_command_wrapper
|
||||
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
|
||||
@@ -224,8 +217,7 @@ class TEF6686(BaseTEF668X):
|
||||
|
||||
@_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):
|
||||
# Not sure if offset is signed or not
|
||||
return b"\x30\x18\x01" + pack(mode, offset, SignedInt(amplitude1), frequency1, SignedInt(amplitude2), frequency2), None, None
|
||||
return b"\x30\x18\x01" + pack(mode, SignedInt(offset), SignedInt(amplitude1), frequency1, SignedInt(amplitude2), frequency2), None, None
|
||||
|
||||
@_command_wrapper
|
||||
def APPL_Set_OperationMode(self, mode: bool = True): return b"\x40\x01\x01" + pack(mode), None, None
|
||||
@@ -238,7 +230,7 @@ class TEF6686(BaseTEF668X):
|
||||
@staticmethod
|
||||
def _get_quality_data(data) -> None | tuple[int, int, int, int, int, int, int]:
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack(">HhHHhHH", data[1:])
|
||||
return struct.unpack_from(">HhHHhHH", data, 1)
|
||||
@_command_wrapper
|
||||
def FM_Get_Quality_Status(self):
|
||||
return b"\x20\x80\x01", 7*2, self._get_quality_data
|
||||
@@ -254,15 +246,12 @@ class TEF6686(BaseTEF668X):
|
||||
|
||||
@staticmethod
|
||||
def _get_rds_data_proc_decoder(data) -> None | tuple[int, int, int, int, int, int]:
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack(">HHHHHH", data[1:])
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack_from(">HHHHHH", data, 1)
|
||||
@staticmethod
|
||||
def _get_rds_data_proc_demodulator(data):
|
||||
if data[0] != 0: return None
|
||||
status = (data[1] << 8) | data[2]
|
||||
raw_data_high = (data[3] << 8) | data[4]
|
||||
raw_data_low = (data[5] << 8) | data[6]
|
||||
return status, (raw_data_high << 16) | raw_data_low
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack_from(">HI", data, 1)
|
||||
@_command_wrapper
|
||||
def FM_Get_RDS_Status__decoder(self):
|
||||
return b"\x20\x82\x01", 2*6, self._get_rds_data_proc_decoder
|
||||
@@ -283,7 +272,7 @@ class TEF6686(BaseTEF668X):
|
||||
"""
|
||||
def proc(data):
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack(">HH", data[1:])
|
||||
return struct.unpack_from(">HH", data, 1)
|
||||
return b"\x20\x84\x01", 2*2, proc
|
||||
|
||||
@_command_wrapper
|
||||
@@ -293,7 +282,7 @@ class TEF6686(BaseTEF668X):
|
||||
"""
|
||||
def proc(data):
|
||||
if data[0] != 0: return None
|
||||
value, *_ = struct.unpack(">H", data[1:])
|
||||
value, *_ = struct.unpack_from(">H", data, 1)
|
||||
return (value & (1 << 15)) != 0, (value & (1 << 14)) != 0
|
||||
return b"\x20\x85\x01", 2, proc
|
||||
|
||||
@@ -301,7 +290,7 @@ class TEF6686(BaseTEF668X):
|
||||
def FM_Get_Processing_Status(self):
|
||||
def proc(data):
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack(">HHHH", data[1:])
|
||||
return struct.unpack_from(">HHHH", data, 1)
|
||||
return b"\x20\x86\x01", 2*4, proc
|
||||
|
||||
# Get_Operation_Status is defined in the base
|
||||
@@ -317,14 +306,14 @@ class TEF6686(BaseTEF668X):
|
||||
def APPL_Get_Identification(self):
|
||||
def proc(data):
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack(">HHH", data[1:])
|
||||
return struct.unpack_from(">HHH", data, 1)
|
||||
return b"\x40\x82\x01", 2*3, proc
|
||||
|
||||
@_command_wrapper
|
||||
def APPL_Get_LastWrite(self):
|
||||
def proc(data):
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack(">HHHHHHH", data[1:])
|
||||
return struct.unpack_from(">HHHHHHH", data, 1)
|
||||
return b"\x40\x83\x01", 2*7, proc
|
||||
|
||||
@overload
|
||||
@@ -401,13 +390,13 @@ class TEF6688(TEF6686):
|
||||
def FM_Get_Interface_Status(self):
|
||||
def parse(data):
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack(">H", data[1:])
|
||||
return struct.unpack_from(">H", data, 1)
|
||||
return b"\x20\x87\x01", 2, parse
|
||||
@_8_command_wrapper
|
||||
def AM_Get_Interface_Status(self):
|
||||
def parse(data):
|
||||
if data[0] != 0: return None
|
||||
return struct.unpack(">H", data[1:])
|
||||
return struct.unpack_from(">H", data, 1)
|
||||
return b"\x21\x87\x01", 2, parse
|
||||
|
||||
# This is a combination of all of the features of those all
|
||||
|
||||
Reference in New Issue
Block a user