aboutsummaryrefslogtreecommitdiff
path: root/picostream/cli.py
diff options
context:
space:
mode:
Diffstat (limited to 'picostream/cli.py')
-rw-r--r--picostream/cli.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/picostream/cli.py b/picostream/cli.py
index 2006645..87c665b 100644
--- a/picostream/cli.py
+++ b/picostream/cli.py
@@ -47,6 +47,8 @@ class Streamer:
offset_v: float = 0.0,
max_buffer_seconds: Optional[float] = None,
is_gui_mode: bool = False,
+ y_min: Optional[float] = None,
+ y_max: Optional[float] = None,
) -> None:
# --- Configuration ---
self.output_file = output_file
@@ -55,6 +57,8 @@ class Streamer:
self.is_gui_mode = is_gui_mode
self.plot_window_s = plot_window_s
self.max_buffer_seconds = max_buffer_seconds
+ self.y_min = y_min
+ self.y_max = y_max
(
sample_rate_msps,
@@ -390,6 +394,8 @@ class Streamer:
hdf5_path=self.output_file,
display_window_seconds=self.plot_window_s,
decimation_factor=self.decimation_factor,
+ y_min=self.y_min,
+ y_max=self.y_max,
)
plotter.show()
@@ -532,6 +538,16 @@ def generate_unique_filename(base_path: str) -> str:
default=False,
help="Overwrite existing output file.",
)
+@click.option(
+ "--y-min",
+ type=float,
+ help="Minimum Y-axis limit in mV for live plot.",
+)
+@click.option(
+ "--y-max",
+ type=float,
+ help="Maximum Y-axis limit in mV for live plot.",
+)
def main(
sample_rate: float,
resolution: str,
@@ -546,9 +562,21 @@ def main(
offset: float,
max_buff_sec: Optional[float],
force: bool,
+ y_min: Optional[float],
+ y_max: Optional[float],
) -> None:
"""High-speed data acquisition tool for Picoscope 5000a series."""
# --- Argument Validation and Processing ---
+
+ # Validate Y-axis limits
+ if (y_min is None) != (y_max is None):
+ logger.error("Both --y-min and --y-max must be provided together, or neither.")
+ sys.exit(1)
+
+ if y_min is not None and y_max is not None and y_min >= y_max:
+ logger.error(f"Invalid Y-axis range: y_min ({y_min}) must be less than y_max ({y_max}).")
+ sys.exit(1)
+
channel_range_str = VOLTAGE_RANGE_MAP[float(rangev)]
resolution_bits = int(resolution)
@@ -603,6 +631,8 @@ def main(
downsample_mode=downsample_mode,
offset_v=offset,
max_buffer_seconds=max_buff_sec,
+ y_min=y_min,
+ y_max=y_max,
)
# Update the acquisition command in metadata