diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2026-04-21 13:43:52 -0600 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2026-04-21 13:57:46 -0600 |
| commit | 2a634dca0c7962b90004f75c4cdac6225201bb5e (patch) | |
| tree | 3e1f0cd4ff165e77d17ebec5278c9bed885bb1da /devices | |
| parent | b1a61fd29e2282110bc4f4bc4616c55ed9d88dbb (diff) | |
V13
This version contains the profile feature. Allowins users to save the
channels, signals and plots for specific labs.
Diffstat (limited to 'devices')
| -rw-r--r-- | devices/__pycache__/__init__.cpython-312.pyc | bin | 0 -> 396 bytes | |||
| -rw-r--r-- | devices/__pycache__/__init__.cpython-314.pyc | bin | 401 -> 0 bytes | |||
| -rw-r--r-- | devices/__pycache__/analog_input.cpython-312.pyc | bin | 0 -> 23750 bytes | |||
| -rw-r--r-- | devices/__pycache__/analog_input.cpython-314.pyc | bin | 24525 -> 0 bytes | |||
| -rw-r--r-- | devices/__pycache__/base_device.cpython-312.pyc | bin | 0 -> 5615 bytes | |||
| -rw-r--r-- | devices/__pycache__/base_device.cpython-314.pyc | bin | 7588 -> 0 bytes | |||
| -rw-r--r-- | devices/__pycache__/device_registry.cpython-312.pyc | bin | 0 -> 4582 bytes | |||
| -rw-r--r-- | devices/__pycache__/device_registry.cpython-314.pyc | bin | 5930 -> 0 bytes | |||
| -rw-r--r-- | devices/__pycache__/digital_io.cpython-312.pyc | bin | 0 -> 18353 bytes | |||
| -rw-r--r-- | devices/__pycache__/digital_io.cpython-314.pyc | bin | 19331 -> 0 bytes | |||
| -rw-r--r-- | devices/__pycache__/serial_device.cpython-312.pyc | bin | 0 -> 14680 bytes | |||
| -rw-r--r-- | devices/__pycache__/serial_device.cpython-314.pyc | bin | 16431 -> 0 bytes | |||
| -rw-r--r-- | devices/analog_input.py | 26 | ||||
| -rw-r--r-- | devices/digital_io.py | 19 |
14 files changed, 42 insertions, 3 deletions
diff --git a/devices/__pycache__/__init__.cpython-312.pyc b/devices/__pycache__/__init__.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..bd9bb71 --- /dev/null +++ b/devices/__pycache__/__init__.cpython-312.pyc diff --git a/devices/__pycache__/__init__.cpython-314.pyc b/devices/__pycache__/__init__.cpython-314.pyc Binary files differdeleted file mode 100644 index 47d46e4..0000000 --- a/devices/__pycache__/__init__.cpython-314.pyc +++ /dev/null diff --git a/devices/__pycache__/analog_input.cpython-312.pyc b/devices/__pycache__/analog_input.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..2ff8a31 --- /dev/null +++ b/devices/__pycache__/analog_input.cpython-312.pyc diff --git a/devices/__pycache__/analog_input.cpython-314.pyc b/devices/__pycache__/analog_input.cpython-314.pyc Binary files differdeleted file mode 100644 index b6be747..0000000 --- a/devices/__pycache__/analog_input.cpython-314.pyc +++ /dev/null diff --git a/devices/__pycache__/base_device.cpython-312.pyc b/devices/__pycache__/base_device.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..f665ff1 --- /dev/null +++ b/devices/__pycache__/base_device.cpython-312.pyc diff --git a/devices/__pycache__/base_device.cpython-314.pyc b/devices/__pycache__/base_device.cpython-314.pyc Binary files differdeleted file mode 100644 index 6566690..0000000 --- a/devices/__pycache__/base_device.cpython-314.pyc +++ /dev/null diff --git a/devices/__pycache__/device_registry.cpython-312.pyc b/devices/__pycache__/device_registry.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..2694da3 --- /dev/null +++ b/devices/__pycache__/device_registry.cpython-312.pyc diff --git a/devices/__pycache__/device_registry.cpython-314.pyc b/devices/__pycache__/device_registry.cpython-314.pyc Binary files differdeleted file mode 100644 index 780bd71..0000000 --- a/devices/__pycache__/device_registry.cpython-314.pyc +++ /dev/null diff --git a/devices/__pycache__/digital_io.cpython-312.pyc b/devices/__pycache__/digital_io.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..8c7375b --- /dev/null +++ b/devices/__pycache__/digital_io.cpython-312.pyc diff --git a/devices/__pycache__/digital_io.cpython-314.pyc b/devices/__pycache__/digital_io.cpython-314.pyc Binary files differdeleted file mode 100644 index c1a14b4..0000000 --- a/devices/__pycache__/digital_io.cpython-314.pyc +++ /dev/null diff --git a/devices/__pycache__/serial_device.cpython-312.pyc b/devices/__pycache__/serial_device.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..7472878 --- /dev/null +++ b/devices/__pycache__/serial_device.cpython-312.pyc diff --git a/devices/__pycache__/serial_device.cpython-314.pyc b/devices/__pycache__/serial_device.cpython-314.pyc Binary files differdeleted file mode 100644 index 46fb630..0000000 --- a/devices/__pycache__/serial_device.cpython-314.pyc +++ /dev/null diff --git a/devices/analog_input.py b/devices/analog_input.py index 6183f43..508804f 100644 --- a/devices/analog_input.py +++ b/devices/analog_input.py @@ -141,7 +141,22 @@ class AnalogInputDevice(BaseDevice): return self._layer.read() def write_channel(self, channel_id: str, value: Any) -> bool: - return False + """ + Route output commands through the Arduino layer. + + channel_id examples: + "D7" → digital write W:D7:1 or W:D7:0 + "D9" → PWM write P:D9:<duty> (if value is 0-255) + "HEAT" → named param C:HEAT:1.0 + """ + if self.backend != "arduino" or not hasattr(self._layer, "digital_write"): + return False + ch = channel_id.strip() + # Digital pin (D7, D13, etc.) + if ch.upper().startswith("D") and ch[1:].isdigit(): + return self._layer.digital_write(ch, int(bool(value))) + # Named parameter / setpoint + return self._layer.set_parameter(ch, value) def get_config_widget(self) -> QWidget: return AnalogInputConfigWidget(self) @@ -295,7 +310,7 @@ class AnalogInputConfigWidget(QWidget): self._diag_box = QTextEdit() self._diag_box.setObjectName("codeEditor") self._diag_box.setReadOnly(True) - self._diag_box.setMaximumHeight(90) + self._diag_box.setMaximumHeight(160) self._diag_box.setPlaceholderText("Connection log will appear here…") diag_lay.addWidget(self._diag_box) @@ -332,6 +347,13 @@ class AnalogInputConfigWidget(QWidget): lines.append(f"Port: {self.device._ard_port}") lines.append(f"Baud: {self.device._ard_baud}") lines.append(f"pyserial: {'available' if ArduinoLayer.is_pyserial_available() else 'NOT INSTALLED'}") + # Show last raw lines received from Arduino + if hasattr(self.device._layer, "raw_lines"): + raw = self.device._layer.raw_lines + if raw: + lines.append("\nLast lines from Arduino:") + for r in raw: + lines.append(f" {r}") if self.device._last_error: lines.append(f"\nError:\n{self.device._last_error}") self._diag_box.setPlainText("\n".join(lines)) diff --git a/devices/digital_io.py b/devices/digital_io.py index 291baea..53014b5 100644 --- a/devices/digital_io.py +++ b/devices/digital_io.py @@ -206,9 +206,26 @@ class DigitalIODevice(BaseDevice): except Exception as e: print(f"[DigitalIODevice] NI write failed: {e}") elif self.backend == "arduino" and self._ard_layer: - self._ard_layer.write(channel_id, int(bool(value))) + # Map channel ID to Arduino pin name: + # do0→D5, do1→D6, do2→D7... (matches DIGITAL_OUT in firmware) + # Or the channel_id itself if it already looks like D5 + pin = channel_id if channel_id.upper().startswith("D") else f"D{5 + int(channel_id.replace('do',''))}" + self._ard_layer.digital_write(pin, int(bool(value))) return True + def pwm_channel(self, channel_id: str, duty_pct: float) -> bool: + """Send a PWM command to an Arduino output pin (0–100%).""" + if self.backend == "arduino" and self._ard_layer and not self.simulate: + pin = channel_id if channel_id.upper().startswith("D") else f"D{9 + int(channel_id.replace('do',''))}" + return self._ard_layer.pwm_write_pct(pin, duty_pct) + return False + + def set_parameter(self, name: str, value: Any) -> bool: + """Send a named parameter/setpoint to the Arduino.""" + if self.backend == "arduino" and self._ard_layer and not self.simulate: + return self._ard_layer.set_parameter(name, value) + return False + def get_config_widget(self) -> QWidget: return DigitalIOConfigWidget(self) |
