nanonis_rs/client/piezo/types.rs
1// ==================== Piezo Types ====================
2
3/// On/Off toggle with no-change option for piezo settings.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
5pub enum PiezoToggle {
6 /// No change to current state
7 #[default]
8 NoChange = 0,
9 /// Turn on
10 On = 1,
11 /// Turn off
12 Off = 2,
13}
14
15impl From<PiezoToggle> for u32 {
16 fn from(val: PiezoToggle) -> Self {
17 val as u32
18 }
19}
20
21impl From<PiezoToggle> for u16 {
22 fn from(val: PiezoToggle) -> Self {
23 val as u16
24 }
25}
26
27/// XYZ tilt correction angles.
28#[derive(Debug, Clone, Copy, Default)]
29pub struct TiltCorrection {
30 /// Tilt angle in X direction (degrees)
31 pub tilt_x_deg: f32,
32 /// Tilt angle in Y direction (degrees)
33 pub tilt_y_deg: f32,
34}
35
36/// XYZ piezo range in meters.
37#[derive(Debug, Clone, Copy, Default)]
38pub struct PiezoRange {
39 /// Range in X direction (meters)
40 pub range_x_m: f32,
41 /// Range in Y direction (meters)
42 pub range_y_m: f32,
43 /// Range in Z direction (meters)
44 pub range_z_m: f32,
45}
46
47/// XYZ piezo sensitivity (m/V).
48#[derive(Debug, Clone, Copy, Default)]
49pub struct PiezoSensitivity {
50 /// Sensitivity in X direction (m/V)
51 pub sens_x_m_per_v: f32,
52 /// Sensitivity in Y direction (m/V)
53 pub sens_y_m_per_v: f32,
54 /// Sensitivity in Z direction (m/V)
55 pub sens_z_m_per_v: f32,
56}
57
58/// Drift compensation configuration.
59#[derive(Debug, Clone, Copy, Default)]
60pub struct DriftCompConfig {
61 /// Compensation toggle (no change/on/off)
62 pub enabled: PiezoToggle,
63 /// Linear speed in X direction (m/s)
64 pub vx_m_s: f32,
65 /// Linear speed in Y direction (m/s)
66 pub vy_m_s: f32,
67 /// Linear speed in Z direction (m/s)
68 pub vz_m_s: f32,
69 /// Saturation limit
70 pub saturation_limit: f32,
71}
72
73/// Drift compensation status and settings.
74#[derive(Debug, Clone, Copy, Default)]
75pub struct DriftCompStatus {
76 /// Whether compensation is currently enabled
77 pub enabled: bool,
78 /// Linear speed in X direction (m/s)
79 pub vx_m_s: f32,
80 /// Linear speed in Y direction (m/s)
81 pub vy_m_s: f32,
82 /// Linear speed in Z direction (m/s)
83 pub vz_m_s: f32,
84 /// X axis reached saturation limit
85 pub x_saturated: bool,
86 /// Y axis reached saturation limit
87 pub y_saturated: bool,
88 /// Z axis reached saturation limit
89 pub z_saturated: bool,
90 /// Saturation limit value
91 pub saturation_limit: f32,
92}
93
94/// HVA (High Voltage Amplifier) gain information.
95#[derive(Debug, Clone, Copy, Default)]
96pub struct HVAInfo {
97 /// AUX gain
98 pub gain_aux: f32,
99 /// X gain
100 pub gain_x: f32,
101 /// Y gain
102 pub gain_y: f32,
103 /// Z gain
104 pub gain_z: f32,
105 /// XY enabled
106 pub xy_enabled: bool,
107 /// Z enabled
108 pub z_enabled: bool,
109 /// AUX enabled
110 pub aux_enabled: bool,
111}
112
113/// HVA status LED indicators.
114#[derive(Debug, Clone, Copy, Default)]
115pub struct HVAStatusLED {
116 /// Overheated status
117 pub overheated: bool,
118 /// HV supply status
119 pub hv_supply: bool,
120 /// High temperature status
121 pub high_temperature: bool,
122 /// Output connector status
123 pub output_connector: bool,
124}
125
126/// XYZ voltage limits configuration.
127#[derive(Debug, Clone, Copy)]
128pub struct XYZLimits {
129 /// Limits enabled
130 pub enabled: bool,
131 /// X low voltage limit (V)
132 pub x_low_v: f32,
133 /// X high voltage limit (V)
134 pub x_high_v: f32,
135 /// Y low voltage limit (V)
136 pub y_low_v: f32,
137 /// Y high voltage limit (V)
138 pub y_high_v: f32,
139 /// Z low voltage limit (V)
140 pub z_low_v: f32,
141 /// Z high voltage limit (V)
142 pub z_high_v: f32,
143}
144
145impl Default for XYZLimits {
146 fn default() -> Self {
147 Self {
148 enabled: false,
149 x_low_v: -10.0,
150 x_high_v: 10.0,
151 y_low_v: -10.0,
152 y_high_v: 10.0,
153 z_low_v: -10.0,
154 z_high_v: 10.0,
155 }
156 }
157}
158
159/// Hysteresis compensation points for one axis.
160#[derive(Debug, Clone, Default)]
161pub struct HysteresisAxisPoints {
162 /// X coordinates of hysteresis points
163 pub x_points: Vec<f32>,
164 /// Y coordinates of hysteresis points
165 pub y_points: Vec<f32>,
166}
167
168/// Hysteresis compensation values for fast and slow axes.
169#[derive(Debug, Clone, Default)]
170pub struct HysteresisValues {
171 /// Fast axis hysteresis points
172 pub fast_axis: HysteresisAxisPoints,
173 /// Slow axis hysteresis points
174 pub slow_axis: HysteresisAxisPoints,
175}