Skip to content

Commit b8df71a

Browse files
committed
Update Oscilloscope API
- The API is now more similar to LogicAnalyzer. - Triggering can now be configured directly in `capture` via the `trigger` and `trigger_channel` arguments. - `capture_nonblocking` has been replaced by a `block` argument in `capture`. - `capture` now returns a list of numpy.ndarray. - `fetch_data` no longer takes the channel name as input; instead, all sampled channels are returned in a list of numpy.ndarray. - Analog gain handling has been moved from AnalogInput to Oscilloscope in order to comply with the architecture design of IO classes being representations only.
1 parent 7514259 commit b8df71a

8 files changed

+161
-203
lines changed

PSL/achan.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414
import numpy as np
1515

16-
import PSL.commands_proto as CP
17-
from PSL import packet_handler
18-
1916
logger = logging.getLogger(__name__)
2017

2118
GAIN_VALUES = (1, 2, 4, 5, 8, 10, 16, 32)
@@ -76,19 +73,18 @@ class AnalogInput:
7673
Number used to refer to this channel in the firmware.
7774
"""
7875

79-
def __init__(self, name: str, device: packet_handler.Handler):
76+
def __init__(self, name: str):
8077
self._name = name
81-
self._device = device
8278
self._resolution = 2 ** 10 - 1
8379

8480
if self._name == "CH1":
85-
self._programmable_gain_amplifier = 1
86-
self.gain = 1
81+
self.programmable_gain_amplifier = 1
82+
self._gain = 1
8783
elif self._name == "CH2":
88-
self._programmable_gain_amplifier = 2
89-
self.gain = 1
84+
self.programmable_gain_amplifier = 2
85+
self._gain = 1
9086
else:
91-
self._programmable_gain_amplifier = None
87+
self.programmable_gain_amplifier = None
9288
self._gain = 1
9389

9490
self.samples_in_buffer = 0
@@ -125,12 +121,6 @@ def gain(self, value: Union[int, float]):
125121
if value not in GAIN_VALUES:
126122
raise ValueError(f"Invalid gain. Valid values are {GAIN_VALUES}.")
127123

128-
gain_idx = GAIN_VALUES.index(value)
129-
self._device.send_byte(CP.ADC)
130-
self._device.send_byte(CP.SET_PGA_GAIN)
131-
self._device.send_byte(self._programmable_gain_amplifier)
132-
self._device.send_byte(gain_idx)
133-
self._device.get_ack()
134124
self._gain = value
135125
self._calibrate()
136126

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy