tinkerforge_async/bindings/
lcd_128x64_bricklet.rs

1/* ***********************************************************
2 * This file was automatically generated on 2024-02-16.      *
3 *                                                           *
4 * Rust Bindings Version 2.0.20                              *
5 *                                                           *
6 * If you have a bugfix for this file and want to commit it, *
7 * please fix the bug in the generator. You can find a link  *
8 * to the generators git repository on tinkerforge.com       *
9 *************************************************************/
10
11//! 7.1cm (2.8") display with 128x64 pixel and touch screen.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/LCD128x64_Bricklet_Rust.html).
14#[allow(unused_imports)]
15use crate::{
16    base58::Uid,
17    byte_converter::*,
18    converting_receiver::{BrickletError, BrickletRecvTimeoutError},
19    device::*,
20    error::TinkerforgeError,
21    ip_connection::async_io::AsyncIpConnection,
22    low_level_traits::LowLevelRead,
23};
24#[allow(unused_imports)]
25use futures_core::Stream;
26#[allow(unused_imports)]
27use tokio_stream::StreamExt;
28pub enum Lcd128x64BrickletFunction {
29    WritePixelsLowLevel,
30    ReadPixelsLowLevel,
31    ClearDisplay,
32    SetDisplayConfiguration,
33    GetDisplayConfiguration,
34    WriteLine,
35    DrawBufferedFrame,
36    GetTouchPosition,
37    SetTouchPositionCallbackConfiguration,
38    GetTouchPositionCallbackConfiguration,
39    GetTouchGesture,
40    SetTouchGestureCallbackConfiguration,
41    GetTouchGestureCallbackConfiguration,
42    DrawLine,
43    DrawBox,
44    DrawText,
45    SetGuiButton,
46    GetGuiButton,
47    RemoveGuiButton,
48    SetGuiButtonPressedCallbackConfiguration,
49    GetGuiButtonPressedCallbackConfiguration,
50    GetGuiButtonPressed,
51    SetGuiSlider,
52    GetGuiSlider,
53    RemoveGuiSlider,
54    SetGuiSliderValueCallbackConfiguration,
55    GetGuiSliderValueCallbackConfiguration,
56    GetGuiSliderValue,
57    SetGuiTabConfiguration,
58    GetGuiTabConfiguration,
59    SetGuiTabText,
60    GetGuiTabText,
61    SetGuiTabIcon,
62    GetGuiTabIcon,
63    RemoveGuiTab,
64    SetGuiTabSelected,
65    SetGuiTabSelectedCallbackConfiguration,
66    GetGuiTabSelectedCallbackConfiguration,
67    GetGuiTabSelected,
68    SetGuiGraphConfiguration,
69    GetGuiGraphConfiguration,
70    SetGuiGraphDataLowLevel,
71    GetGuiGraphDataLowLevel,
72    RemoveGuiGraph,
73    RemoveAllGui,
74    SetTouchLedConfig,
75    GetTouchLedConfig,
76    GetSpitfpErrorCount,
77    SetBootloaderMode,
78    GetBootloaderMode,
79    SetWriteFirmwarePointer,
80    WriteFirmware,
81    SetStatusLedConfig,
82    GetStatusLedConfig,
83    GetChipTemperature,
84    Reset,
85    WriteUid,
86    ReadUid,
87    GetIdentity,
88    CallbackTouchPosition,
89    CallbackTouchGesture,
90    CallbackGuiButtonPressed,
91    CallbackGuiSliderValue,
92    CallbackGuiTabSelected,
93}
94impl From<Lcd128x64BrickletFunction> for u8 {
95    fn from(fun: Lcd128x64BrickletFunction) -> Self {
96        match fun {
97            Lcd128x64BrickletFunction::WritePixelsLowLevel => 1,
98            Lcd128x64BrickletFunction::ReadPixelsLowLevel => 2,
99            Lcd128x64BrickletFunction::ClearDisplay => 3,
100            Lcd128x64BrickletFunction::SetDisplayConfiguration => 4,
101            Lcd128x64BrickletFunction::GetDisplayConfiguration => 5,
102            Lcd128x64BrickletFunction::WriteLine => 6,
103            Lcd128x64BrickletFunction::DrawBufferedFrame => 7,
104            Lcd128x64BrickletFunction::GetTouchPosition => 8,
105            Lcd128x64BrickletFunction::SetTouchPositionCallbackConfiguration => 9,
106            Lcd128x64BrickletFunction::GetTouchPositionCallbackConfiguration => 10,
107            Lcd128x64BrickletFunction::GetTouchGesture => 12,
108            Lcd128x64BrickletFunction::SetTouchGestureCallbackConfiguration => 13,
109            Lcd128x64BrickletFunction::GetTouchGestureCallbackConfiguration => 14,
110            Lcd128x64BrickletFunction::DrawLine => 16,
111            Lcd128x64BrickletFunction::DrawBox => 17,
112            Lcd128x64BrickletFunction::DrawText => 18,
113            Lcd128x64BrickletFunction::SetGuiButton => 19,
114            Lcd128x64BrickletFunction::GetGuiButton => 20,
115            Lcd128x64BrickletFunction::RemoveGuiButton => 21,
116            Lcd128x64BrickletFunction::SetGuiButtonPressedCallbackConfiguration => 22,
117            Lcd128x64BrickletFunction::GetGuiButtonPressedCallbackConfiguration => 23,
118            Lcd128x64BrickletFunction::GetGuiButtonPressed => 24,
119            Lcd128x64BrickletFunction::SetGuiSlider => 26,
120            Lcd128x64BrickletFunction::GetGuiSlider => 27,
121            Lcd128x64BrickletFunction::RemoveGuiSlider => 28,
122            Lcd128x64BrickletFunction::SetGuiSliderValueCallbackConfiguration => 29,
123            Lcd128x64BrickletFunction::GetGuiSliderValueCallbackConfiguration => 30,
124            Lcd128x64BrickletFunction::GetGuiSliderValue => 31,
125            Lcd128x64BrickletFunction::SetGuiTabConfiguration => 33,
126            Lcd128x64BrickletFunction::GetGuiTabConfiguration => 34,
127            Lcd128x64BrickletFunction::SetGuiTabText => 35,
128            Lcd128x64BrickletFunction::GetGuiTabText => 36,
129            Lcd128x64BrickletFunction::SetGuiTabIcon => 37,
130            Lcd128x64BrickletFunction::GetGuiTabIcon => 38,
131            Lcd128x64BrickletFunction::RemoveGuiTab => 39,
132            Lcd128x64BrickletFunction::SetGuiTabSelected => 40,
133            Lcd128x64BrickletFunction::SetGuiTabSelectedCallbackConfiguration => 41,
134            Lcd128x64BrickletFunction::GetGuiTabSelectedCallbackConfiguration => 42,
135            Lcd128x64BrickletFunction::GetGuiTabSelected => 43,
136            Lcd128x64BrickletFunction::SetGuiGraphConfiguration => 45,
137            Lcd128x64BrickletFunction::GetGuiGraphConfiguration => 46,
138            Lcd128x64BrickletFunction::SetGuiGraphDataLowLevel => 47,
139            Lcd128x64BrickletFunction::GetGuiGraphDataLowLevel => 48,
140            Lcd128x64BrickletFunction::RemoveGuiGraph => 49,
141            Lcd128x64BrickletFunction::RemoveAllGui => 50,
142            Lcd128x64BrickletFunction::SetTouchLedConfig => 51,
143            Lcd128x64BrickletFunction::GetTouchLedConfig => 52,
144            Lcd128x64BrickletFunction::GetSpitfpErrorCount => 234,
145            Lcd128x64BrickletFunction::SetBootloaderMode => 235,
146            Lcd128x64BrickletFunction::GetBootloaderMode => 236,
147            Lcd128x64BrickletFunction::SetWriteFirmwarePointer => 237,
148            Lcd128x64BrickletFunction::WriteFirmware => 238,
149            Lcd128x64BrickletFunction::SetStatusLedConfig => 239,
150            Lcd128x64BrickletFunction::GetStatusLedConfig => 240,
151            Lcd128x64BrickletFunction::GetChipTemperature => 242,
152            Lcd128x64BrickletFunction::Reset => 243,
153            Lcd128x64BrickletFunction::WriteUid => 248,
154            Lcd128x64BrickletFunction::ReadUid => 249,
155            Lcd128x64BrickletFunction::GetIdentity => 255,
156            Lcd128x64BrickletFunction::CallbackTouchPosition => 11,
157            Lcd128x64BrickletFunction::CallbackTouchGesture => 15,
158            Lcd128x64BrickletFunction::CallbackGuiButtonPressed => 25,
159            Lcd128x64BrickletFunction::CallbackGuiSliderValue => 32,
160            Lcd128x64BrickletFunction::CallbackGuiTabSelected => 44,
161        }
162    }
163}
164pub const LCD_128X64_BRICKLET_GESTURE_LEFT_TO_RIGHT: u8 = 0;
165pub const LCD_128X64_BRICKLET_GESTURE_RIGHT_TO_LEFT: u8 = 1;
166pub const LCD_128X64_BRICKLET_GESTURE_TOP_TO_BOTTOM: u8 = 2;
167pub const LCD_128X64_BRICKLET_GESTURE_BOTTOM_TO_TOP: u8 = 3;
168pub const LCD_128X64_BRICKLET_COLOR_WHITE: bool = false;
169pub const LCD_128X64_BRICKLET_COLOR_BLACK: bool = true;
170pub const LCD_128X64_BRICKLET_FONT_6X8: u8 = 0;
171pub const LCD_128X64_BRICKLET_FONT_6X16: u8 = 1;
172pub const LCD_128X64_BRICKLET_FONT_6X24: u8 = 2;
173pub const LCD_128X64_BRICKLET_FONT_6X32: u8 = 3;
174pub const LCD_128X64_BRICKLET_FONT_12X16: u8 = 4;
175pub const LCD_128X64_BRICKLET_FONT_12X24: u8 = 5;
176pub const LCD_128X64_BRICKLET_FONT_12X32: u8 = 6;
177pub const LCD_128X64_BRICKLET_FONT_18X24: u8 = 7;
178pub const LCD_128X64_BRICKLET_FONT_18X32: u8 = 8;
179pub const LCD_128X64_BRICKLET_FONT_24X32: u8 = 9;
180pub const LCD_128X64_BRICKLET_DIRECTION_HORIZONTAL: u8 = 0;
181pub const LCD_128X64_BRICKLET_DIRECTION_VERTICAL: u8 = 1;
182pub const LCD_128X64_BRICKLET_CHANGE_TAB_ON_CLICK: u8 = 1;
183pub const LCD_128X64_BRICKLET_CHANGE_TAB_ON_SWIPE: u8 = 2;
184pub const LCD_128X64_BRICKLET_CHANGE_TAB_ON_CLICK_AND_SWIPE: u8 = 3;
185pub const LCD_128X64_BRICKLET_GRAPH_TYPE_DOT: u8 = 0;
186pub const LCD_128X64_BRICKLET_GRAPH_TYPE_LINE: u8 = 1;
187pub const LCD_128X64_BRICKLET_GRAPH_TYPE_BAR: u8 = 2;
188pub const LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_OFF: u8 = 0;
189pub const LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_ON: u8 = 1;
190pub const LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
191pub const LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_SHOW_TOUCH: u8 = 3;
192pub const LCD_128X64_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
193pub const LCD_128X64_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
194pub const LCD_128X64_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
195pub const LCD_128X64_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
196pub const LCD_128X64_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
197pub const LCD_128X64_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
198pub const LCD_128X64_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
199pub const LCD_128X64_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
200pub const LCD_128X64_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
201pub const LCD_128X64_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
202pub const LCD_128X64_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
203pub const LCD_128X64_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
204pub const LCD_128X64_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
205pub const LCD_128X64_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
206pub const LCD_128X64_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
207
208#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
209pub struct WritePixelsLowLevel {}
210impl FromByteSlice for WritePixelsLowLevel {
211    fn bytes_expected() -> usize {
212        0
213    }
214    fn from_le_byte_slice(_bytes: &[u8]) -> WritePixelsLowLevel {
215        WritePixelsLowLevel {}
216    }
217}
218
219#[derive(Clone, Copy)]
220pub struct ReadPixelsLowLevel {
221    pub pixels_length: u16,
222    pub pixels_chunk_offset: u16,
223    pub pixels_chunk_data: [bool; 480],
224}
225impl FromByteSlice for ReadPixelsLowLevel {
226    fn bytes_expected() -> usize {
227        64
228    }
229    fn from_le_byte_slice(bytes: &[u8]) -> ReadPixelsLowLevel {
230        ReadPixelsLowLevel {
231            pixels_length: <u16>::from_le_byte_slice(&bytes[0..2]),
232            pixels_chunk_offset: <u16>::from_le_byte_slice(&bytes[2..4]),
233            pixels_chunk_data: <[bool; 480]>::from_le_byte_slice(&bytes[4..64]),
234        }
235    }
236}
237impl LowLevelRead<bool, ReadPixelsResult> for ReadPixelsLowLevel {
238    fn ll_message_length(&self) -> usize {
239        self.pixels_length as usize
240    }
241
242    fn ll_message_chunk_offset(&self) -> usize {
243        self.pixels_chunk_offset as usize
244    }
245
246    fn ll_message_chunk_data(&self) -> &[bool] {
247        &self.pixels_chunk_data
248    }
249
250    fn get_result(&self) -> ReadPixelsResult {
251        ReadPixelsResult {}
252    }
253}
254
255#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
256pub struct DisplayConfiguration {
257    pub contrast: u8,
258    pub backlight: u8,
259    pub invert: bool,
260    pub automatic_draw: bool,
261}
262impl FromByteSlice for DisplayConfiguration {
263    fn bytes_expected() -> usize {
264        4
265    }
266    fn from_le_byte_slice(bytes: &[u8]) -> DisplayConfiguration {
267        DisplayConfiguration {
268            contrast: <u8>::from_le_byte_slice(&bytes[0..1]),
269            backlight: <u8>::from_le_byte_slice(&bytes[1..2]),
270            invert: <bool>::from_le_byte_slice(&bytes[2..3]),
271            automatic_draw: <bool>::from_le_byte_slice(&bytes[3..4]),
272        }
273    }
274}
275
276#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
277pub struct TouchPosition {
278    pub pressure: u16,
279    pub x: u16,
280    pub y: u16,
281    pub age: u32,
282}
283impl FromByteSlice for TouchPosition {
284    fn bytes_expected() -> usize {
285        10
286    }
287    fn from_le_byte_slice(bytes: &[u8]) -> TouchPosition {
288        TouchPosition {
289            pressure: <u16>::from_le_byte_slice(&bytes[0..2]),
290            x: <u16>::from_le_byte_slice(&bytes[2..4]),
291            y: <u16>::from_le_byte_slice(&bytes[4..6]),
292            age: <u32>::from_le_byte_slice(&bytes[6..10]),
293        }
294    }
295}
296
297#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
298pub struct TouchPositionCallbackConfiguration {
299    pub period: u32,
300    pub value_has_to_change: bool,
301}
302impl FromByteSlice for TouchPositionCallbackConfiguration {
303    fn bytes_expected() -> usize {
304        5
305    }
306    fn from_le_byte_slice(bytes: &[u8]) -> TouchPositionCallbackConfiguration {
307        TouchPositionCallbackConfiguration {
308            period: <u32>::from_le_byte_slice(&bytes[0..4]),
309            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
310        }
311    }
312}
313
314#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
315pub struct TouchPositionEvent {
316    pub pressure: u16,
317    pub x: u16,
318    pub y: u16,
319    pub age: u32,
320}
321impl FromByteSlice for TouchPositionEvent {
322    fn bytes_expected() -> usize {
323        10
324    }
325    fn from_le_byte_slice(bytes: &[u8]) -> TouchPositionEvent {
326        TouchPositionEvent {
327            pressure: <u16>::from_le_byte_slice(&bytes[0..2]),
328            x: <u16>::from_le_byte_slice(&bytes[2..4]),
329            y: <u16>::from_le_byte_slice(&bytes[4..6]),
330            age: <u32>::from_le_byte_slice(&bytes[6..10]),
331        }
332    }
333}
334
335#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
336pub struct TouchGesture {
337    pub gesture: u8,
338    pub duration: u32,
339    pub pressure_max: u16,
340    pub x_start: u16,
341    pub y_start: u16,
342    pub x_end: u16,
343    pub y_end: u16,
344    pub age: u32,
345}
346impl FromByteSlice for TouchGesture {
347    fn bytes_expected() -> usize {
348        19
349    }
350    fn from_le_byte_slice(bytes: &[u8]) -> TouchGesture {
351        TouchGesture {
352            gesture: <u8>::from_le_byte_slice(&bytes[0..1]),
353            duration: <u32>::from_le_byte_slice(&bytes[1..5]),
354            pressure_max: <u16>::from_le_byte_slice(&bytes[5..7]),
355            x_start: <u16>::from_le_byte_slice(&bytes[7..9]),
356            y_start: <u16>::from_le_byte_slice(&bytes[9..11]),
357            x_end: <u16>::from_le_byte_slice(&bytes[11..13]),
358            y_end: <u16>::from_le_byte_slice(&bytes[13..15]),
359            age: <u32>::from_le_byte_slice(&bytes[15..19]),
360        }
361    }
362}
363
364#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
365pub struct TouchGestureCallbackConfiguration {
366    pub period: u32,
367    pub value_has_to_change: bool,
368}
369impl FromByteSlice for TouchGestureCallbackConfiguration {
370    fn bytes_expected() -> usize {
371        5
372    }
373    fn from_le_byte_slice(bytes: &[u8]) -> TouchGestureCallbackConfiguration {
374        TouchGestureCallbackConfiguration {
375            period: <u32>::from_le_byte_slice(&bytes[0..4]),
376            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
377        }
378    }
379}
380
381#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
382pub struct TouchGestureEvent {
383    pub gesture: u8,
384    pub duration: u32,
385    pub pressure_max: u16,
386    pub x_start: u16,
387    pub y_start: u16,
388    pub x_end: u16,
389    pub y_end: u16,
390    pub age: u32,
391}
392impl FromByteSlice for TouchGestureEvent {
393    fn bytes_expected() -> usize {
394        19
395    }
396    fn from_le_byte_slice(bytes: &[u8]) -> TouchGestureEvent {
397        TouchGestureEvent {
398            gesture: <u8>::from_le_byte_slice(&bytes[0..1]),
399            duration: <u32>::from_le_byte_slice(&bytes[1..5]),
400            pressure_max: <u16>::from_le_byte_slice(&bytes[5..7]),
401            x_start: <u16>::from_le_byte_slice(&bytes[7..9]),
402            y_start: <u16>::from_le_byte_slice(&bytes[9..11]),
403            x_end: <u16>::from_le_byte_slice(&bytes[11..13]),
404            y_end: <u16>::from_le_byte_slice(&bytes[13..15]),
405            age: <u32>::from_le_byte_slice(&bytes[15..19]),
406        }
407    }
408}
409
410#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
411pub struct GuiButton {
412    pub active: bool,
413    pub position_x: u8,
414    pub position_y: u8,
415    pub width: u8,
416    pub height: u8,
417    pub text: String,
418}
419impl FromByteSlice for GuiButton {
420    fn bytes_expected() -> usize {
421        21
422    }
423    fn from_le_byte_slice(bytes: &[u8]) -> GuiButton {
424        GuiButton {
425            active: <bool>::from_le_byte_slice(&bytes[0..1]),
426            position_x: <u8>::from_le_byte_slice(&bytes[1..2]),
427            position_y: <u8>::from_le_byte_slice(&bytes[2..3]),
428            width: <u8>::from_le_byte_slice(&bytes[3..4]),
429            height: <u8>::from_le_byte_slice(&bytes[4..5]),
430            text: <String>::from_le_byte_slice(&bytes[5..21]),
431        }
432    }
433}
434
435#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
436pub struct GuiButtonPressedCallbackConfiguration {
437    pub period: u32,
438    pub value_has_to_change: bool,
439}
440impl FromByteSlice for GuiButtonPressedCallbackConfiguration {
441    fn bytes_expected() -> usize {
442        5
443    }
444    fn from_le_byte_slice(bytes: &[u8]) -> GuiButtonPressedCallbackConfiguration {
445        GuiButtonPressedCallbackConfiguration {
446            period: <u32>::from_le_byte_slice(&bytes[0..4]),
447            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
448        }
449    }
450}
451
452#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
453pub struct GuiButtonPressedEvent {
454    pub index: u8,
455    pub pressed: bool,
456}
457impl FromByteSlice for GuiButtonPressedEvent {
458    fn bytes_expected() -> usize {
459        2
460    }
461    fn from_le_byte_slice(bytes: &[u8]) -> GuiButtonPressedEvent {
462        GuiButtonPressedEvent { index: <u8>::from_le_byte_slice(&bytes[0..1]), pressed: <bool>::from_le_byte_slice(&bytes[1..2]) }
463    }
464}
465
466#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
467pub struct GuiSlider {
468    pub active: bool,
469    pub position_x: u8,
470    pub position_y: u8,
471    pub length: u8,
472    pub direction: u8,
473    pub value: u8,
474}
475impl FromByteSlice for GuiSlider {
476    fn bytes_expected() -> usize {
477        6
478    }
479    fn from_le_byte_slice(bytes: &[u8]) -> GuiSlider {
480        GuiSlider {
481            active: <bool>::from_le_byte_slice(&bytes[0..1]),
482            position_x: <u8>::from_le_byte_slice(&bytes[1..2]),
483            position_y: <u8>::from_le_byte_slice(&bytes[2..3]),
484            length: <u8>::from_le_byte_slice(&bytes[3..4]),
485            direction: <u8>::from_le_byte_slice(&bytes[4..5]),
486            value: <u8>::from_le_byte_slice(&bytes[5..6]),
487        }
488    }
489}
490
491#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
492pub struct GuiSliderValueCallbackConfiguration {
493    pub period: u32,
494    pub value_has_to_change: bool,
495}
496impl FromByteSlice for GuiSliderValueCallbackConfiguration {
497    fn bytes_expected() -> usize {
498        5
499    }
500    fn from_le_byte_slice(bytes: &[u8]) -> GuiSliderValueCallbackConfiguration {
501        GuiSliderValueCallbackConfiguration {
502            period: <u32>::from_le_byte_slice(&bytes[0..4]),
503            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
504        }
505    }
506}
507
508#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
509pub struct GuiSliderValueEvent {
510    pub index: u8,
511    pub value: u8,
512}
513impl FromByteSlice for GuiSliderValueEvent {
514    fn bytes_expected() -> usize {
515        2
516    }
517    fn from_le_byte_slice(bytes: &[u8]) -> GuiSliderValueEvent {
518        GuiSliderValueEvent { index: <u8>::from_le_byte_slice(&bytes[0..1]), value: <u8>::from_le_byte_slice(&bytes[1..2]) }
519    }
520}
521
522#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
523pub struct GuiTabConfiguration {
524    pub change_tab_config: u8,
525    pub clear_gui: bool,
526}
527impl FromByteSlice for GuiTabConfiguration {
528    fn bytes_expected() -> usize {
529        2
530    }
531    fn from_le_byte_slice(bytes: &[u8]) -> GuiTabConfiguration {
532        GuiTabConfiguration {
533            change_tab_config: <u8>::from_le_byte_slice(&bytes[0..1]),
534            clear_gui: <bool>::from_le_byte_slice(&bytes[1..2]),
535        }
536    }
537}
538
539#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
540pub struct GuiTabText {
541    pub active: bool,
542    pub text: String,
543}
544impl FromByteSlice for GuiTabText {
545    fn bytes_expected() -> usize {
546        6
547    }
548    fn from_le_byte_slice(bytes: &[u8]) -> GuiTabText {
549        GuiTabText { active: <bool>::from_le_byte_slice(&bytes[0..1]), text: <String>::from_le_byte_slice(&bytes[1..6]) }
550    }
551}
552
553#[derive(Clone, Copy)]
554pub struct GuiTabIcon {
555    pub active: bool,
556    pub icon: [bool; 168],
557}
558impl FromByteSlice for GuiTabIcon {
559    fn bytes_expected() -> usize {
560        22
561    }
562    fn from_le_byte_slice(bytes: &[u8]) -> GuiTabIcon {
563        GuiTabIcon { active: <bool>::from_le_byte_slice(&bytes[0..1]), icon: <[bool; 168]>::from_le_byte_slice(&bytes[1..22]) }
564    }
565}
566
567#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
568pub struct GuiTabSelectedCallbackConfiguration {
569    pub period: u32,
570    pub value_has_to_change: bool,
571}
572impl FromByteSlice for GuiTabSelectedCallbackConfiguration {
573    fn bytes_expected() -> usize {
574        5
575    }
576    fn from_le_byte_slice(bytes: &[u8]) -> GuiTabSelectedCallbackConfiguration {
577        GuiTabSelectedCallbackConfiguration {
578            period: <u32>::from_le_byte_slice(&bytes[0..4]),
579            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
580        }
581    }
582}
583
584#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
585pub struct GuiGraphConfiguration {
586    pub active: bool,
587    pub graph_type: u8,
588    pub position_x: u8,
589    pub position_y: u8,
590    pub width: u8,
591    pub height: u8,
592    pub text_x: String,
593    pub text_y: String,
594}
595impl FromByteSlice for GuiGraphConfiguration {
596    fn bytes_expected() -> usize {
597        14
598    }
599    fn from_le_byte_slice(bytes: &[u8]) -> GuiGraphConfiguration {
600        GuiGraphConfiguration {
601            active: <bool>::from_le_byte_slice(&bytes[0..1]),
602            graph_type: <u8>::from_le_byte_slice(&bytes[1..2]),
603            position_x: <u8>::from_le_byte_slice(&bytes[2..3]),
604            position_y: <u8>::from_le_byte_slice(&bytes[3..4]),
605            width: <u8>::from_le_byte_slice(&bytes[4..5]),
606            height: <u8>::from_le_byte_slice(&bytes[5..6]),
607            text_x: <String>::from_le_byte_slice(&bytes[6..10]),
608            text_y: <String>::from_le_byte_slice(&bytes[10..14]),
609        }
610    }
611}
612
613#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
614pub struct SetGuiGraphDataLowLevel {}
615impl FromByteSlice for SetGuiGraphDataLowLevel {
616    fn bytes_expected() -> usize {
617        0
618    }
619    fn from_le_byte_slice(_bytes: &[u8]) -> SetGuiGraphDataLowLevel {
620        SetGuiGraphDataLowLevel {}
621    }
622}
623
624#[derive(Clone, Copy)]
625pub struct GuiGraphDataLowLevel {
626    pub data_length: u16,
627    pub data_chunk_offset: u16,
628    pub data_chunk_data: [u8; 59],
629}
630impl FromByteSlice for GuiGraphDataLowLevel {
631    fn bytes_expected() -> usize {
632        63
633    }
634    fn from_le_byte_slice(bytes: &[u8]) -> GuiGraphDataLowLevel {
635        GuiGraphDataLowLevel {
636            data_length: <u16>::from_le_byte_slice(&bytes[0..2]),
637            data_chunk_offset: <u16>::from_le_byte_slice(&bytes[2..4]),
638            data_chunk_data: <[u8; 59]>::from_le_byte_slice(&bytes[4..63]),
639        }
640    }
641}
642impl LowLevelRead<u8, GuiGraphDataResult> for GuiGraphDataLowLevel {
643    fn ll_message_length(&self) -> usize {
644        self.data_length as usize
645    }
646
647    fn ll_message_chunk_offset(&self) -> usize {
648        self.data_chunk_offset as usize
649    }
650
651    fn ll_message_chunk_data(&self) -> &[u8] {
652        &self.data_chunk_data
653    }
654
655    fn get_result(&self) -> GuiGraphDataResult {
656        GuiGraphDataResult {}
657    }
658}
659
660#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
661pub struct SpitfpErrorCount {
662    pub error_count_ack_checksum: u32,
663    pub error_count_message_checksum: u32,
664    pub error_count_frame: u32,
665    pub error_count_overflow: u32,
666}
667impl FromByteSlice for SpitfpErrorCount {
668    fn bytes_expected() -> usize {
669        16
670    }
671    fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
672        SpitfpErrorCount {
673            error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
674            error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
675            error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
676            error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
677        }
678    }
679}
680
681#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
682pub struct Identity {
683    pub uid: String,
684    pub connected_uid: String,
685    pub position: char,
686    pub hardware_version: [u8; 3],
687    pub firmware_version: [u8; 3],
688    pub device_identifier: u16,
689}
690impl FromByteSlice for Identity {
691    fn bytes_expected() -> usize {
692        25
693    }
694    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
695        Identity {
696            uid: <String>::from_le_byte_slice(&bytes[0..8]),
697            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
698            position: <char>::from_le_byte_slice(&bytes[16..17]),
699            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
700            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
701            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
702        }
703    }
704}
705
706#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
707pub struct WritePixelsResult {}
708
709#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
710pub struct ReadPixelsResult {}
711
712#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
713pub struct SetGuiGraphDataResult {}
714
715#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
716pub struct GuiGraphDataResult {}
717
718/// 7.1cm (2.8") display with 128x64 pixel and touch screen
719#[derive(Clone)]
720pub struct Lcd128x64Bricklet {
721    device: Device,
722}
723impl Lcd128x64Bricklet {
724    pub const DEVICE_IDENTIFIER: u16 = 298;
725    pub const DEVICE_DISPLAY_NAME: &'static str = "LCD 128x64 Bricklet";
726    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
727    pub fn new(uid: Uid, connection: AsyncIpConnection) -> Lcd128x64Bricklet {
728        let mut result = Lcd128x64Bricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
729        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::WritePixelsLowLevel) as usize] = ResponseExpectedFlag::True;
730        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::ReadPixelsLowLevel) as usize] =
731            ResponseExpectedFlag::AlwaysTrue;
732        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::ClearDisplay) as usize] = ResponseExpectedFlag::False;
733        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetDisplayConfiguration) as usize] =
734            ResponseExpectedFlag::False;
735        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetDisplayConfiguration) as usize] =
736            ResponseExpectedFlag::AlwaysTrue;
737        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::WriteLine) as usize] = ResponseExpectedFlag::False;
738        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::DrawBufferedFrame) as usize] = ResponseExpectedFlag::False;
739        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetTouchPosition) as usize] = ResponseExpectedFlag::AlwaysTrue;
740        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetTouchPositionCallbackConfiguration) as usize] =
741            ResponseExpectedFlag::True;
742        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetTouchPositionCallbackConfiguration) as usize] =
743            ResponseExpectedFlag::AlwaysTrue;
744        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetTouchGesture) as usize] = ResponseExpectedFlag::AlwaysTrue;
745        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetTouchGestureCallbackConfiguration) as usize] =
746            ResponseExpectedFlag::True;
747        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetTouchGestureCallbackConfiguration) as usize] =
748            ResponseExpectedFlag::AlwaysTrue;
749        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::DrawLine) as usize] = ResponseExpectedFlag::False;
750        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::DrawBox) as usize] = ResponseExpectedFlag::False;
751        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::DrawText) as usize] = ResponseExpectedFlag::False;
752        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiButton) as usize] = ResponseExpectedFlag::False;
753        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiButton) as usize] = ResponseExpectedFlag::AlwaysTrue;
754        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::RemoveGuiButton) as usize] = ResponseExpectedFlag::False;
755        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiButtonPressedCallbackConfiguration) as usize] =
756            ResponseExpectedFlag::True;
757        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiButtonPressedCallbackConfiguration) as usize] =
758            ResponseExpectedFlag::AlwaysTrue;
759        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiButtonPressed) as usize] =
760            ResponseExpectedFlag::AlwaysTrue;
761        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiSlider) as usize] = ResponseExpectedFlag::False;
762        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiSlider) as usize] = ResponseExpectedFlag::AlwaysTrue;
763        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::RemoveGuiSlider) as usize] = ResponseExpectedFlag::False;
764        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiSliderValueCallbackConfiguration) as usize] =
765            ResponseExpectedFlag::True;
766        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiSliderValueCallbackConfiguration) as usize] =
767            ResponseExpectedFlag::AlwaysTrue;
768        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiSliderValue) as usize] = ResponseExpectedFlag::AlwaysTrue;
769        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiTabConfiguration) as usize] = ResponseExpectedFlag::False;
770        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiTabConfiguration) as usize] =
771            ResponseExpectedFlag::AlwaysTrue;
772        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiTabText) as usize] = ResponseExpectedFlag::False;
773        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiTabText) as usize] = ResponseExpectedFlag::AlwaysTrue;
774        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiTabIcon) as usize] = ResponseExpectedFlag::False;
775        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiTabIcon) as usize] = ResponseExpectedFlag::AlwaysTrue;
776        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::RemoveGuiTab) as usize] = ResponseExpectedFlag::False;
777        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiTabSelected) as usize] = ResponseExpectedFlag::False;
778        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiTabSelectedCallbackConfiguration) as usize] =
779            ResponseExpectedFlag::True;
780        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiTabSelectedCallbackConfiguration) as usize] =
781            ResponseExpectedFlag::AlwaysTrue;
782        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiTabSelected) as usize] = ResponseExpectedFlag::AlwaysTrue;
783        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiGraphConfiguration) as usize] =
784            ResponseExpectedFlag::False;
785        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiGraphConfiguration) as usize] =
786            ResponseExpectedFlag::AlwaysTrue;
787        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetGuiGraphDataLowLevel) as usize] = ResponseExpectedFlag::True;
788        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetGuiGraphDataLowLevel) as usize] =
789            ResponseExpectedFlag::AlwaysTrue;
790        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::RemoveGuiGraph) as usize] = ResponseExpectedFlag::False;
791        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::RemoveAllGui) as usize] = ResponseExpectedFlag::False;
792        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetTouchLedConfig) as usize] = ResponseExpectedFlag::False;
793        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetTouchLedConfig) as usize] = ResponseExpectedFlag::AlwaysTrue;
794        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetSpitfpErrorCount) as usize] =
795            ResponseExpectedFlag::AlwaysTrue;
796        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetBootloaderMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
797        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetBootloaderMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
798        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetWriteFirmwarePointer) as usize] =
799            ResponseExpectedFlag::False;
800        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::WriteFirmware) as usize] = ResponseExpectedFlag::AlwaysTrue;
801        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::SetStatusLedConfig) as usize] = ResponseExpectedFlag::False;
802        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetStatusLedConfig) as usize] =
803            ResponseExpectedFlag::AlwaysTrue;
804        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetChipTemperature) as usize] =
805            ResponseExpectedFlag::AlwaysTrue;
806        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
807        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
808        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
809        result.device.response_expected[u8::from(Lcd128x64BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
810        result
811    }
812
813    /// Returns the response expected flag for the function specified by the function ID parameter.
814    /// It is true if the function is expected to send a response, false otherwise.
815    ///
816    /// For getter functions this is enabled by default and cannot be disabled, because those
817    /// functions will always send a response. For callback configuration functions it is enabled
818    /// by default too, but can be disabled by [`set_response_expected`](crate::lcd_128x64_bricklet::Lcd128x64Bricklet::set_response_expected).
819    /// For setter functions it is disabled by default and can be enabled.
820    ///
821    /// Enabling the response expected flag for a setter function allows to detect timeouts
822    /// and other error conditions calls of this setter as well. The device will then send a response
823    /// for this purpose. If this flag is disabled for a setter function then no response is sent
824    /// and errors are silently ignored, because they cannot be detected.
825    ///
826    /// See [`set_response_expected`](crate::lcd_128x64_bricklet::Lcd128x64Bricklet::set_response_expected) for the list of function ID constants available for this function.
827    pub fn get_response_expected(&mut self, fun: Lcd128x64BrickletFunction) -> Result<bool, GetResponseExpectedError> {
828        self.device.get_response_expected(u8::from(fun))
829    }
830
831    /// Changes the response expected flag of the function specified by the function ID parameter.
832    /// This flag can only be changed for setter (default value: false) and callback configuration
833    /// functions (default value: true). For getter functions it is always enabled.
834    ///
835    /// Enabling the response expected flag for a setter function allows to detect timeouts and
836    /// other error conditions calls of this setter as well. The device will then send a response
837    /// for this purpose. If this flag is disabled for a setter function then no response is sent
838    /// and errors are silently ignored, because they cannot be detected.
839    pub fn set_response_expected(
840        &mut self,
841        fun: Lcd128x64BrickletFunction,
842        response_expected: bool,
843    ) -> Result<(), SetResponseExpectedError> {
844        self.device.set_response_expected(u8::from(fun), response_expected)
845    }
846
847    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
848    pub fn set_response_expected_all(&mut self, response_expected: bool) {
849        self.device.set_response_expected_all(response_expected)
850    }
851
852    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
853    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
854    pub fn get_api_version(&self) -> [u8; 3] {
855        self.device.api_version
856    }
857
858    /// This receiver is triggered periodically with the period that is set by
859    /// [`set_touch_position_callback_configuration`]. The parameters are the
860    /// same as for [`get_touch_position`].
861    ///
862    /// [`get_touch_position`]: #method.get_touch_position
863    /// [`set_touch_position_callback_configuration`]: #method.set_touch_position_callback_configuration
864    pub async fn get_touch_position_callback_receiver(&mut self) -> impl Stream<Item = TouchPositionEvent> {
865        self.device
866            .get_callback_receiver(u8::from(Lcd128x64BrickletFunction::CallbackTouchPosition))
867            .await
868            .map(|p| TouchPositionEvent::from_le_byte_slice(p.body()))
869    }
870
871    /// This receiver is triggered periodically with the period that is set by
872    /// [`set_touch_gesture_callback_configuration`]. The parameters are the
873    /// same as for [`get_touch_gesture`].
874    pub async fn get_touch_gesture_callback_receiver(&mut self) -> impl Stream<Item = TouchGestureEvent> {
875        self.device
876            .get_callback_receiver(u8::from(Lcd128x64BrickletFunction::CallbackTouchGesture))
877            .await
878            .map(|p| TouchGestureEvent::from_le_byte_slice(p.body()))
879    }
880
881    /// This receiver is triggered periodically with the period that is set by
882    /// [`set_gui_button_pressed_callback_configuration`]. The parameters are the
883    /// same as for [`get_gui_button_pressed`].
884    ///
885    ///
886    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
887    pub async fn get_gui_button_pressed_callback_receiver(&mut self) -> impl Stream<Item = GuiButtonPressedEvent> {
888        self.device
889            .get_callback_receiver(u8::from(Lcd128x64BrickletFunction::CallbackGuiButtonPressed))
890            .await
891            .map(|p| GuiButtonPressedEvent::from_le_byte_slice(p.body()))
892    }
893
894    /// This receiver is triggered periodically with the period that is set by
895    /// [`set_gui_slider_value_callback_configuration`]. The parameters are the
896    /// same as for [`get_gui_slider_value`].
897    ///
898    ///
899    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
900    pub async fn get_gui_slider_value_callback_receiver(&mut self) -> impl Stream<Item = GuiSliderValueEvent> {
901        self.device
902            .get_callback_receiver(u8::from(Lcd128x64BrickletFunction::CallbackGuiSliderValue))
903            .await
904            .map(|p| GuiSliderValueEvent::from_le_byte_slice(p.body()))
905    }
906
907    /// This receiver is triggered periodically with the period that is set by
908    /// [`set_gui_tab_selected_callback_configuration`]. The parameters are the
909    /// same as for [`get_gui_tab_selected`].
910    ///
911    ///
912    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
913    pub async fn get_gui_tab_selected_callback_receiver(&mut self) -> impl Stream<Item = i8> {
914        self.device
915            .get_callback_receiver(u8::from(Lcd128x64BrickletFunction::CallbackGuiTabSelected))
916            .await
917            .map(|p| i8::from_le_byte_slice(p.body()))
918    }
919
920    /// Writes pixels to the specified window.
921    ///
922    /// The pixels are written into the window line by line top to bottom
923    /// and each line is written from left to right.
924    ///
925    /// If automatic draw is enabled (default) the pixels are directly written to
926    /// the screen. Only pixels that have actually changed are updated on the screen,
927    /// the rest stays the same.
928    ///
929    /// If automatic draw is disabled the pixels are written to an internal buffer and
930    /// the buffer is transferred to the display only after [`draw_buffered_frame`]
931    /// is called. This can be used to avoid flicker when drawing a complex frame in
932    /// multiple steps.
933    ///
934    /// Automatic draw can be configured with the [`set_display_configuration`]
935    /// function.
936    pub async fn write_pixels_low_level(
937        &mut self,
938        x_start: u8,
939        y_start: u8,
940        x_end: u8,
941        y_end: u8,
942        pixels_length: u16,
943        pixels_chunk_offset: u16,
944        pixels_chunk_data: &[bool; 448],
945    ) -> Result<WritePixelsLowLevel, TinkerforgeError> {
946        let mut payload = [0; 64];
947        x_start.write_to_slice(&mut payload[0..1]);
948        y_start.write_to_slice(&mut payload[1..2]);
949        x_end.write_to_slice(&mut payload[2..3]);
950        y_end.write_to_slice(&mut payload[3..4]);
951        pixels_length.write_to_slice(&mut payload[4..6]);
952        pixels_chunk_offset.write_to_slice(&mut payload[6..8]);
953        pixels_chunk_data.write_to_slice(&mut payload[8..64]);
954
955        #[allow(unused_variables)]
956        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::WritePixelsLowLevel), &payload).await?.unwrap();
957        Ok(WritePixelsLowLevel::from_le_byte_slice(result.body()))
958    }
959
960    /// Reads pixels from the specified window.
961    ///
962    /// The pixels are read from the window line by line top to bottom
963    /// and each line is read from left to right.
964    ///
965    /// If automatic draw is enabled (default) the pixels that are read are always the
966    /// same that are shown on the display.
967    ///
968    /// If automatic draw is disabled the pixels are read from the internal buffer
969    /// (see [`draw_buffered_frame`]).
970    ///
971    /// Automatic draw can be configured with the [`set_display_configuration`]
972    /// function.
973    pub async fn read_pixels_low_level(
974        &mut self,
975        x_start: u8,
976        y_start: u8,
977        x_end: u8,
978        y_end: u8,
979    ) -> Result<ReadPixelsLowLevel, TinkerforgeError> {
980        let mut payload = [0; 4];
981        x_start.write_to_slice(&mut payload[0..1]);
982        y_start.write_to_slice(&mut payload[1..2]);
983        x_end.write_to_slice(&mut payload[2..3]);
984        y_end.write_to_slice(&mut payload[3..4]);
985
986        #[allow(unused_variables)]
987        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::ReadPixelsLowLevel), &payload).await?;
988        Ok(ReadPixelsLowLevel::from_le_byte_slice(result.body()))
989    }
990
991    /// Clears the complete content of the display.
992    ///
993    /// If automatic draw is enabled (default) the pixels are directly cleared.
994    ///
995    /// If automatic draw is disabled the the internal buffer is cleared and
996    /// the buffer is transferred to the display only after [`draw_buffered_frame`]
997    /// is called. This can be used to avoid flicker when drawing a complex frame in
998    /// multiple steps.
999    ///
1000    /// Automatic draw can be configured with the [`set_display_configuration`]
1001    /// function.
1002    pub async fn clear_display(&mut self) -> Result<(), TinkerforgeError> {
1003        let payload = [0; 0];
1004
1005        #[allow(unused_variables)]
1006        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::ClearDisplay), &payload).await?;
1007        Ok(())
1008    }
1009
1010    /// Sets the configuration of the display.
1011    ///
1012    /// If automatic draw is set to *true*, the display is automatically updated with every
1013    /// call of [`write_pixels`] and [`write_line`]. If it is set to false, the
1014    /// changes are written into an internal buffer and only shown on the display after
1015    /// a call of [`draw_buffered_frame`].
1016    pub async fn set_display_configuration(
1017        &mut self,
1018        contrast: u8,
1019        backlight: u8,
1020        invert: bool,
1021        automatic_draw: bool,
1022    ) -> Result<(), TinkerforgeError> {
1023        let mut payload = [0; 4];
1024        contrast.write_to_slice(&mut payload[0..1]);
1025        backlight.write_to_slice(&mut payload[1..2]);
1026        invert.write_to_slice(&mut payload[2..3]);
1027        automatic_draw.write_to_slice(&mut payload[3..4]);
1028
1029        #[allow(unused_variables)]
1030        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetDisplayConfiguration), &payload).await?;
1031        Ok(())
1032    }
1033
1034    /// Returns the configuration as set by [`set_display_configuration`].
1035    pub async fn get_display_configuration(&mut self) -> Result<DisplayConfiguration, TinkerforgeError> {
1036        let payload = [0; 0];
1037
1038        #[allow(unused_variables)]
1039        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetDisplayConfiguration), &payload).await?;
1040        Ok(DisplayConfiguration::from_le_byte_slice(result.body()))
1041    }
1042
1043    /// Writes text to a specific line with a specific position.
1044    ///
1045    /// For example: (1, 10, Hello) will write *Hello* in the middle of the
1046    /// second line of the display.
1047    ///
1048    /// The display uses a special 5x7 pixel charset. You can view the characters
1049    /// of the charset in Brick Viewer.
1050    ///
1051    /// If automatic draw is enabled (default) the text is directly written to
1052    /// the screen. Only pixels that have actually changed are updated on the screen,
1053    /// the rest stays the same.
1054    ///
1055    /// If automatic draw is disabled the text is written to an internal buffer and
1056    /// the buffer is transferred to the display only after [`draw_buffered_frame`]
1057    /// is called. This can be used to avoid flicker when drawing a complex frame in
1058    /// multiple steps.
1059    ///
1060    /// Automatic draw can be configured with the [`set_display_configuration`]
1061    /// function.
1062    ///
1063    /// This function is a 1:1 replacement for the function with the same name
1064    /// in the LCD 20x4 Bricklet. You can draw text at a specific pixel position
1065    /// and with different font sizes with the [`draw_text`] function.
1066    pub async fn write_line(&mut self, line: u8, position: u8, text: String) -> Result<(), TinkerforgeError> {
1067        let mut payload = [0; 24];
1068        line.write_to_slice(&mut payload[0..1]);
1069        position.write_to_slice(&mut payload[1..2]);
1070        text.try_write_to_slice(22, &mut payload)?;
1071
1072        #[allow(unused_variables)]
1073        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::WriteLine), &payload).await?;
1074        Ok(())
1075    }
1076
1077    /// Draws the currently buffered frame. Normally each call of [`write_pixels`] and
1078    /// [`write_line`] draws directly onto the display. If you turn automatic draw off
1079    /// ([`set_display_configuration`]), the data is written in an internal buffer and
1080    /// only transferred to the display by calling this function. This can be used to
1081    /// avoid flicker when drawing a complex frame in multiple steps.
1082    ///
1083    /// Set the `force complete redraw` to *true* to redraw the whole display
1084    /// instead of only the changed parts. Normally it should not be necessary to set this to
1085    /// *true*. It may only become necessary in case of stuck pixels because of errors.
1086    pub async fn draw_buffered_frame(&mut self, force_complete_redraw: bool) -> Result<(), TinkerforgeError> {
1087        let mut payload = [0; 1];
1088        force_complete_redraw.write_to_slice(&mut payload[0..1]);
1089
1090        #[allow(unused_variables)]
1091        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::DrawBufferedFrame), &payload).await?;
1092        Ok(())
1093    }
1094
1095    /// Returns the last valid touch position:
1096    ///
1097    /// * Pressure: Amount of pressure applied by the user
1098    /// * X: Touch position on x-axis
1099    /// * Y: Touch position on y-axis
1100    /// * Age: Age of touch press (how long ago it was)
1101    pub async fn get_touch_position(&mut self) -> Result<TouchPosition, TinkerforgeError> {
1102        let payload = [0; 0];
1103
1104        #[allow(unused_variables)]
1105        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetTouchPosition), &payload).await?;
1106        Ok(TouchPosition::from_le_byte_slice(result.body()))
1107    }
1108
1109    /// The period is the period with which the [`get_touch_position_callback_receiver`] receiver
1110    /// is triggered periodically. A value of 0 turns the receiver off.
1111    ///
1112    /// If the `value has to change`-parameter is set to true, the receiver is only
1113    /// triggered after the value has changed. If the value didn't change within the
1114    /// period, the receiver is triggered immediately on change.
1115    ///
1116    /// If it is set to false, the receiver is continuously triggered with the period,
1117    /// independent of the value.
1118    pub async fn set_touch_position_callback_configuration(
1119        &mut self,
1120        period: u32,
1121        value_has_to_change: bool,
1122    ) -> Result<(), TinkerforgeError> {
1123        let mut payload = [0; 5];
1124        period.write_to_slice(&mut payload[0..4]);
1125        value_has_to_change.write_to_slice(&mut payload[4..5]);
1126
1127        #[allow(unused_variables)]
1128        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetTouchPositionCallbackConfiguration), &payload).await?;
1129        Ok(())
1130    }
1131
1132    /// Returns the receiver configuration as set by
1133    /// [`set_touch_position_callback_configuration`].
1134    pub async fn get_touch_position_callback_configuration(&mut self) -> Result<TouchPositionCallbackConfiguration, TinkerforgeError> {
1135        let payload = [0; 0];
1136
1137        #[allow(unused_variables)]
1138        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetTouchPositionCallbackConfiguration), &payload).await?;
1139        Ok(TouchPositionCallbackConfiguration::from_le_byte_slice(result.body()))
1140    }
1141
1142    /// Returns one of four touch gestures that can be automatically detected by the Bricklet.
1143    ///
1144    /// The gestures are swipes from left to right, right to left, top to bottom and bottom to top.
1145    ///
1146    /// Additionally to the gestures a vector with a start and end position of the gesture is
1147    /// provided. You can use this vector do determine a more exact location of the gesture (e.g.
1148    /// the swipe from top to bottom was on the left or right part of the screen).
1149    ///
1150    /// The age parameter corresponds to the age of gesture (how long ago it was).
1151    ///
1152    /// Associated constants:
1153    /// * LCD_128X64_BRICKLET_GESTURE_LEFT_TO_RIGHT
1154    ///	* LCD_128X64_BRICKLET_GESTURE_RIGHT_TO_LEFT
1155    ///	* LCD_128X64_BRICKLET_GESTURE_TOP_TO_BOTTOM
1156    ///	* LCD_128X64_BRICKLET_GESTURE_BOTTOM_TO_TOP
1157    pub async fn get_touch_gesture(&mut self) -> Result<TouchGesture, TinkerforgeError> {
1158        let payload = [0; 0];
1159
1160        #[allow(unused_variables)]
1161        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetTouchGesture), &payload).await?;
1162        Ok(TouchGesture::from_le_byte_slice(result.body()))
1163    }
1164
1165    /// The period is the period with which the [`get_touch_gesture_callback_receiver`] receiver
1166    /// is triggered periodically. A value of 0 turns the receiver off.
1167    ///
1168    /// If the `value has to change`-parameter is set to true, the receiver is only
1169    /// triggered after the value has changed. If the value didn't change within the
1170    /// period, the receiver is triggered immediately on change.
1171    ///
1172    /// If it is set to false, the receiver is continuously triggered with the period,
1173    /// independent of the value.
1174    pub async fn set_touch_gesture_callback_configuration(
1175        &mut self,
1176        period: u32,
1177        value_has_to_change: bool,
1178    ) -> Result<(), TinkerforgeError> {
1179        let mut payload = [0; 5];
1180        period.write_to_slice(&mut payload[0..4]);
1181        value_has_to_change.write_to_slice(&mut payload[4..5]);
1182
1183        #[allow(unused_variables)]
1184        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetTouchGestureCallbackConfiguration), &payload).await?;
1185        Ok(())
1186    }
1187
1188    /// Returns the receiver configuration as set by
1189    /// [`set_touch_gesture_callback_configuration`].
1190    pub async fn get_touch_gesture_callback_configuration(&mut self) -> Result<TouchGestureCallbackConfiguration, TinkerforgeError> {
1191        let payload = [0; 0];
1192
1193        #[allow(unused_variables)]
1194        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetTouchGestureCallbackConfiguration), &payload).await?;
1195        Ok(TouchGestureCallbackConfiguration::from_le_byte_slice(result.body()))
1196    }
1197
1198    /// Draws a white or black line from (x, y)-start to (x, y)-end.
1199    ///
1200    ///
1201    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1202    ///
1203    /// Associated constants:
1204    /// * LCD_128X64_BRICKLET_COLOR_WHITE
1205    ///	* LCD_128X64_BRICKLET_COLOR_BLACK
1206    pub async fn draw_line(
1207        &mut self,
1208        position_x_start: u8,
1209        position_y_start: u8,
1210        position_x_end: u8,
1211        position_y_end: u8,
1212        color: bool,
1213    ) -> Result<(), TinkerforgeError> {
1214        let mut payload = [0; 5];
1215        position_x_start.write_to_slice(&mut payload[0..1]);
1216        position_y_start.write_to_slice(&mut payload[1..2]);
1217        position_x_end.write_to_slice(&mut payload[2..3]);
1218        position_y_end.write_to_slice(&mut payload[3..4]);
1219        color.write_to_slice(&mut payload[4..5]);
1220
1221        #[allow(unused_variables)]
1222        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::DrawLine), &payload).await?;
1223        Ok(())
1224    }
1225
1226    /// Draws a white or black box from (x, y)-start to (x, y)-end.
1227    ///
1228    /// If you set fill to true, the box will be filled with the
1229    /// color. Otherwise only the outline will be drawn.
1230    ///
1231    ///
1232    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1233    ///
1234    /// Associated constants:
1235    /// * LCD_128X64_BRICKLET_COLOR_WHITE
1236    ///	* LCD_128X64_BRICKLET_COLOR_BLACK
1237    pub async fn draw_box(
1238        &mut self,
1239        position_x_start: u8,
1240        position_y_start: u8,
1241        position_x_end: u8,
1242        position_y_end: u8,
1243        fill: bool,
1244        color: bool,
1245    ) -> Result<(), TinkerforgeError> {
1246        let mut payload = [0; 6];
1247        position_x_start.write_to_slice(&mut payload[0..1]);
1248        position_y_start.write_to_slice(&mut payload[1..2]);
1249        position_x_end.write_to_slice(&mut payload[2..3]);
1250        position_y_end.write_to_slice(&mut payload[3..4]);
1251        fill.write_to_slice(&mut payload[4..5]);
1252        color.write_to_slice(&mut payload[5..6]);
1253
1254        #[allow(unused_variables)]
1255        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::DrawBox), &payload).await?;
1256        Ok(())
1257    }
1258
1259    /// Draws a text at the pixel position (x, y).
1260    ///
1261    /// You can use one of 9 different font sizes and draw the text in white or black.
1262    ///
1263    /// The font conforms to code page 437.
1264    ///
1265    ///
1266    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1267    ///
1268    /// Associated constants:
1269    /// * LCD_128X64_BRICKLET_FONT_6X8
1270    ///	* LCD_128X64_BRICKLET_FONT_6X16
1271    ///	* LCD_128X64_BRICKLET_FONT_6X24
1272    ///	* LCD_128X64_BRICKLET_FONT_6X32
1273    ///	* LCD_128X64_BRICKLET_FONT_12X16
1274    ///	* LCD_128X64_BRICKLET_FONT_12X24
1275    ///	* LCD_128X64_BRICKLET_FONT_12X32
1276    ///	* LCD_128X64_BRICKLET_FONT_18X24
1277    ///	* LCD_128X64_BRICKLET_FONT_18X32
1278    ///	* LCD_128X64_BRICKLET_FONT_24X32
1279    ///	* LCD_128X64_BRICKLET_COLOR_WHITE
1280    ///	* LCD_128X64_BRICKLET_COLOR_BLACK
1281    pub async fn draw_text(&mut self, position_x: u8, position_y: u8, font: u8, color: bool, text: String) -> Result<(), TinkerforgeError> {
1282        let mut payload = [0; 26];
1283        position_x.write_to_slice(&mut payload[0..1]);
1284        position_y.write_to_slice(&mut payload[1..2]);
1285        font.write_to_slice(&mut payload[2..3]);
1286        color.write_to_slice(&mut payload[3..4]);
1287        text.try_write_to_slice(22, &mut payload)?;
1288
1289        #[allow(unused_variables)]
1290        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::DrawText), &payload).await?;
1291        Ok(())
1292    }
1293
1294    /// Draws a clickable button at position (x, y) with the given text.
1295    ///
1296    /// You can use up to 12 buttons.
1297    ///
1298    /// The x position + width has to be within the range of 1 to 128 and the y
1299    /// position + height has to be within the range of 1 to 64.
1300    ///
1301    /// The minimum useful width/height of a button is 3.
1302    ///
1303    /// You can enable a receiver for a button press with
1304    /// [`set_gui_button_pressed_callback_configuration`]. The receiver will
1305    /// be triggered for press and release-events.
1306    ///
1307    /// The button is drawn in a separate GUI buffer and the button-frame will
1308    /// always stay on top of the graphics drawn with [`write_pixels`]. To
1309    /// remove the button use [`remove_gui_button`].
1310    ///
1311    /// If you want an icon instead of text, you can draw the icon inside of the
1312    /// button with [`write_pixels`].
1313    ///
1314    ///
1315    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1316    pub async fn set_gui_button(
1317        &mut self,
1318        index: u8,
1319        position_x: u8,
1320        position_y: u8,
1321        width: u8,
1322        height: u8,
1323        text: String,
1324    ) -> Result<(), TinkerforgeError> {
1325        let mut payload = [0; 21];
1326        index.write_to_slice(&mut payload[0..1]);
1327        position_x.write_to_slice(&mut payload[1..2]);
1328        position_y.write_to_slice(&mut payload[2..3]);
1329        width.write_to_slice(&mut payload[3..4]);
1330        height.write_to_slice(&mut payload[4..5]);
1331        text.try_write_to_slice(16, &mut payload)?;
1332
1333        #[allow(unused_variables)]
1334        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiButton), &payload).await?;
1335        Ok(())
1336    }
1337
1338    /// Returns the button properties for a given `Index` as set by [`set_gui_button`].
1339    ///
1340    /// Additionally the `Active` parameter shows if a button is currently active/visible
1341    /// or not.
1342    ///
1343    ///
1344    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1345    pub async fn get_gui_button(&mut self, index: u8) -> Result<GuiButton, TinkerforgeError> {
1346        let mut payload = [0; 1];
1347        index.write_to_slice(&mut payload[0..1]);
1348
1349        #[allow(unused_variables)]
1350        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiButton), &payload).await?;
1351        Ok(GuiButton::from_le_byte_slice(result.body()))
1352    }
1353
1354    /// Removes the button with the given index.
1355    ///
1356    /// You can use index 255 to remove all buttons.
1357    ///
1358    ///
1359    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1360    pub async fn remove_gui_button(&mut self, index: u8) -> Result<(), TinkerforgeError> {
1361        let mut payload = [0; 1];
1362        index.write_to_slice(&mut payload[0..1]);
1363
1364        #[allow(unused_variables)]
1365        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::RemoveGuiButton), &payload).await?;
1366        Ok(())
1367    }
1368
1369    /// The period is the period with which the [`get_gui_button_pressed_callback_receiver`] receiver
1370    /// is triggered periodically. A value of 0 turns the receiver off.
1371    ///
1372    /// If the `value has to change`-parameter is set to true, the receiver is only
1373    /// triggered after the value has changed. If the value didn't change within the
1374    /// period, the receiver is triggered immediately on change.
1375    ///
1376    /// If it is set to false, the receiver is continuously triggered with the period,
1377    /// independent of the value.
1378    ///
1379    ///
1380    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1381    pub async fn set_gui_button_pressed_callback_configuration(
1382        &mut self,
1383        period: u32,
1384        value_has_to_change: bool,
1385    ) -> Result<(), TinkerforgeError> {
1386        let mut payload = [0; 5];
1387        period.write_to_slice(&mut payload[0..4]);
1388        value_has_to_change.write_to_slice(&mut payload[4..5]);
1389
1390        #[allow(unused_variables)]
1391        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiButtonPressedCallbackConfiguration), &payload).await?;
1392        Ok(())
1393    }
1394
1395    /// Returns the receiver configuration as set by
1396    /// [`set_gui_button_pressed_callback_configuration`].
1397    ///
1398    ///
1399    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1400    pub async fn get_gui_button_pressed_callback_configuration(
1401        &mut self,
1402    ) -> Result<GuiButtonPressedCallbackConfiguration, TinkerforgeError> {
1403        let payload = [0; 0];
1404
1405        #[allow(unused_variables)]
1406        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiButtonPressedCallbackConfiguration), &payload).await?;
1407        Ok(GuiButtonPressedCallbackConfiguration::from_le_byte_slice(result.body()))
1408    }
1409
1410    /// Returns the state of the button for the given index.
1411    ///
1412    /// The state can either be pressed (true) or released (false).
1413    ///
1414    ///
1415    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1416    pub async fn get_gui_button_pressed(&mut self, index: u8) -> Result<bool, TinkerforgeError> {
1417        let mut payload = [0; 1];
1418        index.write_to_slice(&mut payload[0..1]);
1419
1420        #[allow(unused_variables)]
1421        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiButtonPressed), &payload).await?;
1422        Ok(bool::from_le_byte_slice(result.body()))
1423    }
1424
1425    /// Draws a slider at position (x, y) with the given length.
1426    ///
1427    /// You can use up to 6 sliders.
1428    ///
1429    /// If you use the horizontal direction, the x position + length has to be
1430    /// within the range of 1 to 128 and the y position has to be within
1431    /// the range of 0 to 46.
1432    ///
1433    /// If you use the vertical direction, the y position + length has to be
1434    /// within the range of 1 to 64 and the x position has to be within
1435    /// the range of 0 to 110.
1436    ///
1437    /// The minimum length of a slider is 8.
1438    ///
1439    /// The parameter value is the start-position of the slider, it can
1440    /// be between 0 and length-8.
1441    ///
1442    /// You can enable a receiver for the slider value with
1443    /// [`set_gui_slider_value_callback_configuration`].
1444    ///
1445    /// The slider is drawn in a separate GUI buffer and it will
1446    /// always stay on top of the graphics drawn with [`write_pixels`]. To
1447    /// remove the button use [`remove_gui_slider`].
1448    ///
1449    ///
1450    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1451    ///
1452    /// Associated constants:
1453    /// * LCD_128X64_BRICKLET_DIRECTION_HORIZONTAL
1454    ///	* LCD_128X64_BRICKLET_DIRECTION_VERTICAL
1455    pub async fn set_gui_slider(
1456        &mut self,
1457        index: u8,
1458        position_x: u8,
1459        position_y: u8,
1460        length: u8,
1461        direction: u8,
1462        value: u8,
1463    ) -> Result<(), TinkerforgeError> {
1464        let mut payload = [0; 6];
1465        index.write_to_slice(&mut payload[0..1]);
1466        position_x.write_to_slice(&mut payload[1..2]);
1467        position_y.write_to_slice(&mut payload[2..3]);
1468        length.write_to_slice(&mut payload[3..4]);
1469        direction.write_to_slice(&mut payload[4..5]);
1470        value.write_to_slice(&mut payload[5..6]);
1471
1472        #[allow(unused_variables)]
1473        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiSlider), &payload).await?;
1474        Ok(())
1475    }
1476
1477    /// Returns the slider properties for a given `Index` as set by [`set_gui_slider`].
1478    ///
1479    /// Additionally the `Active` parameter shows if a button is currently active/visible
1480    /// or not.
1481    ///
1482    ///
1483    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1484    ///
1485    /// Associated constants:
1486    /// * LCD_128X64_BRICKLET_DIRECTION_HORIZONTAL
1487    ///	* LCD_128X64_BRICKLET_DIRECTION_VERTICAL
1488    pub async fn get_gui_slider(&mut self, index: u8) -> Result<GuiSlider, TinkerforgeError> {
1489        let mut payload = [0; 1];
1490        index.write_to_slice(&mut payload[0..1]);
1491
1492        #[allow(unused_variables)]
1493        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiSlider), &payload).await?;
1494        Ok(GuiSlider::from_le_byte_slice(result.body()))
1495    }
1496
1497    /// Removes the slider with the given index.
1498    ///
1499    /// You can use index 255 to remove all slider.
1500    ///
1501    ///
1502    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1503    pub async fn remove_gui_slider(&mut self, index: u8) -> Result<(), TinkerforgeError> {
1504        let mut payload = [0; 1];
1505        index.write_to_slice(&mut payload[0..1]);
1506
1507        #[allow(unused_variables)]
1508        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::RemoveGuiSlider), &payload).await?;
1509        Ok(())
1510    }
1511
1512    /// The period is the period with which the [`get_gui_slider_value_callback_receiver`] receiver
1513    /// is triggered periodically. A value of 0 turns the receiver off.
1514    ///
1515    /// If the `value has to change`-parameter is set to true, the receiver is only
1516    /// triggered after the value has changed. If the value didn't change within the
1517    /// period, the receiver is triggered immediately on change.
1518    ///
1519    /// If it is set to false, the receiver is continuously triggered with the period,
1520    /// independent of the value.
1521    ///
1522    ///
1523    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1524    pub async fn set_gui_slider_value_callback_configuration(
1525        &mut self,
1526        period: u32,
1527        value_has_to_change: bool,
1528    ) -> Result<(), TinkerforgeError> {
1529        let mut payload = [0; 5];
1530        period.write_to_slice(&mut payload[0..4]);
1531        value_has_to_change.write_to_slice(&mut payload[4..5]);
1532
1533        #[allow(unused_variables)]
1534        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiSliderValueCallbackConfiguration), &payload).await?;
1535        Ok(())
1536    }
1537
1538    /// Returns the receiver configuration as set by
1539    /// [`set_gui_slider_value_callback_configuration`].
1540    ///
1541    ///
1542    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1543    pub async fn get_gui_slider_value_callback_configuration(&mut self) -> Result<GuiSliderValueCallbackConfiguration, TinkerforgeError> {
1544        let payload = [0; 0];
1545
1546        #[allow(unused_variables)]
1547        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiSliderValueCallbackConfiguration), &payload).await?;
1548        Ok(GuiSliderValueCallbackConfiguration::from_le_byte_slice(result.body()))
1549    }
1550
1551    /// Returns the current slider value for the given index.
1552    ///
1553    ///
1554    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1555    pub async fn get_gui_slider_value(&mut self, index: u8) -> Result<u8, TinkerforgeError> {
1556        let mut payload = [0; 1];
1557        index.write_to_slice(&mut payload[0..1]);
1558
1559        #[allow(unused_variables)]
1560        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiSliderValue), &payload).await?;
1561        Ok(u8::from_le_byte_slice(result.body()))
1562    }
1563
1564    /// Sets the general configuration for tabs. You can configure the tabs to only
1565    /// accept clicks or only swipes (gesture left/right and right/left) or both.
1566    ///
1567    /// Additionally, if you set `Clear GUI` to true, all of the GUI elements (buttons,
1568    /// slider, graphs) will automatically be removed on every tab change.
1569    ///
1570    ///
1571    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1572    ///
1573    /// Associated constants:
1574    /// * LCD_128X64_BRICKLET_CHANGE_TAB_ON_CLICK
1575    ///	* LCD_128X64_BRICKLET_CHANGE_TAB_ON_SWIPE
1576    ///	* LCD_128X64_BRICKLET_CHANGE_TAB_ON_CLICK_AND_SWIPE
1577    pub async fn set_gui_tab_configuration(&mut self, change_tab_config: u8, clear_gui: bool) -> Result<(), TinkerforgeError> {
1578        let mut payload = [0; 2];
1579        change_tab_config.write_to_slice(&mut payload[0..1]);
1580        clear_gui.write_to_slice(&mut payload[1..2]);
1581
1582        #[allow(unused_variables)]
1583        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiTabConfiguration), &payload).await?;
1584        Ok(())
1585    }
1586
1587    /// Returns the tab configuration as set by [`set_gui_tab_configuration`].
1588    ///
1589    ///
1590    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1591    ///
1592    /// Associated constants:
1593    /// * LCD_128X64_BRICKLET_CHANGE_TAB_ON_CLICK
1594    ///	* LCD_128X64_BRICKLET_CHANGE_TAB_ON_SWIPE
1595    ///	* LCD_128X64_BRICKLET_CHANGE_TAB_ON_CLICK_AND_SWIPE
1596    pub async fn get_gui_tab_configuration(&mut self) -> Result<GuiTabConfiguration, TinkerforgeError> {
1597        let payload = [0; 0];
1598
1599        #[allow(unused_variables)]
1600        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiTabConfiguration), &payload).await?;
1601        Ok(GuiTabConfiguration::from_le_byte_slice(result.body()))
1602    }
1603
1604    /// Adds a text-tab with the given index.
1605    ///
1606    /// You can use up to 10 tabs.
1607    ///
1608    /// A text-tab with the same index as a icon-tab will overwrite the icon-tab.
1609    ///
1610    ///
1611    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1612    pub async fn set_gui_tab_text(&mut self, index: u8, text: String) -> Result<(), TinkerforgeError> {
1613        let mut payload = [0; 6];
1614        index.write_to_slice(&mut payload[0..1]);
1615        text.try_write_to_slice(5, &mut payload)?;
1616
1617        #[allow(unused_variables)]
1618        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiTabText), &payload).await?;
1619        Ok(())
1620    }
1621
1622    /// Returns the text for a given index as set by [`set_gui_tab_text`].
1623    ///
1624    /// Additionally the `Active` parameter shows if the tab is currently active/visible
1625    /// or not.
1626    ///
1627    ///
1628    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1629    pub async fn get_gui_tab_text(&mut self, index: u8) -> Result<GuiTabText, TinkerforgeError> {
1630        let mut payload = [0; 1];
1631        index.write_to_slice(&mut payload[0..1]);
1632
1633        #[allow(unused_variables)]
1634        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiTabText), &payload).await?;
1635        Ok(GuiTabText::from_le_byte_slice(result.body()))
1636    }
1637
1638    /// Adds a icon-tab with the given index. The icon can have a width of 28 pixels
1639    /// with a height of 6 pixels. It is drawn line-by-line from left to right.
1640    ///
1641    /// You can use up to 10 tabs.
1642    ///
1643    /// A icon-tab with the same index as a text-tab will overwrite the text-tab.
1644    ///
1645    ///
1646    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1647    pub async fn set_gui_tab_icon(&mut self, index: u8, icon: &[bool; 168]) -> Result<(), TinkerforgeError> {
1648        let mut payload = [0; 22];
1649        index.write_to_slice(&mut payload[0..1]);
1650        icon.write_to_slice(&mut payload[1..22]);
1651
1652        #[allow(unused_variables)]
1653        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiTabIcon), &payload).await?;
1654        Ok(())
1655    }
1656
1657    /// Returns the icon for a given index as set by [`set_gui_tab_icon`].
1658    ///
1659    /// Additionally the `Active` parameter shows if the tab is currently active/visible
1660    /// or not.
1661    ///
1662    ///
1663    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1664    pub async fn get_gui_tab_icon(&mut self, index: u8) -> Result<GuiTabIcon, TinkerforgeError> {
1665        let mut payload = [0; 1];
1666        index.write_to_slice(&mut payload[0..1]);
1667
1668        #[allow(unused_variables)]
1669        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiTabIcon), &payload).await?;
1670        Ok(GuiTabIcon::from_le_byte_slice(result.body()))
1671    }
1672
1673    /// Removes the tab with the given index.
1674    ///
1675    /// You can use index 255 to remove all tabs.
1676    ///
1677    ///
1678    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1679    pub async fn remove_gui_tab(&mut self, index: u8) -> Result<(), TinkerforgeError> {
1680        let mut payload = [0; 1];
1681        index.write_to_slice(&mut payload[0..1]);
1682
1683        #[allow(unused_variables)]
1684        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::RemoveGuiTab), &payload).await?;
1685        Ok(())
1686    }
1687
1688    /// Sets the tab with the given index as selected (drawn as selected on the display).
1689    ///
1690    ///
1691    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1692    pub async fn set_gui_tab_selected(&mut self, index: u8) -> Result<(), TinkerforgeError> {
1693        let mut payload = [0; 1];
1694        index.write_to_slice(&mut payload[0..1]);
1695
1696        #[allow(unused_variables)]
1697        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiTabSelected), &payload).await?;
1698        Ok(())
1699    }
1700
1701    /// The period is the period with which the [`get_gui_tab_selected_callback_receiver`] receiver
1702    /// is triggered periodically. A value of 0 turns the receiver off.
1703    ///
1704    /// If the `value has to change`-parameter is set to true, the receiver is only
1705    /// triggered after the value has changed. If the value didn't change within the
1706    /// period, the receiver is triggered immediately on change.
1707    ///
1708    /// If it is set to false, the receiver is continuously triggered with the period,
1709    /// independent of the value.
1710    ///
1711    ///
1712    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1713    pub async fn set_gui_tab_selected_callback_configuration(
1714        &mut self,
1715        period: u32,
1716        value_has_to_change: bool,
1717    ) -> Result<(), TinkerforgeError> {
1718        let mut payload = [0; 5];
1719        period.write_to_slice(&mut payload[0..4]);
1720        value_has_to_change.write_to_slice(&mut payload[4..5]);
1721
1722        #[allow(unused_variables)]
1723        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiTabSelectedCallbackConfiguration), &payload).await?;
1724        Ok(())
1725    }
1726
1727    /// Returns the receiver configuration as set by
1728    /// [`set_gui_tab_selected_callback_configuration`].
1729    ///
1730    ///
1731    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1732    pub async fn get_gui_tab_selected_callback_configuration(&mut self) -> Result<GuiTabSelectedCallbackConfiguration, TinkerforgeError> {
1733        let payload = [0; 0];
1734
1735        #[allow(unused_variables)]
1736        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiTabSelectedCallbackConfiguration), &payload).await?;
1737        Ok(GuiTabSelectedCallbackConfiguration::from_le_byte_slice(result.body()))
1738    }
1739
1740    /// Returns the index of the currently selected tab.
1741    /// If there are not tabs, the returned index is -1.
1742    ///
1743    ///
1744    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1745    pub async fn get_gui_tab_selected(&mut self) -> Result<i8, TinkerforgeError> {
1746        let payload = [0; 0];
1747
1748        #[allow(unused_variables)]
1749        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiTabSelected), &payload).await?;
1750        Ok(i8::from_le_byte_slice(result.body()))
1751    }
1752
1753    /// Sets the configuration for up to four graphs.
1754    ///
1755    /// The graph type can be dot-, line- or bar-graph.
1756    ///
1757    /// The x and y position are pixel positions.
1758    ///
1759    /// You can add a text for the x and y axis.
1760    /// The text is drawn at the inside of the graph and it can overwrite some
1761    /// of the graph data. If you need the text outside of the graph you can
1762    /// leave this text here empty and use [`draw_text`] to draw the caption
1763    /// outside of the graph.
1764    ///
1765    /// The data of the graph can be set and updated with [`set_gui_graph_data`].
1766    ///
1767    /// The graph is drawn in a separate GUI buffer and the graph-frame and data will
1768    /// always stay on top of the graphics drawn with [`write_pixels`]. To
1769    /// remove the graph use [`remove_gui_graph`].
1770    ///
1771    ///
1772    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1773    ///
1774    /// Associated constants:
1775    /// * LCD_128X64_BRICKLET_GRAPH_TYPE_DOT
1776    ///	* LCD_128X64_BRICKLET_GRAPH_TYPE_LINE
1777    ///	* LCD_128X64_BRICKLET_GRAPH_TYPE_BAR
1778    pub async fn set_gui_graph_configuration(
1779        &mut self,
1780        index: u8,
1781        graph_type: u8,
1782        position_x: u8,
1783        position_y: u8,
1784        width: u8,
1785        height: u8,
1786        text_x: String,
1787        text_y: String,
1788    ) -> Result<(), TinkerforgeError> {
1789        let mut payload = [0; 14];
1790        index.write_to_slice(&mut payload[0..1]);
1791        graph_type.write_to_slice(&mut payload[1..2]);
1792        position_x.write_to_slice(&mut payload[2..3]);
1793        position_y.write_to_slice(&mut payload[3..4]);
1794        width.write_to_slice(&mut payload[4..5]);
1795        height.write_to_slice(&mut payload[5..6]);
1796        text_x.try_write_to_slice(4, &mut payload)?;
1797        text_y.try_write_to_slice(4, &mut payload)?;
1798
1799        #[allow(unused_variables)]
1800        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiGraphConfiguration), &payload).await?;
1801        Ok(())
1802    }
1803
1804    /// Returns the graph properties for a given `Index` as set by [`set_gui_graph_configuration`].
1805    ///
1806    /// Additionally the `Active` parameter shows if a graph is currently active/visible
1807    /// or not.
1808    ///
1809    ///
1810    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1811    ///
1812    /// Associated constants:
1813    /// * LCD_128X64_BRICKLET_GRAPH_TYPE_DOT
1814    ///	* LCD_128X64_BRICKLET_GRAPH_TYPE_LINE
1815    ///	* LCD_128X64_BRICKLET_GRAPH_TYPE_BAR
1816    pub async fn get_gui_graph_configuration(&mut self, index: u8) -> Result<GuiGraphConfiguration, TinkerforgeError> {
1817        let mut payload = [0; 1];
1818        index.write_to_slice(&mut payload[0..1]);
1819
1820        #[allow(unused_variables)]
1821        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiGraphConfiguration), &payload).await?;
1822        Ok(GuiGraphConfiguration::from_le_byte_slice(result.body()))
1823    }
1824
1825    /// Sets the data for a graph with the given index. You have to configure the graph with
1826    /// [`set_gui_graph_configuration`] before you can set the first data.
1827    ///
1828    /// The graph will show the first n values of the data that you set, where
1829    /// n is the width set with [`set_gui_graph_configuration`]. If you set
1830    /// less then n values it will show the rest of the values as zero.
1831    ///
1832    /// The maximum number of data-points you can set is 118 (which also corresponds to the
1833    /// maximum width of the graph).
1834    ///
1835    /// You have to scale your values to be between 0 and 255. 0 will be shown
1836    /// at the bottom of the graph and 255 at the top.
1837    ///
1838    ///
1839    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1840    pub async fn set_gui_graph_data_low_level(
1841        &mut self,
1842        index: u8,
1843        data_length: u16,
1844        data_chunk_offset: u16,
1845        data_chunk_data: &[u8; 59],
1846    ) -> Result<SetGuiGraphDataLowLevel, TinkerforgeError> {
1847        let mut payload = [0; 64];
1848        index.write_to_slice(&mut payload[0..1]);
1849        data_length.write_to_slice(&mut payload[1..3]);
1850        data_chunk_offset.write_to_slice(&mut payload[3..5]);
1851        data_chunk_data.write_to_slice(&mut payload[5..64]);
1852
1853        #[allow(unused_variables)]
1854        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetGuiGraphDataLowLevel), &payload).await?.unwrap();
1855        Ok(SetGuiGraphDataLowLevel::from_le_byte_slice(result.body()))
1856    }
1857
1858    /// Returns the graph data for a given index as set by [`set_gui_graph_data`].
1859    ///
1860    ///
1861    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1862    pub async fn get_gui_graph_data_low_level(&mut self, index: u8) -> Result<GuiGraphDataLowLevel, TinkerforgeError> {
1863        let mut payload = [0; 1];
1864        index.write_to_slice(&mut payload[0..1]);
1865
1866        #[allow(unused_variables)]
1867        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetGuiGraphDataLowLevel), &payload).await?;
1868        Ok(GuiGraphDataLowLevel::from_le_byte_slice(result.body()))
1869    }
1870
1871    /// Removes the graph with the given index.
1872    ///
1873    /// You can use index 255 to remove all graphs.
1874    ///
1875    ///
1876    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1877    pub async fn remove_gui_graph(&mut self, index: u8) -> Result<(), TinkerforgeError> {
1878        let mut payload = [0; 1];
1879        index.write_to_slice(&mut payload[0..1]);
1880
1881        #[allow(unused_variables)]
1882        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::RemoveGuiGraph), &payload).await?;
1883        Ok(())
1884    }
1885
1886    /// Removes all GUI elements (buttons, slider, graphs, tabs).
1887    ///
1888    ///
1889    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1890    pub async fn remove_all_gui(&mut self) -> Result<(), TinkerforgeError> {
1891        let payload = [0; 0];
1892
1893        #[allow(unused_variables)]
1894        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::RemoveAllGui), &payload).await?;
1895        Ok(())
1896    }
1897
1898    /// Sets the touch LED configuration. By default the LED is on if the
1899    /// LCD is touched.
1900    ///
1901    /// You can also turn the LED permanently on/off or show a heartbeat.
1902    ///
1903    /// If the Bricklet is in bootloader mode, the LED is off.
1904    ///
1905    ///
1906    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1907    ///
1908    /// Associated constants:
1909    /// * LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_OFF
1910    ///	* LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_ON
1911    ///	* LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_SHOW_HEARTBEAT
1912    ///	* LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_SHOW_TOUCH
1913    pub async fn set_touch_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
1914        let mut payload = [0; 1];
1915        config.write_to_slice(&mut payload[0..1]);
1916
1917        #[allow(unused_variables)]
1918        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetTouchLedConfig), &payload).await?;
1919        Ok(())
1920    }
1921
1922    /// Returns the configuration as set by [`set_touch_led_config`]
1923    ///
1924    ///
1925    /// .. versionadded:: 2.0.2$nbsp;(Plugin)
1926    ///
1927    /// Associated constants:
1928    /// * LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_OFF
1929    ///	* LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_ON
1930    ///	* LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_SHOW_HEARTBEAT
1931    ///	* LCD_128X64_BRICKLET_TOUCH_LED_CONFIG_SHOW_TOUCH
1932    pub async fn get_touch_led_config(&mut self) -> Result<u8, TinkerforgeError> {
1933        let payload = [0; 0];
1934
1935        #[allow(unused_variables)]
1936        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetTouchLedConfig), &payload).await?;
1937        Ok(u8::from_le_byte_slice(result.body()))
1938    }
1939
1940    /// Returns the error count for the communication between Brick and Bricklet.
1941    ///
1942    /// The errors are divided into
1943    ///
1944    /// * ACK checksum errors,
1945    /// * message checksum errors,
1946    /// * framing errors and
1947    /// * overflow errors.
1948    ///
1949    /// The errors counts are for errors that occur on the Bricklet side. All
1950    /// Bricks have a similar function that returns the errors on the Brick side.
1951    pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
1952        let payload = [0; 0];
1953
1954        #[allow(unused_variables)]
1955        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetSpitfpErrorCount), &payload).await?;
1956        Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
1957    }
1958
1959    /// Sets the bootloader mode and returns the status after the requested
1960    /// mode change was instigated.
1961    ///
1962    /// You can change from bootloader mode to firmware mode and vice versa. A change
1963    /// from bootloader mode to firmware mode will only take place if the entry function,
1964    /// device identifier and CRC are present and correct.
1965    ///
1966    /// This function is used by Brick Viewer during flashing. It should not be
1967    /// necessary to call it in a normal user program.
1968    ///
1969    /// Associated constants:
1970    /// * LCD_128X64_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
1971    ///	* LCD_128X64_BRICKLET_BOOTLOADER_MODE_FIRMWARE
1972    ///	* LCD_128X64_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
1973    ///	* LCD_128X64_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
1974    ///	* LCD_128X64_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
1975    ///	* LCD_128X64_BRICKLET_BOOTLOADER_STATUS_OK
1976    ///	* LCD_128X64_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE
1977    ///	* LCD_128X64_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE
1978    ///	* LCD_128X64_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT
1979    ///	* LCD_128X64_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT
1980    ///	* LCD_128X64_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH
1981    pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
1982        let mut payload = [0; 1];
1983        mode.write_to_slice(&mut payload[0..1]);
1984
1985        #[allow(unused_variables)]
1986        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::SetBootloaderMode), &payload).await?;
1987        Ok(u8::from_le_byte_slice(result.body()))
1988    }
1989
1990    /// Returns the current bootloader mode, see [`set_bootloader_mode`].
1991    ///
1992    /// Associated constants:
1993    /// * LCD_128X64_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
1994    ///	* LCD_128X64_BRICKLET_BOOTLOADER_MODE_FIRMWARE
1995    ///	* LCD_128X64_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
1996    ///	* LCD_128X64_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
1997    ///	* LCD_128X64_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
1998    pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
1999        let payload = [0; 0];
2000
2001        #[allow(unused_variables)]
2002        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetBootloaderMode), &payload).await?;
2003        Ok(u8::from_le_byte_slice(result.body()))
2004    }
2005
2006    /// Sets the firmware pointer for [`write_firmware`]. The pointer has
2007    /// to be increased by chunks of size 64. The data is written to flash
2008    /// every 4 chunks (which equals to one page of size 256).
2009    ///
2010    /// This function is used by Brick Viewer during flashing. It should not be
2011    /// necessary to call it in a normal user program.
2012    pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
2013        let mut payload = [0; 4];
2014        pointer.write_to_slice(&mut payload[0..4]);
2015
2016        #[allow(unused_variables)]
2017        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetWriteFirmwarePointer), &payload).await?;
2018        Ok(())
2019    }
2020
2021    /// Writes 64 Bytes of firmware at the position as written by
2022    /// [`set_write_firmware_pointer`] before. The firmware is written
2023    /// to flash every 4 chunks.
2024    ///
2025    /// You can only write firmware in bootloader mode.
2026    ///
2027    /// This function is used by Brick Viewer during flashing. It should not be
2028    /// necessary to call it in a normal user program.
2029    pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
2030        let mut payload = [0; 64];
2031        data.write_to_slice(&mut payload[0..64]);
2032
2033        #[allow(unused_variables)]
2034        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::WriteFirmware), &payload).await?;
2035        Ok(u8::from_le_byte_slice(result.body()))
2036    }
2037
2038    /// Sets the status LED configuration. By default the LED shows
2039    /// communication traffic between Brick and Bricklet, it flickers once
2040    /// for every 10 received data packets.
2041    ///
2042    /// You can also turn the LED permanently on/off or show a heartbeat.
2043    ///
2044    /// If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
2045    ///
2046    /// Associated constants:
2047    /// * LCD_128X64_BRICKLET_STATUS_LED_CONFIG_OFF
2048    ///	* LCD_128X64_BRICKLET_STATUS_LED_CONFIG_ON
2049    ///	* LCD_128X64_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
2050    ///	* LCD_128X64_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
2051    pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
2052        let mut payload = [0; 1];
2053        config.write_to_slice(&mut payload[0..1]);
2054
2055        #[allow(unused_variables)]
2056        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::SetStatusLedConfig), &payload).await?;
2057        Ok(())
2058    }
2059
2060    /// Returns the configuration as set by [`set_status_led_config`]
2061    ///
2062    /// Associated constants:
2063    /// * LCD_128X64_BRICKLET_STATUS_LED_CONFIG_OFF
2064    ///	* LCD_128X64_BRICKLET_STATUS_LED_CONFIG_ON
2065    ///	* LCD_128X64_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
2066    ///	* LCD_128X64_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
2067    pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
2068        let payload = [0; 0];
2069
2070        #[allow(unused_variables)]
2071        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetStatusLedConfig), &payload).await?;
2072        Ok(u8::from_le_byte_slice(result.body()))
2073    }
2074
2075    /// Returns the temperature as measured inside the microcontroller. The
2076    /// value returned is not the ambient temperature!
2077    ///
2078    /// The temperature is only proportional to the real temperature and it has bad
2079    /// accuracy. Practically it is only useful as an indicator for
2080    /// temperature changes.
2081    pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
2082        let payload = [0; 0];
2083
2084        #[allow(unused_variables)]
2085        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetChipTemperature), &payload).await?;
2086        Ok(i16::from_le_byte_slice(result.body()))
2087    }
2088
2089    /// Calling this function will reset the Bricklet. All configurations
2090    /// will be lost.
2091    ///
2092    /// After a reset you have to create new device objects,
2093    /// calling functions on the existing ones will result in
2094    /// undefined behavior!
2095    pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
2096        let payload = [0; 0];
2097
2098        #[allow(unused_variables)]
2099        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::Reset), &payload).await?;
2100        Ok(())
2101    }
2102
2103    /// Writes a new UID into flash. If you want to set a new UID
2104    /// you have to decode the Base58 encoded UID string into an
2105    /// integer first.
2106    ///
2107    /// We recommend that you use Brick Viewer to change the UID.
2108    pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
2109        let mut payload = [0; 4];
2110        uid.write_to_slice(&mut payload[0..4]);
2111
2112        #[allow(unused_variables)]
2113        let result = self.device.set(u8::from(Lcd128x64BrickletFunction::WriteUid), &payload).await?;
2114        Ok(())
2115    }
2116
2117    /// Returns the current UID as an integer. Encode as
2118    /// Base58 to get the usual string version.
2119    pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
2120        let payload = [0; 0];
2121
2122        #[allow(unused_variables)]
2123        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::ReadUid), &payload).await?;
2124        Ok(u32::from_le_byte_slice(result.body()))
2125    }
2126
2127    /// Returns the UID, the UID where the Bricklet is connected to,
2128    /// the position, the hardware and firmware version as well as the
2129    /// device identifier.
2130    ///
2131    /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
2132    /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
2133    /// position 'z'.
2134    ///
2135    /// The device identifier numbers can be found [here](device_identifier).
2136    /// |device_identifier_constant|
2137    pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
2138        let payload = [0; 0];
2139
2140        #[allow(unused_variables)]
2141        let result = self.device.get(u8::from(Lcd128x64BrickletFunction::GetIdentity), &payload).await?;
2142        Ok(Identity::from_le_byte_slice(result.body()))
2143    }
2144}