1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! # FleaScope RS
//!
//! A Rust library for configuring triggers and communicating with FleaScope oscilloscope devices.
//!
//! This library provides types and builders for creating digital and analog triggers
//! that can be used to control data capture timing in FleaScope oscilloscope devices,
//! as well as a serial terminal interface for communication and complete device control.
//!
//! ## Features
//!
//! - **Cross-platform device discovery**: Uses `serialport` for finding FleaScope devices
//! - **Trigger configuration**: Digital and analog triggers with builder patterns
//! - **Data acquisition**: Raw oscilloscope data reading with automatic time indexing
//! - **Calibration management**: Read/write probe calibrations from/to device flash
//! - **DataFrame output**: Uses `polars` for efficient data handling instead of pandas
//! - **Type safety**: Strong typing and error handling throughout
//!
//! ## Examples
//!
//! ### Device Connection and Basic Usage
//!
//! ```rust,no_run
//! use fleascope_rs::{FleaScope, ProbeType, Waveform};
//! use std::time::Duration;
//!
//! // Connect to any available FleaScope device
//! let mut scope = FleaScope::connect(None, None, true)?;
//!
//! // Set up signal generator
//! scope.set_waveform(Waveform::Sine, 1000)?; // 1kHz sine wave
//!
//! // Read data using the 1x probe with default auto trigger
//! let data = scope.read(ProbeType::X1, Duration::from_millis(10), None, None)?;
//! println!("Captured {} samples", data.height());
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! ### Digital Trigger
//!
//! ```rust
//! use fleascope_rs::trigger_config::{DigitalTrigger, BitState};
//!
//! let trigger = DigitalTrigger::start_capturing_when()
//! .bit0(BitState::High)
//! .bit1(BitState::Low)
//! .starts_matching();
//!
//! let trigger_fields = trigger.into_trigger_fields();
//! println!("Digital trigger: {}", trigger_fields);
//! ```
//!
//! ### Analog Trigger
//!
//! ```rust
//! use fleascope_rs::trigger_config::AnalogTrigger;
//!
//! let trigger = AnalogTrigger::start_capturing_when()
//! .rising_edge(1.5);
//!
//! let voltage_to_raw = |v: f64| v * 100.0;
//! let trigger_fields = trigger.into_trigger_fields(voltage_to_raw).unwrap();
//! println!("Analog trigger: {}", trigger_fields);
//! ```
//!
//! ### Data Acquisition with Triggers
//!
//! ```rust,no_run
//! use fleascope_rs::{FleaScope, ProbeType, DigitalTrigger, AnalogTrigger, Trigger, BitState};
//! use std::time::Duration;
//!
//! let mut scope = FleaScope::connect(None, None, true)?;
//!
//! // Read with unified trigger API - digital trigger using 1x probe
//! let digital_trigger = DigitalTrigger::start_capturing_when()
//! .bit0(BitState::High)
//! .starts_matching();
//! let data = scope.read(ProbeType::X1, Duration::from_millis(5), Some(digital_trigger.into()), None)?;
//!
//! // Read with unified trigger API - analog trigger using 10x probe
//! let analog_trigger = AnalogTrigger::start_capturing_when()
//! .rising_edge(2.0);
//! let data = scope.read(ProbeType::X10, Duration::from_millis(10), Some(analog_trigger.into()), Some(Duration::from_micros(500)))?;
//!
//! // You can also read without triggers (auto trigger)
//! let data = scope.read(ProbeType::X1, Duration::from_millis(5), None, None)?;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! ### Device Discovery
//!
//! ```rust,no_run
//! use fleascope_rs::FleaConnector;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Connect to any available FleaScope device
//! let terminal = FleaConnector::connect(None, None, true)?;
//!
//! // Or connect to a specific port
//! let terminal = FleaConnector::connect(None, Some("/dev/ttyUSB0"), true)?;
//!
//! // List available devices (iterator - memory efficient)
//! let devices = FleaConnector::get_available_devices(None)?;
//! for device in devices.take(3) { // Only process first 3 devices
//! println!("Found device: {} at {}", device.name, device.port);
//! }
//!
//! // Or get all devices as a Vec (if you need to access multiple times)
//! let devices_vec = FleaConnector::get_available_devices_vec(None)?;
//! println!("Total devices: {}", devices_vec.len());
//! # Ok(())
//! # }
//! ```
//! ```
// Re-export the main types for convenience
pub use ;
pub use ;
pub use ;
pub use ;