Metadata-Version: 2.4
Name: ind-ls-r2x4
Version: 0.4.3
Summary: Interface the R2X4 light source from Industrialise.
Project-URL: Home, https://industrialise.be
Author-email: Lou Vervecken <lou.vervecken@industrialise.be>, Floris Lambrechts <floris.lambrechts@industrialise.be>
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: <3.15,>=3.8
Requires-Dist: cobs
Requires-Dist: pyserial~=3.5
Description-Content-Type: text/markdown

Driver package for the `R2X4` programmable light source from [Industrialise](https://www.industrialise.be).

The R2X4 is a powerful and precise programmable constant-current LED light source.  It has four independent LED channels
and is temperature stabilized.
It is powered using USB Power Delivery or by a DC adapter.


# Installation

The package can be installed from PyPI using `pip` or `uv`:
```bash
pip install ind-ls-r2x4
uv add ind-ls-r2x4
```

There is an optional `Qt`-based GUI available, next to a `tkinter`-based one.
The Qt GUI uses `QtPy` to abstract the Qt backend. The package can be installed with:

```bash
pip install qtpy
uv add qtpy
```

The actual Qt backend needs to be installed separately. For example, to use the `PySide6` backend:

```bash
pip install PySide6
uv add PySide6
```

`PySide2`, `PyQt5` and `PyQt6` are also supported. Checkout the `QtPy` [documentation](https://pypi.org/project/QtPy/) for information on which version of backend 
is supported by which version of `QtPy`.

There is also a `R2X4Panel` available for use in [Gamma Desk](https://pypi.org/project/gamma-desk/) which uses the same widget as the Qt GUI. Check the 
`ls_r2x4.gui.gdesk_panel` module for more information. To install Gamma Desk:
    
```bash
pip install gamma-desk PySide6
uv add gamma-desk PySide6
```


# Usage

## Demo

A text-based demo is started when the package is run as a module:
```bash
python -m ls_r2x4
uv run -m ls_r2x4
```
These top level scripts are available when the Python environment is active:

  - `r2x4_gui_tkinter` : Start the GUI using the `tkinter` backend.
  - `r2x4_gui_qt`: Start the GUI using a Qt backend. This is needs `pyqt` or `pyside` to be installed!

  - `r2x4_demo`: Start the same demo as when the package is run as a script.

More demo scripts are available in the `ls_r2x4.demo.demo` module.

JupyterLab users may refer to a demo Jupyter Notebook available in the `ls_r2x4.demo` folder.


## GUI

To run the GUI, run:

```bash
r2x4_gui_qt
uvx --from ind-ls-r2x4 --with pyside6,qtpy r2x4_gui_qt
```


## Programming API

The main class to use is the `LightSourceR2X4` class.

```python
from ls_r2x4 import LightSourceR2X4
ls = LightSourceR2X4()
ls.connect()
```

A serial port name can be passed to the constructor, if left `None` it will try to find the correct port automatically.

Once the instance is connected, the light source can be controlled using the methods and attributes of the class.

```python
import time
ls.triggering_force_a_channels()
ls.blue_a.value = 5  # set the blue a channel to 5%
ls.red_b.value = 3  # set the red b channel to 3%
time.sleep(2)
ls.triggering_force_b_channels()
time.sleep(1)
ls.blue_a.value = 0  # turn back off
ls.red_b.value = 0
```

Checkout the demo scripts for more examples.
