diff --git a/.vscode/launch.json b/.vscode/launch.json index 057b277..e29e90b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "debugpy", "request": "launch", // "program": "src/__main__.py", - "module": "examples.dyscom.example_dyscom_pyplot", + "module": "examples.low_level.example_low_level", "justMyCode": false, // "args": ["COM3"], "console": "integratedTerminal" diff --git a/README.md b/README.md index a0c32bb..b8dba74 100644 --- a/README.md +++ b/README.md @@ -49,32 +49,35 @@ Python 3.11 or higher ## Description - Located in folder `examples` - Run examples with `python -m examples..` + - From root directory of this repository - Example: `python -m examples.dyscom.example_dyscom_fastplotlib` - All examples try to find the serial port that a science mode device is connected to automatically - If that fails, provide serial port name as parameter, e.g. `python -m examples.. COM3` +- Good starting point for an simple stimulation is example `example_mid_level` - Examples have own dependencies, see [Dependencies for examples](#dependencies-for-examples) - General layer - - `example_general.py` - - Demonstrates how to use general layer to initialize device and get serial number and firmware version + - `python -m examples.general.example_general` + - Demonstrates how to use general layer to initialize device, get serial number and firmware version + - Does not call any stimulation functions - Mid level layer - - `example_mid_level_simple` + - `python -m examples.mid_level.example_mid_level_simple` - Demonstrates how to use mid level layer, where a stimulation pattern is send to the stimulator and the device automatically executes the pattern by itself for 15s - - `example_mid_level.py` + - `python -m examples.mid_level.example_mid_level` - Demonstrates how to use mid level layer, where a stimulation pattern is send to the stimulator and the device automatically executes the pattern by itself until user ends stimulation by keyboard - Low level layer - - `example_low_level.py` + - `python -m examples.low_level.example_low_level` - Demonstrates how to use low level layer, where host has to trigger stimulation manually, in this case by pressing a key - - `example_low_level_plot.py` + - `python -m examples.low_level.example_low_level_plot` - Demonstrates how to use low level layer to stimulate, measure current and plot it in a graph using PyPlot - Dyscom layer - - `example_dyscom_get` + - `python -m examples.dyscom.example_dyscom_get` - Demonstrate how to use different get commands from dyscom layer - - `example_dyscom_fastplotlib` - - Demonstrate how to use dyscom layer to measure EMG and BI and plotting values using fastplotlib - - `example_dyscom_pyplot` - - Demonstrate how to use dyscom layer to measure BI and plotting values using PyPlot - - `example_dyscom_write_csv` - - Demonstrate how to use dyscom layer to measure BI and EMG and writing measurement data to a .csv-file + - `python -m examples.dyscom.example_dyscom_fastplotlib` + - Demonstrate how to use dyscom layer to measure data and plotting values using fastplotlib + - `python -m examples.dyscom.example_dyscom_pyplot` + - Demonstrate how to use dyscom layer to measure data and plotting values using PyPlot + - `python -m examples.dyscom.example_dyscom_write_csv` + - Demonstrate how to use dyscom layer to measure data and writing measurement data to a .csv-file ## Dependencies for examples - Install all dependencies @@ -110,4 +113,8 @@ Python 3.11 or higher - Enhanced example low level plot to show all channels ## 0.0.14 -- Improved examples under Linux/MacOS \ No newline at end of file +- Improved examples under Linux/MacOS + +## 0.0.15 +- Clarified readme +- Changed current for ChannelPoint from int to float \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 539eaa9..501e2f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "science_mode_4" -version = "0.0.14" +version = "0.0.15" authors = [ { name="Marc Hofmann", email="marc-hofmann@gmx.de" }, ] diff --git a/src/science_mode_4/protocol/channel_point.py b/src/science_mode_4/protocol/channel_point.py index 0f9d0f5..9445f81 100644 --- a/src/science_mode_4/protocol/channel_point.py +++ b/src/science_mode_4/protocol/channel_point.py @@ -7,31 +7,31 @@ class ChannelPoint(): """Class for channel point""" - def __init__(self, duration_micro_seconds: int, current_milli_ampere: int): + def __init__(self, duration_micro_seconds: int, current_milli_ampere: float): self._duration_in_micro_seconds = duration_micro_seconds self._current_in_milli_ampere = current_milli_ampere @property - def duration_in_micro_seconds(self) -> int: - """Getter for duration""" - return self._duration_in_micro_seconds + def current_in_milli_ampere(self) -> float: + """Getter for current""" + return self._current_in_milli_ampere @property - def current_in_milli_ampere(self) -> int: + def duration_in_micro_seconds(self) -> int: """Getter for duration""" - return self._current_in_milli_ampere + return self._duration_in_micro_seconds def get_data(self) -> bytes: """Convert information to bytes""" - if (self._current_in_milli_ampere < -150) or (self._current_in_milli_ampere > 150): + if (self._current_in_milli_ampere < -150.0) or (self._current_in_milli_ampere > 150.0): raise ValueError(f"Channel point current must be between -150..150 {self._current_in_milli_ampere}") if (self._duration_in_micro_seconds < 0) or (self._duration_in_micro_seconds > 4095): raise ValueError(f"Channel point duration must be between 0..4095 {self._duration_in_micro_seconds}") - c = 2 * self._current_in_milli_ampere + 300 + c = round(2.0 * self._current_in_milli_ampere + 300.0) bb = ByteBuilder() bb.set_bit_to_position(0, 0, 10)