diff --git a/flexsea/__init__.py b/flexsea/__init__.py index bc5813e7..13b4a72f 100644 --- a/flexsea/__init__.py +++ b/flexsea/__init__.py @@ -1 +1 @@ -__version__ = "12.0.4" +__version__ = "12.1.0" diff --git a/flexsea/device.py b/flexsea/device.py index 2013a62b..0ba36e83 100644 --- a/flexsea/device.py +++ b/flexsea/device.py @@ -1683,3 +1683,115 @@ def streaming(self) -> bool: if self.connected: return self._clib.fxIsStreaming(self.id) return False + + # ----- + # request_re_config_settings + # ----- + @minimum_required_version("13.0.0") + @validate + def _request_re_config_settings(self) -> int: + return self._clib.fxRequestRegulateConfigSettings(self.id) + + # ----- + # battery_type + # ----- + @minimum_required_version("13.0.0") + @property + def battery_type(self) -> str: + self._request_re_config_settings() + sleep(1) + batteryType = c.c_int() + retCode = self._clib.fxGetBatteryType(self.id, c.byref(batteryType)) + if retCode != self._SUCCESS.value: + raise RuntimeError("Could not read battery type.") + return fxc.batteryTypes[batteryType.value] + + # ----- + # battery_type - setter + # ----- + @minimum_required_version("13.0.0") + @battery_type.setter + @validate + def battery_type(self, batteryType: int | c.c_int) -> None: + if isinstance(batteryType, c.c_int): + batteryType = batteryType.value + if batteryType not in fxc.batteryTypes: + raise ValueError(f"Error: invalid battery type {batteryType}") + self._request_re_config_settings() + sleep(1) + batteryType = c.c_int(batteryType) + return self._clib.fxSetBatteryType(self.id, batteryType) + + # ----- + # running_led_sequence + # ----- + @minimum_required_version("13.0.0") + @property + def running_led_sequence(self) -> str: + self._request_re_config_settings() + sleep(1) + ledSequence = c.c_int() + retCode = self._clib.fxGetRunningLEDSequence(self.id, c.byref(ledSequence)) + if retCode != self._SUCCESS.value: + raise RuntimeError("Could not read running led sequence.") + return fxc.ledSequences[ledSequence.value] + + # ----- + # init_led_sequence + # ----- + @minimum_required_version("13.0.0") + @property + def init_led_sequence(self) -> str: + self._request_re_config_settings() + sleep(1) + ledSequence = c.c_int() + retCode = self._clib.fxGetInitLEDSequence(self.id, c.byref(ledSequence)) + if retCode != self._SUCCESS.value: + raise RuntimeError("Could not read init led sequence.") + return fxc.ledSequences[ledSequence.value] + + # ----- + # init_led_sequence - setter + # ----- + @minimum_required_version("13.0.0") + @init_led_sequence.setter + @validate + def init_led_sequence(self, ledSequence: int | c.c_int) -> None: + if isinstance(ledSequence, c.c_int): + ledSequence = ledSequence.value + if ledSequence not in fxc.ledSequences: + raise ValueError(f"Error: invalid led sequence {ledSequence}") + self._request_re_config_settings() + sleep(1) + ledSequence = c.c_int(ledSequence) + return self._clib.fxSetInitLEDSequence(self.id, ledSequence) + + # ----- + # shutoff_led_sequence + # ----- + @minimum_required_version("13.0.0") + @property + def shutoff_led_sequence(self) -> str: + self._request_re_config_settings() + sleep(1) + ledSequence = c.c_int() + retCode = self._clib.fxGetShutoffLEDSequence(self.id, c.byref(ledSequence)) + if retCode != self._SUCCESS.value: + raise RuntimeError("Could not read shutoff led sequence.") + return fxc.ledSequences[ledSequence.value] + + # ----- + # shutoff_led_sequence - setter + # ----- + @minimum_required_version("13.0.0") + @shutoff_led_sequence.setter + @validate + def shutoff_led_sequence(self, ledSequence: int | c.c_int) -> None: + if isinstance(ledSequence, c.c_int): + ledSequence = ledSequence.value + if ledSequence not in fxc.ledSequences: + raise ValueError(f"Error: invalid ledSequence type {ledSequence}") + self._request_re_config_settings() + sleep(1) + ledSequence = c.c_int(ledSequence) + return self._clib.fxSetShutoffLEDSequence(self.id, ledSequence) diff --git a/flexsea/utilities/constants.py b/flexsea/utilities/constants.py index ff6ea295..4f7a6e8b 100644 --- a/flexsea/utilities/constants.py +++ b/flexsea/utilities/constants.py @@ -171,3 +171,69 @@ # past v9, the number of UTTs is fixed, so we hard code it here, though it makes # me sad to do so nUttsV9 = 15 + + +# ============================================ +# Battery Types +# ============================================ +BATTERY_TYPE_UNKNOWN = c.c_int(0) +BATTERY_TYPE_6_CELL = c.c_int(1) +BATTERY_TYPE_8_CELL = c.c_int(2) +BATTERY_TYPE_10_CELL = c.c_int(3) +BATTERY_TYPE_11_CELL = c.c_int(4) +BATTERY_TYPE_12_CELL = c.c_int(5) +POWER_SUPPLY = c.c_int(6) + +batteryTypes = { + BATTERY_TYPE_UNKNOWN.value: "unknown", + BATTERY_TYPE_6_CELL.value: "6 cell", + BATTERY_TYPE_8_CELL.value: "8 cell", + BATTERY_TYPE_10_CELL.value: "10 cell", + BATTERY_TYPE_11_CELL.value: "11 cell", + BATTERY_TYPE_12_CELL.value: "12 cell", + POWER_SUPPLY.value: "power supply", +} + + +# ============================================ +# LED Sequences +# ============================================ +UNIDENTIFIED_LED_SEQUENCE = c.c_int(0) +SET_GREEN_BREATHE = c.c_int(1) +SET_RED_BREATHE = c.c_int(2) +SET_CYAN_BREATHE = c.c_int(3) +SET_BLUE_BREATHE = c.c_int(4) +SET_WHITE_BREATHE = c.c_int(5) +SET_YELLOW_BREATHE = c.c_int(6) +SET_GREEN_ON = c.c_int(7) +SET_YELLOW_ON = c.c_int(8) +SET_RED_ON = c.c_int(9) +SET_CYAN_ON = c.c_int(10) +SET_CYLON = c.c_int(11) +SET_RED_FADE = c.c_int(12) +SET_YELLOW_FADE = c.c_int(13) +SET_GREEN_FADE = c.c_int(14) +SET_TO_DISPLAY_BATTERY_LEVEL = c.c_int(15) +SET_TO_WHITE_BLINK = c.c_int(16) +ALL_LEDS_OFF = c.c_int(17) + +ledSequences = { + UNIDENTIFIED_LED_SEQUENCE.value: "uidentified", + SET_GREEN_BREATHE.value: "green breathe", + SET_RED_BREATHE.value: "red breathe", + SET_CYAN_BREATHE.value: "cyan breathe", + SET_BLUE_BREATHE.value: "blue breathe", + SET_WHITE_BREATHE.value: "white breathe", + SET_YELLOW_BREATHE.value: "yellow breathe", + SET_GREEN_ON.value: "green on", + SET_YELLOW_ON.value: "yellow on", + SET_RED_ON.value: "red on", + SET_CYAN_ON.value: "cyan on", + SET_CYLON.value: "cylon", + SET_RED_FADE.value: "red fade", + SET_YELLOW_FADE.value: "yellow fade", + SET_GREEN_FADE.value: "green fade", + SET_TO_DISPLAY_BATTERY_LEVEL.value: "display battery level", + SET_TO_WHITE_BLINK.value: "white blink", + ALL_LEDS_OFF.value: "all off", +} diff --git a/pyproject.toml b/pyproject.toml index 55aaa858..b0905355 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "flexsea" -version = "12.0.4" +version = "12.1.0" description = "" authors = ["Jared "] readme = "README.md"