Loading README.md +21 −1 Original line number Diff line number Diff line # MS210 python driver This repository contains a small python module to control the MS210 Channel Mixer by Advanced Illumination ## Dependencies | Name | Version | |------|---------| | Python | >= 3.10 | | Poetry | >= 1.2.0 | ## Add package TODO: ## Linux For linux user add your user to the *dialout* group to access the serial port ```bash sudo usermod -aG dialout $USER ``` No newline at end of file ms210/driver.py +46 −1 Original line number Diff line number Diff line Loading @@ -50,13 +50,25 @@ class MS210: raise MS210InitFailed(msg) def __del__(self): """Destructor """ for channel in _CHANNELS: self.set_value(channel, 0) self._ser.close() def __check_limits(self, value: int) -> bool: """Check that the value is between the limits Parameters ---------- value : int Value to check Returns ------- False if value is out of bound, True otherwise """ if value > _MAX_VALUE: return False Loading @@ -67,6 +79,13 @@ class MS210: return True def __get_current_values(self) -> tuple[bool, str]: """Read the current values of each channel Returns ------- tuple : bool, str success, error message if not success """ buf = "" Loading @@ -86,9 +105,35 @@ class MS210: return (True, "OK") def get_value(self, channel: Literal["IR", "R", "B", "G"]) -> int: """Get the value of a channel Parameters ---------- channel : str The channel name Returns ------- The current value of the channel """ return [x for x in self.channels if x.name == channel][0].value def set_value(self, channel: Literal["IR", "R", "B", "G"], value : int = 0) -> tuple[bool, str]: """Set the value of a channel Parameters ---------- channel : str The name of the channel value : int The value to set the channel to Returns ------- tuple: bool, str success, an error msg in not success """ if not self.__check_limits(value): return (False, f"Value {value} is out of bound. {_MIN_VALUE} < value < {_MAX_VALUE}") Loading Loading
README.md +21 −1 Original line number Diff line number Diff line # MS210 python driver This repository contains a small python module to control the MS210 Channel Mixer by Advanced Illumination ## Dependencies | Name | Version | |------|---------| | Python | >= 3.10 | | Poetry | >= 1.2.0 | ## Add package TODO: ## Linux For linux user add your user to the *dialout* group to access the serial port ```bash sudo usermod -aG dialout $USER ``` No newline at end of file
ms210/driver.py +46 −1 Original line number Diff line number Diff line Loading @@ -50,13 +50,25 @@ class MS210: raise MS210InitFailed(msg) def __del__(self): """Destructor """ for channel in _CHANNELS: self.set_value(channel, 0) self._ser.close() def __check_limits(self, value: int) -> bool: """Check that the value is between the limits Parameters ---------- value : int Value to check Returns ------- False if value is out of bound, True otherwise """ if value > _MAX_VALUE: return False Loading @@ -67,6 +79,13 @@ class MS210: return True def __get_current_values(self) -> tuple[bool, str]: """Read the current values of each channel Returns ------- tuple : bool, str success, error message if not success """ buf = "" Loading @@ -86,9 +105,35 @@ class MS210: return (True, "OK") def get_value(self, channel: Literal["IR", "R", "B", "G"]) -> int: """Get the value of a channel Parameters ---------- channel : str The channel name Returns ------- The current value of the channel """ return [x for x in self.channels if x.name == channel][0].value def set_value(self, channel: Literal["IR", "R", "B", "G"], value : int = 0) -> tuple[bool, str]: """Set the value of a channel Parameters ---------- channel : str The name of the channel value : int The value to set the channel to Returns ------- tuple: bool, str success, an error msg in not success """ if not self.__check_limits(value): return (False, f"Value {value} is out of bound. {_MIN_VALUE} < value < {_MAX_VALUE}") Loading