driver: expose _odr_type for filter cfgs

This commit is contained in:
linuswck 2024-10-10 15:26:45 +08:00
parent 4f19d2c2be
commit cb2bc505c9

View File

@ -80,13 +80,19 @@ class FilterConfig:
f21sps = "F21SPS"
f20sps = "F20SPS"
f16sps = "F16SPS"
def _odr_type(self):
return "sinc5sinc1postfilter"
_odr_type = "sinc5sinc1postfilter"
def _filter_type(self):
return "Sinc5Sinc1With50hz60HzRejection"
@classmethod
def get_list_of_settings(cls):
ret = []
for e in cls:
if e not in [cls._odr_type]:
ret.append(e)
return ret
class Sinc5Sinc1(StrEnum):
f31250_0sps = "F31250_0SPS"
f15625_0sps = "F15625_0SPS"
@ -106,13 +112,19 @@ class FilterConfig:
f5_0sps = "F5_0SPS"
f2_5sps = "F2_5SPS"
f1_25sps = "F1_25SPS"
def _odr_type(self):
return "sinc5sinc1odr"
_odr_type = "sinc5sinc1odr"
def _filter_type(self):
return "Sinc5Sinc1"
@classmethod
def get_list_of_settings(cls):
ret = []
for e in cls:
if e not in [cls._odr_type]:
ret.append(e)
return ret
class Sinc3(StrEnum):
f31250_0sps = "F31250_0SPS"
f15625_0sps = "F15625_0SPS"
@ -131,23 +143,28 @@ class FilterConfig:
f10_0sps = "F10_0SPS"
f5_0sps = "F5_0SPS"
f2_5sps = "F2_5SPS"
f1_25sps = "F1_25SPS"
def _odr_type(self):
return "sinc3odr"
f1_25sps = "F1_25SPS"
_odr_type = "sinc3odr"
def _filter_type(self):
return "Sinc3"
@classmethod
def get_list_of_settings(cls):
ret = []
for e in cls:
if e not in [cls._odr_type]:
ret.append(e)
return ret
class Sinc3WithFineODR():
upper_limit = 31250
lower_limit = 1.907465
_odr_type = "sinc3fineodr"
def __init__(self, rate):
assert rate >= self.lower_limit and rate <= self.upper_limit
self.rate = float(rate)
def _odr_type(self):
return "sinc3fineodr"
def _filter_type(self):
return "Sinc3WithFineODR"
@ -614,12 +631,12 @@ class Thermostat:
if hasattr(filter_config, 'rate'):
cmd[self._cmd.ConfigTempAdcFilter] = {
"filter_type": filter_config._filter_type(),
filter_config._odr_type(): filter_config.rate,
filter_config._odr_type: filter_config.rate,
}
else:
cmd[self._cmd.ConfigTempAdcFilter] = {
"filter_type": filter_config._filter_type(),
filter_config._odr_type(): filter_config,
filter_config._odr_type: filter_config,
}
return await self._send_raw_cmd(cmd)