1use crate::{
15 byte_converter::*, converting_callback_receiver::ConvertingCallbackReceiver, converting_receiver::ConvertingReceiver, device::*,
16 ip_connection::GetRequestSender,
17};
18pub enum LaserRangeFinderV2BrickletFunction {
19 GetDistance,
20 SetDistanceCallbackConfiguration,
21 GetDistanceCallbackConfiguration,
22 GetVelocity,
23 SetVelocityCallbackConfiguration,
24 GetVelocityCallbackConfiguration,
25 SetEnable,
26 GetEnable,
27 SetConfiguration,
28 GetConfiguration,
29 SetMovingAverage,
30 GetMovingAverage,
31 SetOffsetCalibration,
32 GetOffsetCalibration,
33 SetDistanceLedConfig,
34 GetDistanceLedConfig,
35 GetSpitfpErrorCount,
36 SetBootloaderMode,
37 GetBootloaderMode,
38 SetWriteFirmwarePointer,
39 WriteFirmware,
40 SetStatusLedConfig,
41 GetStatusLedConfig,
42 GetChipTemperature,
43 Reset,
44 WriteUid,
45 ReadUid,
46 GetIdentity,
47 CallbackDistance,
48 CallbackVelocity,
49}
50impl From<LaserRangeFinderV2BrickletFunction> for u8 {
51 fn from(fun: LaserRangeFinderV2BrickletFunction) -> Self {
52 match fun {
53 LaserRangeFinderV2BrickletFunction::GetDistance => 1,
54 LaserRangeFinderV2BrickletFunction::SetDistanceCallbackConfiguration => 2,
55 LaserRangeFinderV2BrickletFunction::GetDistanceCallbackConfiguration => 3,
56 LaserRangeFinderV2BrickletFunction::GetVelocity => 5,
57 LaserRangeFinderV2BrickletFunction::SetVelocityCallbackConfiguration => 6,
58 LaserRangeFinderV2BrickletFunction::GetVelocityCallbackConfiguration => 7,
59 LaserRangeFinderV2BrickletFunction::SetEnable => 9,
60 LaserRangeFinderV2BrickletFunction::GetEnable => 10,
61 LaserRangeFinderV2BrickletFunction::SetConfiguration => 11,
62 LaserRangeFinderV2BrickletFunction::GetConfiguration => 12,
63 LaserRangeFinderV2BrickletFunction::SetMovingAverage => 13,
64 LaserRangeFinderV2BrickletFunction::GetMovingAverage => 14,
65 LaserRangeFinderV2BrickletFunction::SetOffsetCalibration => 15,
66 LaserRangeFinderV2BrickletFunction::GetOffsetCalibration => 16,
67 LaserRangeFinderV2BrickletFunction::SetDistanceLedConfig => 17,
68 LaserRangeFinderV2BrickletFunction::GetDistanceLedConfig => 18,
69 LaserRangeFinderV2BrickletFunction::GetSpitfpErrorCount => 234,
70 LaserRangeFinderV2BrickletFunction::SetBootloaderMode => 235,
71 LaserRangeFinderV2BrickletFunction::GetBootloaderMode => 236,
72 LaserRangeFinderV2BrickletFunction::SetWriteFirmwarePointer => 237,
73 LaserRangeFinderV2BrickletFunction::WriteFirmware => 238,
74 LaserRangeFinderV2BrickletFunction::SetStatusLedConfig => 239,
75 LaserRangeFinderV2BrickletFunction::GetStatusLedConfig => 240,
76 LaserRangeFinderV2BrickletFunction::GetChipTemperature => 242,
77 LaserRangeFinderV2BrickletFunction::Reset => 243,
78 LaserRangeFinderV2BrickletFunction::WriteUid => 248,
79 LaserRangeFinderV2BrickletFunction::ReadUid => 249,
80 LaserRangeFinderV2BrickletFunction::GetIdentity => 255,
81 LaserRangeFinderV2BrickletFunction::CallbackDistance => 4,
82 LaserRangeFinderV2BrickletFunction::CallbackVelocity => 8,
83 }
84 }
85}
86pub const LASER_RANGE_FINDER_V2_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
87pub const LASER_RANGE_FINDER_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
88pub const LASER_RANGE_FINDER_V2_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
89pub const LASER_RANGE_FINDER_V2_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
90pub const LASER_RANGE_FINDER_V2_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
91pub const LASER_RANGE_FINDER_V2_BRICKLET_DISTANCE_LED_CONFIG_OFF: u8 = 0;
92pub const LASER_RANGE_FINDER_V2_BRICKLET_DISTANCE_LED_CONFIG_ON: u8 = 1;
93pub const LASER_RANGE_FINDER_V2_BRICKLET_DISTANCE_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
94pub const LASER_RANGE_FINDER_V2_BRICKLET_DISTANCE_LED_CONFIG_SHOW_DISTANCE: u8 = 3;
95pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
96pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
97pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
98pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
99pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
100pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
101pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
102pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
103pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
104pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
105pub const LASER_RANGE_FINDER_V2_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
106pub const LASER_RANGE_FINDER_V2_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
107pub const LASER_RANGE_FINDER_V2_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
108pub const LASER_RANGE_FINDER_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
109pub const LASER_RANGE_FINDER_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
110
111#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
112pub struct DistanceCallbackConfiguration {
113 pub period: u32,
114 pub value_has_to_change: bool,
115 pub option: char,
116 pub min: i16,
117 pub max: i16,
118}
119impl FromByteSlice for DistanceCallbackConfiguration {
120 fn bytes_expected() -> usize { 10 }
121 fn from_le_byte_slice(bytes: &[u8]) -> DistanceCallbackConfiguration {
122 DistanceCallbackConfiguration {
123 period: <u32>::from_le_byte_slice(&bytes[0..4]),
124 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
125 option: <char>::from_le_byte_slice(&bytes[5..6]),
126 min: <i16>::from_le_byte_slice(&bytes[6..8]),
127 max: <i16>::from_le_byte_slice(&bytes[8..10]),
128 }
129 }
130}
131
132#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
133pub struct VelocityCallbackConfiguration {
134 pub period: u32,
135 pub value_has_to_change: bool,
136 pub option: char,
137 pub min: i16,
138 pub max: i16,
139}
140impl FromByteSlice for VelocityCallbackConfiguration {
141 fn bytes_expected() -> usize { 10 }
142 fn from_le_byte_slice(bytes: &[u8]) -> VelocityCallbackConfiguration {
143 VelocityCallbackConfiguration {
144 period: <u32>::from_le_byte_slice(&bytes[0..4]),
145 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
146 option: <char>::from_le_byte_slice(&bytes[5..6]),
147 min: <i16>::from_le_byte_slice(&bytes[6..8]),
148 max: <i16>::from_le_byte_slice(&bytes[8..10]),
149 }
150 }
151}
152
153#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
154pub struct Configuration {
155 pub acquisition_count: u8,
156 pub enable_quick_termination: bool,
157 pub threshold_value: u8,
158 pub measurement_frequency: u16,
159}
160impl FromByteSlice for Configuration {
161 fn bytes_expected() -> usize { 5 }
162 fn from_le_byte_slice(bytes: &[u8]) -> Configuration {
163 Configuration {
164 acquisition_count: <u8>::from_le_byte_slice(&bytes[0..1]),
165 enable_quick_termination: <bool>::from_le_byte_slice(&bytes[1..2]),
166 threshold_value: <u8>::from_le_byte_slice(&bytes[2..3]),
167 measurement_frequency: <u16>::from_le_byte_slice(&bytes[3..5]),
168 }
169 }
170}
171
172#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
173pub struct MovingAverage {
174 pub distance_average_length: u8,
175 pub velocity_average_length: u8,
176}
177impl FromByteSlice for MovingAverage {
178 fn bytes_expected() -> usize { 2 }
179 fn from_le_byte_slice(bytes: &[u8]) -> MovingAverage {
180 MovingAverage {
181 distance_average_length: <u8>::from_le_byte_slice(&bytes[0..1]),
182 velocity_average_length: <u8>::from_le_byte_slice(&bytes[1..2]),
183 }
184 }
185}
186
187#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
188pub struct SpitfpErrorCount {
189 pub error_count_ack_checksum: u32,
190 pub error_count_message_checksum: u32,
191 pub error_count_frame: u32,
192 pub error_count_overflow: u32,
193}
194impl FromByteSlice for SpitfpErrorCount {
195 fn bytes_expected() -> usize { 16 }
196 fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
197 SpitfpErrorCount {
198 error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
199 error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
200 error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
201 error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
202 }
203 }
204}
205
206#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
207pub struct Identity {
208 pub uid: String,
209 pub connected_uid: String,
210 pub position: char,
211 pub hardware_version: [u8; 3],
212 pub firmware_version: [u8; 3],
213 pub device_identifier: u16,
214}
215impl FromByteSlice for Identity {
216 fn bytes_expected() -> usize { 25 }
217 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
218 Identity {
219 uid: <String>::from_le_byte_slice(&bytes[0..8]),
220 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
221 position: <char>::from_le_byte_slice(&bytes[16..17]),
222 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
223 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
224 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
225 }
226 }
227}
228
229#[derive(Clone)]
231pub struct LaserRangeFinderV2Bricklet {
232 device: Device,
233}
234impl LaserRangeFinderV2Bricklet {
235 pub const DEVICE_IDENTIFIER: u16 = 2144;
236 pub const DEVICE_DISPLAY_NAME: &'static str = "Laser Range Finder Bricklet 2.0";
237 pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> LaserRangeFinderV2Bricklet {
239 let mut result = LaserRangeFinderV2Bricklet { device: Device::new([2, 0, 0], uid, req_sender, 0) };
240 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetDistance) as usize] =
241 ResponseExpectedFlag::AlwaysTrue;
242 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetDistanceCallbackConfiguration) as usize] =
243 ResponseExpectedFlag::True;
244 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetDistanceCallbackConfiguration) as usize] =
245 ResponseExpectedFlag::AlwaysTrue;
246 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetVelocity) as usize] =
247 ResponseExpectedFlag::AlwaysTrue;
248 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetVelocityCallbackConfiguration) as usize] =
249 ResponseExpectedFlag::True;
250 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetVelocityCallbackConfiguration) as usize] =
251 ResponseExpectedFlag::AlwaysTrue;
252 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetEnable) as usize] = ResponseExpectedFlag::False;
253 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetEnable) as usize] =
254 ResponseExpectedFlag::AlwaysTrue;
255 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetConfiguration) as usize] =
256 ResponseExpectedFlag::False;
257 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetConfiguration) as usize] =
258 ResponseExpectedFlag::AlwaysTrue;
259 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetMovingAverage) as usize] =
260 ResponseExpectedFlag::False;
261 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetMovingAverage) as usize] =
262 ResponseExpectedFlag::AlwaysTrue;
263 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetOffsetCalibration) as usize] =
264 ResponseExpectedFlag::False;
265 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetOffsetCalibration) as usize] =
266 ResponseExpectedFlag::AlwaysTrue;
267 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetDistanceLedConfig) as usize] =
268 ResponseExpectedFlag::False;
269 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetDistanceLedConfig) as usize] =
270 ResponseExpectedFlag::AlwaysTrue;
271 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetSpitfpErrorCount) as usize] =
272 ResponseExpectedFlag::AlwaysTrue;
273 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetBootloaderMode) as usize] =
274 ResponseExpectedFlag::AlwaysTrue;
275 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetBootloaderMode) as usize] =
276 ResponseExpectedFlag::AlwaysTrue;
277 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetWriteFirmwarePointer) as usize] =
278 ResponseExpectedFlag::False;
279 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::WriteFirmware) as usize] =
280 ResponseExpectedFlag::AlwaysTrue;
281 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::SetStatusLedConfig) as usize] =
282 ResponseExpectedFlag::False;
283 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetStatusLedConfig) as usize] =
284 ResponseExpectedFlag::AlwaysTrue;
285 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetChipTemperature) as usize] =
286 ResponseExpectedFlag::AlwaysTrue;
287 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
288 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
289 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
290 result.device.response_expected[u8::from(LaserRangeFinderV2BrickletFunction::GetIdentity) as usize] =
291 ResponseExpectedFlag::AlwaysTrue;
292 result
293 }
294
295 pub fn get_response_expected(&mut self, fun: LaserRangeFinderV2BrickletFunction) -> Result<bool, GetResponseExpectedError> {
310 self.device.get_response_expected(u8::from(fun))
311 }
312
313 pub fn set_response_expected(
322 &mut self,
323 fun: LaserRangeFinderV2BrickletFunction,
324 response_expected: bool,
325 ) -> Result<(), SetResponseExpectedError> {
326 self.device.set_response_expected(u8::from(fun), response_expected)
327 }
328
329 pub fn set_response_expected_all(&mut self, response_expected: bool) { self.device.set_response_expected_all(response_expected) }
331
332 pub fn get_api_version(&self) -> [u8; 3] { self.device.api_version }
335
336 pub fn get_distance_callback_receiver(&self) -> ConvertingCallbackReceiver<i16> {
344 self.device.get_callback_receiver(u8::from(LaserRangeFinderV2BrickletFunction::CallbackDistance))
345 }
346
347 pub fn get_velocity_callback_receiver(&self) -> ConvertingCallbackReceiver<i16> {
352 self.device.get_callback_receiver(u8::from(LaserRangeFinderV2BrickletFunction::CallbackVelocity))
353 }
354
355 pub fn get_distance(&self) -> ConvertingReceiver<i16> {
364 let payload = vec![0; 0];
365
366 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetDistance), payload)
367 }
368
369 pub fn set_distance_callback_configuration(
402 &self,
403 period: u32,
404 value_has_to_change: bool,
405 option: char,
406 min: i16,
407 max: i16,
408 ) -> ConvertingReceiver<()> {
409 let mut payload = vec![0; 10];
410 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
411 payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
412 payload[5..6].copy_from_slice(&<char>::to_le_byte_vec(option));
413 payload[6..8].copy_from_slice(&<i16>::to_le_byte_vec(min));
414 payload[8..10].copy_from_slice(&<i16>::to_le_byte_vec(max));
415
416 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::SetDistanceCallbackConfiguration), payload)
417 }
418
419 pub fn get_distance_callback_configuration(&self) -> ConvertingReceiver<DistanceCallbackConfiguration> {
428 let payload = vec![0; 0];
429
430 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetDistanceCallbackConfiguration), payload)
431 }
432
433 pub fn get_velocity(&self) -> ConvertingReceiver<i16> {
445 let payload = vec![0; 0];
446
447 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetVelocity), payload)
448 }
449
450 pub fn set_velocity_callback_configuration(
483 &self,
484 period: u32,
485 value_has_to_change: bool,
486 option: char,
487 min: i16,
488 max: i16,
489 ) -> ConvertingReceiver<()> {
490 let mut payload = vec![0; 10];
491 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
492 payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
493 payload[5..6].copy_from_slice(&<char>::to_le_byte_vec(option));
494 payload[6..8].copy_from_slice(&<i16>::to_le_byte_vec(min));
495 payload[8..10].copy_from_slice(&<i16>::to_le_byte_vec(max));
496
497 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::SetVelocityCallbackConfiguration), payload)
498 }
499
500 pub fn get_velocity_callback_configuration(&self) -> ConvertingReceiver<VelocityCallbackConfiguration> {
509 let payload = vec![0; 0];
510
511 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetVelocityCallbackConfiguration), payload)
512 }
513
514 pub fn set_enable(&self, enable: bool) -> ConvertingReceiver<()> {
519 let mut payload = vec![0; 1];
520 payload[0..1].copy_from_slice(&<bool>::to_le_byte_vec(enable));
521
522 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::SetEnable), payload)
523 }
524
525 pub fn get_enable(&self) -> ConvertingReceiver<bool> {
527 let payload = vec![0; 0];
528
529 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetEnable), payload)
530 }
531
532 pub fn set_configuration(
560 &self,
561 acquisition_count: u8,
562 enable_quick_termination: bool,
563 threshold_value: u8,
564 measurement_frequency: u16,
565 ) -> ConvertingReceiver<()> {
566 let mut payload = vec![0; 5];
567 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(acquisition_count));
568 payload[1..2].copy_from_slice(&<bool>::to_le_byte_vec(enable_quick_termination));
569 payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(threshold_value));
570 payload[3..5].copy_from_slice(&<u16>::to_le_byte_vec(measurement_frequency));
571
572 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::SetConfiguration), payload)
573 }
574
575 pub fn get_configuration(&self) -> ConvertingReceiver<Configuration> {
577 let payload = vec![0; 0];
578
579 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetConfiguration), payload)
580 }
581
582 pub fn set_moving_average(&self, distance_average_length: u8, velocity_average_length: u8) -> ConvertingReceiver<()> {
588 let mut payload = vec![0; 2];
589 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(distance_average_length));
590 payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(velocity_average_length));
591
592 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::SetMovingAverage), payload)
593 }
594
595 pub fn get_moving_average(&self) -> ConvertingReceiver<MovingAverage> {
597 let payload = vec![0; 0];
598
599 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetMovingAverage), payload)
600 }
601
602 pub fn set_offset_calibration(&self, offset: i16) -> ConvertingReceiver<()> {
612 let mut payload = vec![0; 2];
613 payload[0..2].copy_from_slice(&<i16>::to_le_byte_vec(offset));
614
615 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::SetOffsetCalibration), payload)
616 }
617
618 pub fn get_offset_calibration(&self) -> ConvertingReceiver<i16> {
620 let payload = vec![0; 0];
621
622 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetOffsetCalibration), payload)
623 }
624
625 pub fn set_distance_led_config(&self, config: u8) -> ConvertingReceiver<()> {
634 let mut payload = vec![0; 1];
635 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(config));
636
637 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::SetDistanceLedConfig), payload)
638 }
639
640 pub fn get_distance_led_config(&self) -> ConvertingReceiver<u8> {
648 let payload = vec![0; 0];
649
650 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetDistanceLedConfig), payload)
651 }
652
653 pub fn get_spitfp_error_count(&self) -> ConvertingReceiver<SpitfpErrorCount> {
665 let payload = vec![0; 0];
666
667 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetSpitfpErrorCount), payload)
668 }
669
670 pub fn set_bootloader_mode(&self, mode: u8) -> ConvertingReceiver<u8> {
693 let mut payload = vec![0; 1];
694 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(mode));
695
696 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::SetBootloaderMode), payload)
697 }
698
699 pub fn get_bootloader_mode(&self) -> ConvertingReceiver<u8> {
708 let payload = vec![0; 0];
709
710 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetBootloaderMode), payload)
711 }
712
713 pub fn set_write_firmware_pointer(&self, pointer: u32) -> ConvertingReceiver<()> {
720 let mut payload = vec![0; 4];
721 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(pointer));
722
723 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::SetWriteFirmwarePointer), payload)
724 }
725
726 pub fn write_firmware(&self, data: [u8; 64]) -> ConvertingReceiver<u8> {
735 let mut payload = vec![0; 64];
736 payload[0..64].copy_from_slice(&<[u8; 64]>::to_le_byte_vec(data));
737
738 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::WriteFirmware), payload)
739 }
740
741 pub fn set_status_led_config(&self, config: u8) -> ConvertingReceiver<()> {
755 let mut payload = vec![0; 1];
756 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(config));
757
758 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::SetStatusLedConfig), payload)
759 }
760
761 pub fn get_status_led_config(&self) -> ConvertingReceiver<u8> {
769 let payload = vec![0; 0];
770
771 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetStatusLedConfig), payload)
772 }
773
774 pub fn get_chip_temperature(&self) -> ConvertingReceiver<i16> {
781 let payload = vec![0; 0];
782
783 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetChipTemperature), payload)
784 }
785
786 pub fn reset(&self) -> ConvertingReceiver<()> {
793 let payload = vec![0; 0];
794
795 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::Reset), payload)
796 }
797
798 pub fn write_uid(&self, uid: u32) -> ConvertingReceiver<()> {
804 let mut payload = vec![0; 4];
805 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(uid));
806
807 self.device.set(u8::from(LaserRangeFinderV2BrickletFunction::WriteUid), payload)
808 }
809
810 pub fn read_uid(&self) -> ConvertingReceiver<u32> {
813 let payload = vec![0; 0];
814
815 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::ReadUid), payload)
816 }
817
818 pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
829 let payload = vec![0; 0];
830
831 self.device.get(u8::from(LaserRangeFinderV2BrickletFunction::GetIdentity), payload)
832 }
833}