UC2-REST 0.2.0.24__tar.gz → 0.2.0.25__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uc2_rest-0.2.0.25/PKG-INFO +151 -0
- uc2_rest-0.2.0.25/README.md +120 -0
- uc2_rest-0.2.0.25/UC2_REST.egg-info/PKG-INFO +151 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/UC2_REST.egg-info/SOURCES.txt +0 -1
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/__version__.py +1 -1
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/camera.py +5 -1
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/mserial.py +2 -4
- uc2_rest-0.2.0.24/PKG-INFO +0 -305
- uc2_rest-0.2.0.24/README.md +0 -274
- uc2_rest-0.2.0.24/UC2_REST.egg-info/PKG-INFO +0 -305
- uc2_rest-0.2.0.24/uc2rest/ledmatrix_.py +0 -214
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/LICENSE +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/UC2_REST.egg-info/dependency_links.txt +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/UC2_REST.egg-info/not-zip-safe +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/UC2_REST.egg-info/requires.txt +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/UC2_REST.egg-info/top_level.txt +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/setup.cfg +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/setup.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/MockSerial.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/UC2Client.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/__init__.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/analog.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/cmdrecorder.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/config.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/config_.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/digitalout.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/galvo.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/gripper.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/home.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/laser.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/ledmatrix.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/logger.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/message.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/modules.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/motor.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/objective.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/pid.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/rotator.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/slm.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/state.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/temperature.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/utils.py +0 -0
- {uc2_rest-0.2.0.24 → uc2_rest-0.2.0.25}/uc2rest/wifi.py +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: UC2-REST
|
|
3
|
+
Version: 0.2.0.25
|
|
4
|
+
Summary: This pacage will help you to drive the ESP32-driven microscopy control modules from UC2
|
|
5
|
+
Home-page: https://github.com/openUC2/UC2-REST
|
|
6
|
+
Author: Benedict Diederich
|
|
7
|
+
Author-email: benedictdied@gmail.com
|
|
8
|
+
License: GPL v3
|
|
9
|
+
Keywords: UC2REST API to control ESP32-driven microscopy control boards
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Requires-Python: >=3.7
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: numpy
|
|
17
|
+
Requires-Dist: requests
|
|
18
|
+
Requires-Dist: pyserial
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: author-email
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: description
|
|
23
|
+
Dynamic: description-content-type
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: keywords
|
|
26
|
+
Dynamic: license
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
Dynamic: requires-dist
|
|
29
|
+
Dynamic: requires-python
|
|
30
|
+
Dynamic: summary
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img src="https://raw.githubusercontent.com/bionanoimaging/UC2-GIT/master/IMAGES/UC2_logo_text.png" width="320" alt="UC2 logo">
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
# UC2‑Python Client
|
|
37
|
+
|
|
38
|
+
Python interface to the **UC2 REST** micro‑controller firmware — control motors, lasers, LED matrices, galvos and more over USB‑Serial or Wi‑Fi from any Python environment.
|
|
39
|
+
|
|
40
|
+
## Highlights
|
|
41
|
+
|
|
42
|
+
- **Plug‑and‑play connection** via USB (`/dev/ttyUSB*`, `COM*`) or TCP (`host`, `port`).
|
|
43
|
+
- **Rich device model**: every hardware block is a Python object with high‑level helpers (e.g. `motor.move_x`, `led.setPattern`, `laser.set_laser`).
|
|
44
|
+
- **Asynchronous & blocking modes** for precise timing or maximum throughput.
|
|
45
|
+
- **Callback hooks** to react to hardware feedback in real time.
|
|
46
|
+
- **Runs everywhere**: desktop Python, headless Raspberry Pi, or in‑browser with PyScript.
|
|
47
|
+
- **LGPL‑3.0‑or‑later** license – use it in academic and commercial projects.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install uc2rest # latest release
|
|
53
|
+
# or for the bleeding‑edge version
|
|
54
|
+
pip install git+https://github.com/openUC2/UC2-REST.git#subdirectory=PYTHON
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Dependencies (`requests`, `numpy`, `pyserial`) are resolved automatically.
|
|
58
|
+
|
|
59
|
+
## Quick start
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import uc2rest
|
|
63
|
+
|
|
64
|
+
# USB example
|
|
65
|
+
esp = uc2rest.UC2Client(serialport="/dev/ttyUSB0") # Linux / Mac OS
|
|
66
|
+
# esp = uc2rest.UC2Client(serialport="COM3") # Windows
|
|
67
|
+
# Wi‑Fi example
|
|
68
|
+
# esp = uc2rest.UC2Client(host="192.168.4.1", port=31950)
|
|
69
|
+
|
|
70
|
+
# LED matrix: switch all pixels on at half intensity
|
|
71
|
+
esp.led.setAll(True, intensity=128)
|
|
72
|
+
|
|
73
|
+
# Move X axis by 1 mm (1000 steps @ 1 kHz)
|
|
74
|
+
esp.motor.move_x(steps=1000, speed=1000, is_blocking=True)
|
|
75
|
+
|
|
76
|
+
# Turn green laser to full power
|
|
77
|
+
esp.laser.set_laser(channel="G", value=255)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Supported modules (automatically attached to `UC2Client`) citeturn1file12
|
|
81
|
+
|
|
82
|
+
| Object | Purpose | Example method(s) |
|
|
83
|
+
|-----------------|---------------------------------------|--------------------------------------|
|
|
84
|
+
| `motor` | X/Y/Z/θ stages | `move_x / move_xy`, `setup_motor` |
|
|
85
|
+
| `led` | 8×8 RGB LED matrix | `setPattern`, `send_LEDMatrix_rings` |
|
|
86
|
+
| `laser` | 3‑channel RGB or IR lasers | `set_laser`, `set_servo` |
|
|
87
|
+
| `galvo` | Analogue DAC & 2‑axis scanner | `set_dac`, `set_scanner_pattern` |
|
|
88
|
+
| `gripper` | Micro‑gripper (servo) | `open`, `close` |
|
|
89
|
+
| `home` | End‑stop homing routines | `home_x`, `home_z` |
|
|
90
|
+
| `rotator` | Filter wheel or Dove prism | `move`, `set_speed` |
|
|
91
|
+
| `objective` | Piezo objective positioner | `move_z`, `calibrate` |
|
|
92
|
+
| `temperature` | NTC digital temperature sensor | `get_temperature` |
|
|
93
|
+
| `analog` | Arbitrary analogue outputs | `set_voltage` |
|
|
94
|
+
| `digitalout` | GPIO (TTL) outputs | `set_pin`, `pulse` |
|
|
95
|
+
| `wifi` | ESP32 network helpers | `scan`, `connect` |
|
|
96
|
+
| `message` | Generic key‑value messaging/trigger | `register_callback`, `trigger_message` |
|
|
97
|
+
|
|
98
|
+
## Design philosophy
|
|
99
|
+
|
|
100
|
+
UC2 REST splits interaction into three JSON endpoints per device:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
/*_act → perform an action (e.g. move)
|
|
104
|
+
/*_set → configure a device (e.g. speed)
|
|
105
|
+
/*_get → query state (e.g. position)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The Python client wraps those endpoints so you rarely deal with raw JSON.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## Running in a browser (PyScript)
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<py-config>
|
|
115
|
+
packages = ["uc2rest"]
|
|
116
|
+
</py-config>
|
|
117
|
+
<py-script>
|
|
118
|
+
from uc2rest import UC2Client
|
|
119
|
+
esp = UC2Client(SerialManager=pyserial_manager) # see docs
|
|
120
|
+
esp.led.setAll(True)
|
|
121
|
+
</py-script>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Documentation & examples
|
|
125
|
+
|
|
126
|
+
* Jupyter notebook tutorial: `PYTHON/UC2_REST_Tutorial_v0.ipynb`
|
|
127
|
+
* Example scripts: `examples/` directory (motor scan, laser modulation, timelapse)
|
|
128
|
+
* Firmware sources and hardware guides: <https://github.com/openUC2>
|
|
129
|
+
|
|
130
|
+
## Troubleshooting
|
|
131
|
+
|
|
132
|
+
| Symptom | Fix |
|
|
133
|
+
|------------------------------|-----|
|
|
134
|
+
| `serial.serialutil.SerialException` | Check port name and permissions (`sudo adduser $USER dialout`) |
|
|
135
|
+
| No JSON response / timeout | Increase `timeout` argument; verify baud rate matches firmware |
|
|
136
|
+
|
|
137
|
+
## Contributing
|
|
138
|
+
|
|
139
|
+
1. Fork the repo and create a feature branch.
|
|
140
|
+
2. Follow the `pre‑commit` checks (`black`, `isort`, `flake8`).
|
|
141
|
+
3. Create pull requests against `develop`.
|
|
142
|
+
|
|
143
|
+
Please open issues for bugs or feature requests.
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT — see `LICENSE` for details.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
Made with 💚 by the OpenUC2 community.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/bionanoimaging/UC2-GIT/master/IMAGES/UC2_logo_text.png" width="320" alt="UC2 logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# UC2‑Python Client
|
|
6
|
+
|
|
7
|
+
Python interface to the **UC2 REST** micro‑controller firmware — control motors, lasers, LED matrices, galvos and more over USB‑Serial or Wi‑Fi from any Python environment.
|
|
8
|
+
|
|
9
|
+
## Highlights
|
|
10
|
+
|
|
11
|
+
- **Plug‑and‑play connection** via USB (`/dev/ttyUSB*`, `COM*`) or TCP (`host`, `port`).
|
|
12
|
+
- **Rich device model**: every hardware block is a Python object with high‑level helpers (e.g. `motor.move_x`, `led.setPattern`, `laser.set_laser`).
|
|
13
|
+
- **Asynchronous & blocking modes** for precise timing or maximum throughput.
|
|
14
|
+
- **Callback hooks** to react to hardware feedback in real time.
|
|
15
|
+
- **Runs everywhere**: desktop Python, headless Raspberry Pi, or in‑browser with PyScript.
|
|
16
|
+
- **LGPL‑3.0‑or‑later** license – use it in academic and commercial projects.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install uc2rest # latest release
|
|
22
|
+
# or for the bleeding‑edge version
|
|
23
|
+
pip install git+https://github.com/openUC2/UC2-REST.git#subdirectory=PYTHON
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Dependencies (`requests`, `numpy`, `pyserial`) are resolved automatically.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import uc2rest
|
|
32
|
+
|
|
33
|
+
# USB example
|
|
34
|
+
esp = uc2rest.UC2Client(serialport="/dev/ttyUSB0") # Linux / Mac OS
|
|
35
|
+
# esp = uc2rest.UC2Client(serialport="COM3") # Windows
|
|
36
|
+
# Wi‑Fi example
|
|
37
|
+
# esp = uc2rest.UC2Client(host="192.168.4.1", port=31950)
|
|
38
|
+
|
|
39
|
+
# LED matrix: switch all pixels on at half intensity
|
|
40
|
+
esp.led.setAll(True, intensity=128)
|
|
41
|
+
|
|
42
|
+
# Move X axis by 1 mm (1000 steps @ 1 kHz)
|
|
43
|
+
esp.motor.move_x(steps=1000, speed=1000, is_blocking=True)
|
|
44
|
+
|
|
45
|
+
# Turn green laser to full power
|
|
46
|
+
esp.laser.set_laser(channel="G", value=255)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Supported modules (automatically attached to `UC2Client`) citeturn1file12
|
|
50
|
+
|
|
51
|
+
| Object | Purpose | Example method(s) |
|
|
52
|
+
|-----------------|---------------------------------------|--------------------------------------|
|
|
53
|
+
| `motor` | X/Y/Z/θ stages | `move_x / move_xy`, `setup_motor` |
|
|
54
|
+
| `led` | 8×8 RGB LED matrix | `setPattern`, `send_LEDMatrix_rings` |
|
|
55
|
+
| `laser` | 3‑channel RGB or IR lasers | `set_laser`, `set_servo` |
|
|
56
|
+
| `galvo` | Analogue DAC & 2‑axis scanner | `set_dac`, `set_scanner_pattern` |
|
|
57
|
+
| `gripper` | Micro‑gripper (servo) | `open`, `close` |
|
|
58
|
+
| `home` | End‑stop homing routines | `home_x`, `home_z` |
|
|
59
|
+
| `rotator` | Filter wheel or Dove prism | `move`, `set_speed` |
|
|
60
|
+
| `objective` | Piezo objective positioner | `move_z`, `calibrate` |
|
|
61
|
+
| `temperature` | NTC digital temperature sensor | `get_temperature` |
|
|
62
|
+
| `analog` | Arbitrary analogue outputs | `set_voltage` |
|
|
63
|
+
| `digitalout` | GPIO (TTL) outputs | `set_pin`, `pulse` |
|
|
64
|
+
| `wifi` | ESP32 network helpers | `scan`, `connect` |
|
|
65
|
+
| `message` | Generic key‑value messaging/trigger | `register_callback`, `trigger_message` |
|
|
66
|
+
|
|
67
|
+
## Design philosophy
|
|
68
|
+
|
|
69
|
+
UC2 REST splits interaction into three JSON endpoints per device:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
/*_act → perform an action (e.g. move)
|
|
73
|
+
/*_set → configure a device (e.g. speed)
|
|
74
|
+
/*_get → query state (e.g. position)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The Python client wraps those endpoints so you rarely deal with raw JSON.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## Running in a browser (PyScript)
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<py-config>
|
|
84
|
+
packages = ["uc2rest"]
|
|
85
|
+
</py-config>
|
|
86
|
+
<py-script>
|
|
87
|
+
from uc2rest import UC2Client
|
|
88
|
+
esp = UC2Client(SerialManager=pyserial_manager) # see docs
|
|
89
|
+
esp.led.setAll(True)
|
|
90
|
+
</py-script>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Documentation & examples
|
|
94
|
+
|
|
95
|
+
* Jupyter notebook tutorial: `PYTHON/UC2_REST_Tutorial_v0.ipynb`
|
|
96
|
+
* Example scripts: `examples/` directory (motor scan, laser modulation, timelapse)
|
|
97
|
+
* Firmware sources and hardware guides: <https://github.com/openUC2>
|
|
98
|
+
|
|
99
|
+
## Troubleshooting
|
|
100
|
+
|
|
101
|
+
| Symptom | Fix |
|
|
102
|
+
|------------------------------|-----|
|
|
103
|
+
| `serial.serialutil.SerialException` | Check port name and permissions (`sudo adduser $USER dialout`) |
|
|
104
|
+
| No JSON response / timeout | Increase `timeout` argument; verify baud rate matches firmware |
|
|
105
|
+
|
|
106
|
+
## Contributing
|
|
107
|
+
|
|
108
|
+
1. Fork the repo and create a feature branch.
|
|
109
|
+
2. Follow the `pre‑commit` checks (`black`, `isort`, `flake8`).
|
|
110
|
+
3. Create pull requests against `develop`.
|
|
111
|
+
|
|
112
|
+
Please open issues for bugs or feature requests.
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT — see `LICENSE` for details.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
Made with 💚 by the OpenUC2 community.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: UC2-REST
|
|
3
|
+
Version: 0.2.0.25
|
|
4
|
+
Summary: This pacage will help you to drive the ESP32-driven microscopy control modules from UC2
|
|
5
|
+
Home-page: https://github.com/openUC2/UC2-REST
|
|
6
|
+
Author: Benedict Diederich
|
|
7
|
+
Author-email: benedictdied@gmail.com
|
|
8
|
+
License: GPL v3
|
|
9
|
+
Keywords: UC2REST API to control ESP32-driven microscopy control boards
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Requires-Python: >=3.7
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: numpy
|
|
17
|
+
Requires-Dist: requests
|
|
18
|
+
Requires-Dist: pyserial
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: author-email
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: description
|
|
23
|
+
Dynamic: description-content-type
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: keywords
|
|
26
|
+
Dynamic: license
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
Dynamic: requires-dist
|
|
29
|
+
Dynamic: requires-python
|
|
30
|
+
Dynamic: summary
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img src="https://raw.githubusercontent.com/bionanoimaging/UC2-GIT/master/IMAGES/UC2_logo_text.png" width="320" alt="UC2 logo">
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
# UC2‑Python Client
|
|
37
|
+
|
|
38
|
+
Python interface to the **UC2 REST** micro‑controller firmware — control motors, lasers, LED matrices, galvos and more over USB‑Serial or Wi‑Fi from any Python environment.
|
|
39
|
+
|
|
40
|
+
## Highlights
|
|
41
|
+
|
|
42
|
+
- **Plug‑and‑play connection** via USB (`/dev/ttyUSB*`, `COM*`) or TCP (`host`, `port`).
|
|
43
|
+
- **Rich device model**: every hardware block is a Python object with high‑level helpers (e.g. `motor.move_x`, `led.setPattern`, `laser.set_laser`).
|
|
44
|
+
- **Asynchronous & blocking modes** for precise timing or maximum throughput.
|
|
45
|
+
- **Callback hooks** to react to hardware feedback in real time.
|
|
46
|
+
- **Runs everywhere**: desktop Python, headless Raspberry Pi, or in‑browser with PyScript.
|
|
47
|
+
- **LGPL‑3.0‑or‑later** license – use it in academic and commercial projects.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install uc2rest # latest release
|
|
53
|
+
# or for the bleeding‑edge version
|
|
54
|
+
pip install git+https://github.com/openUC2/UC2-REST.git#subdirectory=PYTHON
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Dependencies (`requests`, `numpy`, `pyserial`) are resolved automatically.
|
|
58
|
+
|
|
59
|
+
## Quick start
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import uc2rest
|
|
63
|
+
|
|
64
|
+
# USB example
|
|
65
|
+
esp = uc2rest.UC2Client(serialport="/dev/ttyUSB0") # Linux / Mac OS
|
|
66
|
+
# esp = uc2rest.UC2Client(serialport="COM3") # Windows
|
|
67
|
+
# Wi‑Fi example
|
|
68
|
+
# esp = uc2rest.UC2Client(host="192.168.4.1", port=31950)
|
|
69
|
+
|
|
70
|
+
# LED matrix: switch all pixels on at half intensity
|
|
71
|
+
esp.led.setAll(True, intensity=128)
|
|
72
|
+
|
|
73
|
+
# Move X axis by 1 mm (1000 steps @ 1 kHz)
|
|
74
|
+
esp.motor.move_x(steps=1000, speed=1000, is_blocking=True)
|
|
75
|
+
|
|
76
|
+
# Turn green laser to full power
|
|
77
|
+
esp.laser.set_laser(channel="G", value=255)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Supported modules (automatically attached to `UC2Client`) citeturn1file12
|
|
81
|
+
|
|
82
|
+
| Object | Purpose | Example method(s) |
|
|
83
|
+
|-----------------|---------------------------------------|--------------------------------------|
|
|
84
|
+
| `motor` | X/Y/Z/θ stages | `move_x / move_xy`, `setup_motor` |
|
|
85
|
+
| `led` | 8×8 RGB LED matrix | `setPattern`, `send_LEDMatrix_rings` |
|
|
86
|
+
| `laser` | 3‑channel RGB or IR lasers | `set_laser`, `set_servo` |
|
|
87
|
+
| `galvo` | Analogue DAC & 2‑axis scanner | `set_dac`, `set_scanner_pattern` |
|
|
88
|
+
| `gripper` | Micro‑gripper (servo) | `open`, `close` |
|
|
89
|
+
| `home` | End‑stop homing routines | `home_x`, `home_z` |
|
|
90
|
+
| `rotator` | Filter wheel or Dove prism | `move`, `set_speed` |
|
|
91
|
+
| `objective` | Piezo objective positioner | `move_z`, `calibrate` |
|
|
92
|
+
| `temperature` | NTC digital temperature sensor | `get_temperature` |
|
|
93
|
+
| `analog` | Arbitrary analogue outputs | `set_voltage` |
|
|
94
|
+
| `digitalout` | GPIO (TTL) outputs | `set_pin`, `pulse` |
|
|
95
|
+
| `wifi` | ESP32 network helpers | `scan`, `connect` |
|
|
96
|
+
| `message` | Generic key‑value messaging/trigger | `register_callback`, `trigger_message` |
|
|
97
|
+
|
|
98
|
+
## Design philosophy
|
|
99
|
+
|
|
100
|
+
UC2 REST splits interaction into three JSON endpoints per device:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
/*_act → perform an action (e.g. move)
|
|
104
|
+
/*_set → configure a device (e.g. speed)
|
|
105
|
+
/*_get → query state (e.g. position)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The Python client wraps those endpoints so you rarely deal with raw JSON.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## Running in a browser (PyScript)
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<py-config>
|
|
115
|
+
packages = ["uc2rest"]
|
|
116
|
+
</py-config>
|
|
117
|
+
<py-script>
|
|
118
|
+
from uc2rest import UC2Client
|
|
119
|
+
esp = UC2Client(SerialManager=pyserial_manager) # see docs
|
|
120
|
+
esp.led.setAll(True)
|
|
121
|
+
</py-script>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Documentation & examples
|
|
125
|
+
|
|
126
|
+
* Jupyter notebook tutorial: `PYTHON/UC2_REST_Tutorial_v0.ipynb`
|
|
127
|
+
* Example scripts: `examples/` directory (motor scan, laser modulation, timelapse)
|
|
128
|
+
* Firmware sources and hardware guides: <https://github.com/openUC2>
|
|
129
|
+
|
|
130
|
+
## Troubleshooting
|
|
131
|
+
|
|
132
|
+
| Symptom | Fix |
|
|
133
|
+
|------------------------------|-----|
|
|
134
|
+
| `serial.serialutil.SerialException` | Check port name and permissions (`sudo adduser $USER dialout`) |
|
|
135
|
+
| No JSON response / timeout | Increase `timeout` argument; verify baud rate matches firmware |
|
|
136
|
+
|
|
137
|
+
## Contributing
|
|
138
|
+
|
|
139
|
+
1. Fork the repo and create a feature branch.
|
|
140
|
+
2. Follow the `pre‑commit` checks (`black`, `isort`, `flake8`).
|
|
141
|
+
3. Create pull requests against `develop`.
|
|
142
|
+
|
|
143
|
+
Please open issues for bugs or feature requests.
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT — see `LICENSE` for details.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
Made with 💚 by the OpenUC2 community.
|
|
@@ -6,7 +6,7 @@ __version__.py
|
|
|
6
6
|
|
|
7
7
|
__title__ = 'UC2-REST'
|
|
8
8
|
__description__ = 'This pacage will help you to drive the ESP32-driven microscopy control modules from UC2'
|
|
9
|
-
__version__ = "v0.2.0.
|
|
9
|
+
__version__ = "v0.2.0.25"
|
|
10
10
|
__author__ = 'Benedict Diederich'
|
|
11
11
|
__author_email__ = 'benedictdied@gmail.com'
|
|
12
12
|
__license__ = 'GPL v3'
|
|
@@ -60,10 +60,8 @@ class Serial:
|
|
|
60
60
|
if IS_SERIAL:
|
|
61
61
|
self.serialdevice= self.openDevice(port, baudrate)
|
|
62
62
|
else:
|
|
63
|
-
|
|
64
|
-
self.
|
|
65
|
-
self.manufacturer = "UC2Mock"
|
|
66
|
-
self._logger.debug("You have to ensure that the serial device is connected to the computer!")
|
|
63
|
+
''' this is most likely happening because we work under pyoidide '''
|
|
64
|
+
self._logger.debug("You have to provide the serial interface on your own")
|
|
67
65
|
|
|
68
66
|
def breakCurrentCommunication(self):
|
|
69
67
|
self.resetLastCommand = True
|