tinkerforge_async/bindings/
e_paper_296x128_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//! Three color 296x128 e-paper display.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/EPaper296x128_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 EPaper296x128BrickletFunction {
29    Draw,
30    GetDrawStatus,
31    WriteBlackWhiteLowLevel,
32    ReadBlackWhiteLowLevel,
33    WriteColorLowLevel,
34    ReadColorLowLevel,
35    FillDisplay,
36    DrawText,
37    DrawLine,
38    DrawBox,
39    SetUpdateMode,
40    GetUpdateMode,
41    SetDisplayType,
42    GetDisplayType,
43    SetDisplayDriver,
44    GetDisplayDriver,
45    GetSpitfpErrorCount,
46    SetBootloaderMode,
47    GetBootloaderMode,
48    SetWriteFirmwarePointer,
49    WriteFirmware,
50    SetStatusLedConfig,
51    GetStatusLedConfig,
52    GetChipTemperature,
53    Reset,
54    WriteUid,
55    ReadUid,
56    GetIdentity,
57    CallbackDrawStatus,
58}
59impl From<EPaper296x128BrickletFunction> for u8 {
60    fn from(fun: EPaper296x128BrickletFunction) -> Self {
61        match fun {
62            EPaper296x128BrickletFunction::Draw => 1,
63            EPaper296x128BrickletFunction::GetDrawStatus => 2,
64            EPaper296x128BrickletFunction::WriteBlackWhiteLowLevel => 3,
65            EPaper296x128BrickletFunction::ReadBlackWhiteLowLevel => 4,
66            EPaper296x128BrickletFunction::WriteColorLowLevel => 5,
67            EPaper296x128BrickletFunction::ReadColorLowLevel => 6,
68            EPaper296x128BrickletFunction::FillDisplay => 7,
69            EPaper296x128BrickletFunction::DrawText => 8,
70            EPaper296x128BrickletFunction::DrawLine => 9,
71            EPaper296x128BrickletFunction::DrawBox => 10,
72            EPaper296x128BrickletFunction::SetUpdateMode => 12,
73            EPaper296x128BrickletFunction::GetUpdateMode => 13,
74            EPaper296x128BrickletFunction::SetDisplayType => 14,
75            EPaper296x128BrickletFunction::GetDisplayType => 15,
76            EPaper296x128BrickletFunction::SetDisplayDriver => 16,
77            EPaper296x128BrickletFunction::GetDisplayDriver => 17,
78            EPaper296x128BrickletFunction::GetSpitfpErrorCount => 234,
79            EPaper296x128BrickletFunction::SetBootloaderMode => 235,
80            EPaper296x128BrickletFunction::GetBootloaderMode => 236,
81            EPaper296x128BrickletFunction::SetWriteFirmwarePointer => 237,
82            EPaper296x128BrickletFunction::WriteFirmware => 238,
83            EPaper296x128BrickletFunction::SetStatusLedConfig => 239,
84            EPaper296x128BrickletFunction::GetStatusLedConfig => 240,
85            EPaper296x128BrickletFunction::GetChipTemperature => 242,
86            EPaper296x128BrickletFunction::Reset => 243,
87            EPaper296x128BrickletFunction::WriteUid => 248,
88            EPaper296x128BrickletFunction::ReadUid => 249,
89            EPaper296x128BrickletFunction::GetIdentity => 255,
90            EPaper296x128BrickletFunction::CallbackDrawStatus => 11,
91        }
92    }
93}
94pub const E_PAPER_296X128_BRICKLET_DRAW_STATUS_IDLE: u8 = 0;
95pub const E_PAPER_296X128_BRICKLET_DRAW_STATUS_COPYING: u8 = 1;
96pub const E_PAPER_296X128_BRICKLET_DRAW_STATUS_DRAWING: u8 = 2;
97pub const E_PAPER_296X128_BRICKLET_COLOR_BLACK: u8 = 0;
98pub const E_PAPER_296X128_BRICKLET_COLOR_WHITE: u8 = 1;
99pub const E_PAPER_296X128_BRICKLET_COLOR_RED: u8 = 2;
100pub const E_PAPER_296X128_BRICKLET_COLOR_GRAY: u8 = 2;
101pub const E_PAPER_296X128_BRICKLET_FONT_6X8: u8 = 0;
102pub const E_PAPER_296X128_BRICKLET_FONT_6X16: u8 = 1;
103pub const E_PAPER_296X128_BRICKLET_FONT_6X24: u8 = 2;
104pub const E_PAPER_296X128_BRICKLET_FONT_6X32: u8 = 3;
105pub const E_PAPER_296X128_BRICKLET_FONT_12X16: u8 = 4;
106pub const E_PAPER_296X128_BRICKLET_FONT_12X24: u8 = 5;
107pub const E_PAPER_296X128_BRICKLET_FONT_12X32: u8 = 6;
108pub const E_PAPER_296X128_BRICKLET_FONT_18X24: u8 = 7;
109pub const E_PAPER_296X128_BRICKLET_FONT_18X32: u8 = 8;
110pub const E_PAPER_296X128_BRICKLET_FONT_24X32: u8 = 9;
111pub const E_PAPER_296X128_BRICKLET_ORIENTATION_HORIZONTAL: u8 = 0;
112pub const E_PAPER_296X128_BRICKLET_ORIENTATION_VERTICAL: u8 = 1;
113pub const E_PAPER_296X128_BRICKLET_UPDATE_MODE_DEFAULT: u8 = 0;
114pub const E_PAPER_296X128_BRICKLET_UPDATE_MODE_BLACK_WHITE: u8 = 1;
115pub const E_PAPER_296X128_BRICKLET_UPDATE_MODE_DELTA: u8 = 2;
116pub const E_PAPER_296X128_BRICKLET_DISPLAY_TYPE_BLACK_WHITE_RED: u8 = 0;
117pub const E_PAPER_296X128_BRICKLET_DISPLAY_TYPE_BLACK_WHITE_GRAY: u8 = 1;
118pub const E_PAPER_296X128_BRICKLET_DISPLAY_DRIVER_SSD1675A: u8 = 0;
119pub const E_PAPER_296X128_BRICKLET_DISPLAY_DRIVER_SSD1680: u8 = 1;
120pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
121pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
122pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
123pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
124pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
125pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
126pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
127pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
128pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
129pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
130pub const E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
131pub const E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
132pub const E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
133pub const E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
134pub const E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
135
136#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
137pub struct WriteBlackWhiteLowLevel {}
138impl FromByteSlice for WriteBlackWhiteLowLevel {
139    fn bytes_expected() -> usize {
140        0
141    }
142    fn from_le_byte_slice(_bytes: &[u8]) -> WriteBlackWhiteLowLevel {
143        WriteBlackWhiteLowLevel {}
144    }
145}
146
147#[derive(Clone, Copy)]
148pub struct ReadBlackWhiteLowLevel {
149    pub pixels_length: u16,
150    pub pixels_chunk_offset: u16,
151    pub pixels_chunk_data: [bool; 464],
152}
153impl FromByteSlice for ReadBlackWhiteLowLevel {
154    fn bytes_expected() -> usize {
155        62
156    }
157    fn from_le_byte_slice(bytes: &[u8]) -> ReadBlackWhiteLowLevel {
158        ReadBlackWhiteLowLevel {
159            pixels_length: <u16>::from_le_byte_slice(&bytes[0..2]),
160            pixels_chunk_offset: <u16>::from_le_byte_slice(&bytes[2..4]),
161            pixels_chunk_data: <[bool; 464]>::from_le_byte_slice(&bytes[4..62]),
162        }
163    }
164}
165impl LowLevelRead<bool, ReadBlackWhiteResult> for ReadBlackWhiteLowLevel {
166    fn ll_message_length(&self) -> usize {
167        self.pixels_length as usize
168    }
169
170    fn ll_message_chunk_offset(&self) -> usize {
171        self.pixels_chunk_offset as usize
172    }
173
174    fn ll_message_chunk_data(&self) -> &[bool] {
175        &self.pixels_chunk_data
176    }
177
178    fn get_result(&self) -> ReadBlackWhiteResult {
179        ReadBlackWhiteResult {}
180    }
181}
182
183#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
184pub struct WriteColorLowLevel {}
185impl FromByteSlice for WriteColorLowLevel {
186    fn bytes_expected() -> usize {
187        0
188    }
189    fn from_le_byte_slice(_bytes: &[u8]) -> WriteColorLowLevel {
190        WriteColorLowLevel {}
191    }
192}
193
194#[derive(Clone, Copy)]
195pub struct ReadColorLowLevel {
196    pub pixels_length: u16,
197    pub pixels_chunk_offset: u16,
198    pub pixels_chunk_data: [bool; 464],
199}
200impl FromByteSlice for ReadColorLowLevel {
201    fn bytes_expected() -> usize {
202        62
203    }
204    fn from_le_byte_slice(bytes: &[u8]) -> ReadColorLowLevel {
205        ReadColorLowLevel {
206            pixels_length: <u16>::from_le_byte_slice(&bytes[0..2]),
207            pixels_chunk_offset: <u16>::from_le_byte_slice(&bytes[2..4]),
208            pixels_chunk_data: <[bool; 464]>::from_le_byte_slice(&bytes[4..62]),
209        }
210    }
211}
212impl LowLevelRead<bool, ReadColorResult> for ReadColorLowLevel {
213    fn ll_message_length(&self) -> usize {
214        self.pixels_length as usize
215    }
216
217    fn ll_message_chunk_offset(&self) -> usize {
218        self.pixels_chunk_offset as usize
219    }
220
221    fn ll_message_chunk_data(&self) -> &[bool] {
222        &self.pixels_chunk_data
223    }
224
225    fn get_result(&self) -> ReadColorResult {
226        ReadColorResult {}
227    }
228}
229
230#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
231pub struct SpitfpErrorCount {
232    pub error_count_ack_checksum: u32,
233    pub error_count_message_checksum: u32,
234    pub error_count_frame: u32,
235    pub error_count_overflow: u32,
236}
237impl FromByteSlice for SpitfpErrorCount {
238    fn bytes_expected() -> usize {
239        16
240    }
241    fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
242        SpitfpErrorCount {
243            error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
244            error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
245            error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
246            error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
247        }
248    }
249}
250
251#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
252pub struct Identity {
253    pub uid: String,
254    pub connected_uid: String,
255    pub position: char,
256    pub hardware_version: [u8; 3],
257    pub firmware_version: [u8; 3],
258    pub device_identifier: u16,
259}
260impl FromByteSlice for Identity {
261    fn bytes_expected() -> usize {
262        25
263    }
264    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
265        Identity {
266            uid: <String>::from_le_byte_slice(&bytes[0..8]),
267            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
268            position: <char>::from_le_byte_slice(&bytes[16..17]),
269            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
270            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
271            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
272        }
273    }
274}
275
276#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
277pub struct WriteBlackWhiteResult {}
278
279#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
280pub struct ReadBlackWhiteResult {}
281
282#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
283pub struct WriteColorResult {}
284
285#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
286pub struct ReadColorResult {}
287
288/// Three color 296x128 e-paper display
289#[derive(Clone)]
290pub struct EPaper296x128Bricklet {
291    device: Device,
292}
293impl EPaper296x128Bricklet {
294    pub const DEVICE_IDENTIFIER: u16 = 2146;
295    pub const DEVICE_DISPLAY_NAME: &'static str = "E-Paper 296x128 Bricklet";
296    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
297    pub fn new(uid: Uid, connection: AsyncIpConnection) -> EPaper296x128Bricklet {
298        let mut result = EPaper296x128Bricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
299        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::Draw) as usize] = ResponseExpectedFlag::False;
300        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::GetDrawStatus) as usize] = ResponseExpectedFlag::AlwaysTrue;
301        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::WriteBlackWhiteLowLevel) as usize] =
302            ResponseExpectedFlag::True;
303        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::ReadBlackWhiteLowLevel) as usize] =
304            ResponseExpectedFlag::AlwaysTrue;
305        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::WriteColorLowLevel) as usize] = ResponseExpectedFlag::True;
306        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::ReadColorLowLevel) as usize] =
307            ResponseExpectedFlag::AlwaysTrue;
308        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::FillDisplay) as usize] = ResponseExpectedFlag::False;
309        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::DrawText) as usize] = ResponseExpectedFlag::False;
310        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::DrawLine) as usize] = ResponseExpectedFlag::False;
311        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::DrawBox) as usize] = ResponseExpectedFlag::False;
312        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::SetUpdateMode) as usize] = ResponseExpectedFlag::False;
313        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::GetUpdateMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
314        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::SetDisplayType) as usize] = ResponseExpectedFlag::False;
315        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::GetDisplayType) as usize] =
316            ResponseExpectedFlag::AlwaysTrue;
317        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::SetDisplayDriver) as usize] = ResponseExpectedFlag::False;
318        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::GetDisplayDriver) as usize] =
319            ResponseExpectedFlag::AlwaysTrue;
320        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::GetSpitfpErrorCount) as usize] =
321            ResponseExpectedFlag::AlwaysTrue;
322        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::SetBootloaderMode) as usize] =
323            ResponseExpectedFlag::AlwaysTrue;
324        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::GetBootloaderMode) as usize] =
325            ResponseExpectedFlag::AlwaysTrue;
326        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::SetWriteFirmwarePointer) as usize] =
327            ResponseExpectedFlag::False;
328        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::WriteFirmware) as usize] = ResponseExpectedFlag::AlwaysTrue;
329        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::SetStatusLedConfig) as usize] = ResponseExpectedFlag::False;
330        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::GetStatusLedConfig) as usize] =
331            ResponseExpectedFlag::AlwaysTrue;
332        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::GetChipTemperature) as usize] =
333            ResponseExpectedFlag::AlwaysTrue;
334        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
335        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
336        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
337        result.device.response_expected[u8::from(EPaper296x128BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
338        result
339    }
340
341    /// Returns the response expected flag for the function specified by the function ID parameter.
342    /// It is true if the function is expected to send a response, false otherwise.
343    ///
344    /// For getter functions this is enabled by default and cannot be disabled, because those
345    /// functions will always send a response. For callback configuration functions it is enabled
346    /// by default too, but can be disabled by [`set_response_expected`](crate::e_paper_296x128_bricklet::EPaper296x128Bricklet::set_response_expected).
347    /// For setter functions it is disabled by default and can be enabled.
348    ///
349    /// Enabling the response expected flag for a setter function allows to detect timeouts
350    /// and other error conditions calls of this setter as well. The device will then send a response
351    /// for this purpose. If this flag is disabled for a setter function then no response is sent
352    /// and errors are silently ignored, because they cannot be detected.
353    ///
354    /// See [`set_response_expected`](crate::e_paper_296x128_bricklet::EPaper296x128Bricklet::set_response_expected) for the list of function ID constants available for this function.
355    pub fn get_response_expected(&mut self, fun: EPaper296x128BrickletFunction) -> Result<bool, GetResponseExpectedError> {
356        self.device.get_response_expected(u8::from(fun))
357    }
358
359    /// Changes the response expected flag of the function specified by the function ID parameter.
360    /// This flag can only be changed for setter (default value: false) and callback configuration
361    /// functions (default value: true). For getter functions it is always enabled.
362    ///
363    /// Enabling the response expected flag for a setter function allows to detect timeouts and
364    /// other error conditions calls of this setter as well. The device will then send a response
365    /// for this purpose. If this flag is disabled for a setter function then no response is sent
366    /// and errors are silently ignored, because they cannot be detected.
367    pub fn set_response_expected(
368        &mut self,
369        fun: EPaper296x128BrickletFunction,
370        response_expected: bool,
371    ) -> Result<(), SetResponseExpectedError> {
372        self.device.set_response_expected(u8::from(fun), response_expected)
373    }
374
375    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
376    pub fn set_response_expected_all(&mut self, response_expected: bool) {
377        self.device.set_response_expected_all(response_expected)
378    }
379
380    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
381    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
382    pub fn get_api_version(&self) -> [u8; 3] {
383        self.device.api_version
384    }
385
386    /// Receiver for the current draw status. Will be called every time the
387    /// draw status changes (see [`get_draw_status`]).
388    ///
389    /// [`get_draw_status`]: #method.get_draw_status
390    pub async fn get_draw_status_callback_receiver(&mut self) -> impl Stream<Item = u8> {
391        self.device
392            .get_callback_receiver(u8::from(EPaper296x128BrickletFunction::CallbackDrawStatus))
393            .await
394            .map(|p| u8::from_le_byte_slice(p.body()))
395    }
396
397    /// Draws the current black/white and red or gray buffer to the e-paper display.
398    ///
399    /// The Bricklet does not have any double-buffering. You should not call
400    /// this function while writing to the buffer. See [`get_draw_status`].
401    pub async fn draw(&mut self) -> Result<(), TinkerforgeError> {
402        let payload = [0; 0];
403
404        #[allow(unused_variables)]
405        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::Draw), &payload).await?;
406        Ok(())
407    }
408
409    /// Returns one of three draw statuses:
410    ///
411    /// * Idle
412    /// * Copying: Data is being copied from the buffer of the Bricklet to the buffer of the display.
413    /// * Drawing: The display is updating its content (during this phase the flickering etc happens).
414    ///
415    /// You can write to the buffer (through one of the write or draw functions) when the status is
416    /// either *idle* or *drawing*. You should not write to the buffer while it is being *copied* to the
417    /// display. There is no double-buffering.
418    ///
419    /// Associated constants:
420    /// * E_PAPER_296X128_BRICKLET_DRAW_STATUS_IDLE
421    ///	* E_PAPER_296X128_BRICKLET_DRAW_STATUS_COPYING
422    ///	* E_PAPER_296X128_BRICKLET_DRAW_STATUS_DRAWING
423    pub async fn get_draw_status(&mut self) -> Result<u8, TinkerforgeError> {
424        let payload = [0; 0];
425
426        #[allow(unused_variables)]
427        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::GetDrawStatus), &payload).await?;
428        Ok(u8::from_le_byte_slice(result.body()))
429    }
430
431    /// Writes black/white pixels to the specified window into the buffer.
432    ///
433    /// The pixels are written into the window line by line top to bottom
434    /// and each line is written from left to right.
435    ///
436    /// The value 0 (false) corresponds to a black pixel and the value 1 (true) to a
437    /// white pixel.
438    ///
439    /// This function writes the pixels into the black/white pixel buffer, to draw the
440    /// buffer to the display use [`draw`].
441    ///
442    /// Use [`write_color`] to write red or gray pixels.
443    pub async fn write_black_white_low_level(
444        &mut self,
445        x_start: u16,
446        y_start: u8,
447        x_end: u16,
448        y_end: u8,
449        pixels_length: u16,
450        pixels_chunk_offset: u16,
451        pixels_chunk_data: &[bool; 432],
452    ) -> Result<WriteBlackWhiteLowLevel, TinkerforgeError> {
453        let mut payload = [0; 64];
454        x_start.write_to_slice(&mut payload[0..2]);
455        y_start.write_to_slice(&mut payload[2..3]);
456        x_end.write_to_slice(&mut payload[3..5]);
457        y_end.write_to_slice(&mut payload[5..6]);
458        pixels_length.write_to_slice(&mut payload[6..8]);
459        pixels_chunk_offset.write_to_slice(&mut payload[8..10]);
460        pixels_chunk_data.write_to_slice(&mut payload[10..64]);
461
462        #[allow(unused_variables)]
463        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::WriteBlackWhiteLowLevel), &payload).await?.unwrap();
464        Ok(WriteBlackWhiteLowLevel::from_le_byte_slice(result.body()))
465    }
466
467    /// Returns the current content of the black/white pixel buffer for the specified window.
468    ///
469    /// The pixels are read into the window line by line top to bottom and
470    /// each line is read from left to right.
471    ///
472    /// The current content of the buffer does not have to be the current content of the display.
473    /// It is possible that the data was not drawn to the display yet and after a restart of
474    /// the Bricklet the buffer will be reset to black, while the display retains its content.
475    pub async fn read_black_white_low_level(
476        &mut self,
477        x_start: u16,
478        y_start: u8,
479        x_end: u16,
480        y_end: u8,
481    ) -> Result<ReadBlackWhiteLowLevel, TinkerforgeError> {
482        let mut payload = [0; 6];
483        x_start.write_to_slice(&mut payload[0..2]);
484        y_start.write_to_slice(&mut payload[2..3]);
485        x_end.write_to_slice(&mut payload[3..5]);
486        y_end.write_to_slice(&mut payload[5..6]);
487
488        #[allow(unused_variables)]
489        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::ReadBlackWhiteLowLevel), &payload).await?;
490        Ok(ReadBlackWhiteLowLevel::from_le_byte_slice(result.body()))
491    }
492
493    /// The E-Paper 296x128 Bricklet is available with the colors black/white/red and
494    /// black/white/gray. Depending on the model this function writes either red or
495    /// gray pixels to the specified window into the buffer.
496    ///
497    /// The pixels are written into the window line by line top to bottom
498    /// and each line is written from left to right.
499    ///
500    /// The value 0 (false) means that this pixel does not have color. It will be either black
501    /// or white (see [`write_black_white`]). The value 1 (true) corresponds to a red or gray
502    /// pixel, depending on the Bricklet model.
503    ///
504    /// This function writes the pixels into the red or gray pixel buffer, to draw the buffer
505    /// to the display use [`draw`].
506    ///
507    /// Use [`write_black_white`] to write black/white pixels.
508    pub async fn write_color_low_level(
509        &mut self,
510        x_start: u16,
511        y_start: u8,
512        x_end: u16,
513        y_end: u8,
514        pixels_length: u16,
515        pixels_chunk_offset: u16,
516        pixels_chunk_data: &[bool; 432],
517    ) -> Result<WriteColorLowLevel, TinkerforgeError> {
518        let mut payload = [0; 64];
519        x_start.write_to_slice(&mut payload[0..2]);
520        y_start.write_to_slice(&mut payload[2..3]);
521        x_end.write_to_slice(&mut payload[3..5]);
522        y_end.write_to_slice(&mut payload[5..6]);
523        pixels_length.write_to_slice(&mut payload[6..8]);
524        pixels_chunk_offset.write_to_slice(&mut payload[8..10]);
525        pixels_chunk_data.write_to_slice(&mut payload[10..64]);
526
527        #[allow(unused_variables)]
528        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::WriteColorLowLevel), &payload).await?.unwrap();
529        Ok(WriteColorLowLevel::from_le_byte_slice(result.body()))
530    }
531
532    /// Returns the current content of the red or gray pixel buffer for the specified window.
533    ///
534    /// The pixels are written into the window line by line top to bottom
535    /// and each line is written from left to right.
536    ///
537    /// The current content of the buffer does not have to be the current content of the display.
538    /// It is possible that the data was not drawn to the display yet and after a restart of
539    /// the Bricklet the buffer will be reset to black, while the display retains its content.
540    pub async fn read_color_low_level(
541        &mut self,
542        x_start: u16,
543        y_start: u8,
544        x_end: u16,
545        y_end: u8,
546    ) -> Result<ReadColorLowLevel, TinkerforgeError> {
547        let mut payload = [0; 6];
548        x_start.write_to_slice(&mut payload[0..2]);
549        y_start.write_to_slice(&mut payload[2..3]);
550        x_end.write_to_slice(&mut payload[3..5]);
551        y_end.write_to_slice(&mut payload[5..6]);
552
553        #[allow(unused_variables)]
554        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::ReadColorLowLevel), &payload).await?;
555        Ok(ReadColorLowLevel::from_le_byte_slice(result.body()))
556    }
557
558    /// Fills the complete content of the display with the given color.
559    ///
560    /// This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer
561    /// to the display use [`draw`].
562    ///
563    /// Associated constants:
564    /// * E_PAPER_296X128_BRICKLET_COLOR_BLACK
565    ///	* E_PAPER_296X128_BRICKLET_COLOR_WHITE
566    ///	* E_PAPER_296X128_BRICKLET_COLOR_RED
567    ///	* E_PAPER_296X128_BRICKLET_COLOR_GRAY
568    pub async fn fill_display(&mut self, color: u8) -> Result<(), TinkerforgeError> {
569        let mut payload = [0; 1];
570        color.write_to_slice(&mut payload[0..1]);
571
572        #[allow(unused_variables)]
573        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::FillDisplay), &payload).await?;
574        Ok(())
575    }
576
577    /// Draws a text with up to 50 characters at the pixel position (x, y).
578    ///
579    /// You can use one of 9 different font sizes and draw the text in
580    /// black/white/red|gray. The text can be drawn horizontal or vertical.
581    ///
582    /// This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer
583    /// to the display use [`draw`].
584    ///
585    /// The font conforms to code page 437.
586    ///
587    /// Associated constants:
588    /// * E_PAPER_296X128_BRICKLET_FONT_6X8
589    ///	* E_PAPER_296X128_BRICKLET_FONT_6X16
590    ///	* E_PAPER_296X128_BRICKLET_FONT_6X24
591    ///	* E_PAPER_296X128_BRICKLET_FONT_6X32
592    ///	* E_PAPER_296X128_BRICKLET_FONT_12X16
593    ///	* E_PAPER_296X128_BRICKLET_FONT_12X24
594    ///	* E_PAPER_296X128_BRICKLET_FONT_12X32
595    ///	* E_PAPER_296X128_BRICKLET_FONT_18X24
596    ///	* E_PAPER_296X128_BRICKLET_FONT_18X32
597    ///	* E_PAPER_296X128_BRICKLET_FONT_24X32
598    ///	* E_PAPER_296X128_BRICKLET_COLOR_BLACK
599    ///	* E_PAPER_296X128_BRICKLET_COLOR_WHITE
600    ///	* E_PAPER_296X128_BRICKLET_COLOR_RED
601    ///	* E_PAPER_296X128_BRICKLET_COLOR_GRAY
602    ///	* E_PAPER_296X128_BRICKLET_ORIENTATION_HORIZONTAL
603    ///	* E_PAPER_296X128_BRICKLET_ORIENTATION_VERTICAL
604    pub async fn draw_text(
605        &mut self,
606        position_x: u16,
607        position_y: u8,
608        font: u8,
609        color: u8,
610        orientation: u8,
611        text: String,
612    ) -> Result<(), TinkerforgeError> {
613        let mut payload = [0; 56];
614        position_x.write_to_slice(&mut payload[0..2]);
615        position_y.write_to_slice(&mut payload[2..3]);
616        font.write_to_slice(&mut payload[3..4]);
617        color.write_to_slice(&mut payload[4..5]);
618        orientation.write_to_slice(&mut payload[5..6]);
619        text.try_write_to_slice(50, &mut payload)?;
620
621        #[allow(unused_variables)]
622        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::DrawText), &payload).await?;
623        Ok(())
624    }
625
626    /// Draws a line from (x, y)-start to (x, y)-end in the given color.
627    ///
628    /// This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer
629    /// to the display use [`draw`].
630    ///
631    /// Associated constants:
632    /// * E_PAPER_296X128_BRICKLET_COLOR_BLACK
633    ///	* E_PAPER_296X128_BRICKLET_COLOR_WHITE
634    ///	* E_PAPER_296X128_BRICKLET_COLOR_RED
635    ///	* E_PAPER_296X128_BRICKLET_COLOR_GRAY
636    pub async fn draw_line(
637        &mut self,
638        position_x_start: u16,
639        position_y_start: u8,
640        position_x_end: u16,
641        position_y_end: u8,
642        color: u8,
643    ) -> Result<(), TinkerforgeError> {
644        let mut payload = [0; 7];
645        position_x_start.write_to_slice(&mut payload[0..2]);
646        position_y_start.write_to_slice(&mut payload[2..3]);
647        position_x_end.write_to_slice(&mut payload[3..5]);
648        position_y_end.write_to_slice(&mut payload[5..6]);
649        color.write_to_slice(&mut payload[6..7]);
650
651        #[allow(unused_variables)]
652        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::DrawLine), &payload).await?;
653        Ok(())
654    }
655
656    /// Draws a box from (x, y)-start to (x, y)-end in the given color.
657    ///
658    /// If you set fill to true, the box will be filled with the
659    /// color. Otherwise only the outline will be drawn.
660    ///
661    /// This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer
662    /// to the display use [`draw`].
663    ///
664    /// Associated constants:
665    /// * E_PAPER_296X128_BRICKLET_COLOR_BLACK
666    ///	* E_PAPER_296X128_BRICKLET_COLOR_WHITE
667    ///	* E_PAPER_296X128_BRICKLET_COLOR_RED
668    ///	* E_PAPER_296X128_BRICKLET_COLOR_GRAY
669    pub async fn draw_box(
670        &mut self,
671        position_x_start: u16,
672        position_y_start: u8,
673        position_x_end: u16,
674        position_y_end: u8,
675        fill: bool,
676        color: u8,
677    ) -> Result<(), TinkerforgeError> {
678        let mut payload = [0; 8];
679        position_x_start.write_to_slice(&mut payload[0..2]);
680        position_y_start.write_to_slice(&mut payload[2..3]);
681        position_x_end.write_to_slice(&mut payload[3..5]);
682        position_y_end.write_to_slice(&mut payload[5..6]);
683        fill.write_to_slice(&mut payload[6..7]);
684        color.write_to_slice(&mut payload[7..8]);
685
686        #[allow(unused_variables)]
687        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::DrawBox), &payload).await?;
688        Ok(())
689    }
690
691    /// # Note
692    ///  The default update mode corresponds to the default e-paper display
693    ///  manufacturer settings. All of the other modes are experimental and
694    ///  will result in increased ghosting and possibly other long-term
695    ///  side effects.
696    ///
697    ///  If you want to know more about the inner workings of an e-paper display
698    ///  take a look at this excellent video from Ben Krasnow:
699    ///  [https://www.youtube.com/watch?v=MsbiO8EAsGw](https://www.youtube.com/watch?v=MsbiO8EAsGw)__.
700    ///
701    ///  If you are not sure about this option, leave the update mode at default.
702    ///
703    /// Currently there are three update modes available:
704    ///
705    /// * Default: Settings as given by the manufacturer. An update will take about
706    ///   7.5 seconds and during the update the screen will flicker several times.
707    /// * Black/White: This will only update the black/white pixel. It uses the manufacturer
708    ///   settings for black/white and ignores the red or gray pixel buffer. With this mode the
709    ///   display will flicker once and it takes about 2.5 seconds. Compared to the default settings
710    ///   there is more ghosting.
711    /// * Delta: This will only update the black/white pixel. It uses an aggressive method where
712    ///   the changes are not applied for a whole buffer but only for the delta between the last
713    ///   and the next buffer. With this mode the display will not flicker during an update and
714    ///   it takes about 900-950ms. Compared to the other two settings there is more ghosting. This
715    ///   mode can be used for something like a flicker-free live update of a text.
716    ///
717    /// With the black/white/red display if you use either the black/white or the delta mode,
718    /// after a while of going back and forth between black and white the white color will
719    /// start to appear red-ish or pink-ish.
720    ///
721    /// If you use the aggressive delta mode and rapidly change the content, we recommend that you
722    /// change back to the default mode every few hours and in the default mode cycle between the
723    /// three available colors a few times. This will get rid of the ghosting and after that you can
724    /// go back to the delta mode with flicker-free updates.
725    ///
726    /// Associated constants:
727    /// * E_PAPER_296X128_BRICKLET_UPDATE_MODE_DEFAULT
728    ///	* E_PAPER_296X128_BRICKLET_UPDATE_MODE_BLACK_WHITE
729    ///	* E_PAPER_296X128_BRICKLET_UPDATE_MODE_DELTA
730    pub async fn set_update_mode(&mut self, update_mode: u8) -> Result<(), TinkerforgeError> {
731        let mut payload = [0; 1];
732        update_mode.write_to_slice(&mut payload[0..1]);
733
734        #[allow(unused_variables)]
735        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::SetUpdateMode), &payload).await?;
736        Ok(())
737    }
738
739    /// Returns the update mode as set by [`set_update_mode`].
740    ///
741    /// Associated constants:
742    /// * E_PAPER_296X128_BRICKLET_UPDATE_MODE_DEFAULT
743    ///	* E_PAPER_296X128_BRICKLET_UPDATE_MODE_BLACK_WHITE
744    ///	* E_PAPER_296X128_BRICKLET_UPDATE_MODE_DELTA
745    pub async fn get_update_mode(&mut self) -> Result<u8, TinkerforgeError> {
746        let payload = [0; 0];
747
748        #[allow(unused_variables)]
749        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::GetUpdateMode), &payload).await?;
750        Ok(u8::from_le_byte_slice(result.body()))
751    }
752
753    /// Sets the type of the display. The e-paper display is available
754    /// in black/white/red and black/white/gray. This will be factory set
755    /// during the flashing and testing phase. The value is saved in
756    /// non-volatile memory and will stay after a power cycle.
757    ///
758    /// Associated constants:
759    /// * E_PAPER_296X128_BRICKLET_DISPLAY_TYPE_BLACK_WHITE_RED
760    ///	* E_PAPER_296X128_BRICKLET_DISPLAY_TYPE_BLACK_WHITE_GRAY
761    pub async fn set_display_type(&mut self, display_type: u8) -> Result<(), TinkerforgeError> {
762        let mut payload = [0; 1];
763        display_type.write_to_slice(&mut payload[0..1]);
764
765        #[allow(unused_variables)]
766        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::SetDisplayType), &payload).await?;
767        Ok(())
768    }
769
770    /// Returns the type of the e-paper display. It can either be
771    /// black/white/red or black/white/gray.
772    ///
773    /// Associated constants:
774    /// * E_PAPER_296X128_BRICKLET_DISPLAY_TYPE_BLACK_WHITE_RED
775    ///	* E_PAPER_296X128_BRICKLET_DISPLAY_TYPE_BLACK_WHITE_GRAY
776    pub async fn get_display_type(&mut self) -> Result<u8, TinkerforgeError> {
777        let payload = [0; 0];
778
779        #[allow(unused_variables)]
780        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::GetDisplayType), &payload).await?;
781        Ok(u8::from_le_byte_slice(result.body()))
782    }
783
784    /// Sets the type of display driver. The Bricklet can currently support
785    /// SSD1675A and SSD1680. This will be factory set
786    /// during the flashing and testing phase. The value is saved in
787    /// non-volatile memory and will stay after a power cycle.
788    ///
789    ///
790    /// .. versionadded:: 2.0.3$nbsp;(Plugin)
791    ///
792    /// Associated constants:
793    /// * E_PAPER_296X128_BRICKLET_DISPLAY_DRIVER_SSD1675A
794    ///	* E_PAPER_296X128_BRICKLET_DISPLAY_DRIVER_SSD1680
795    pub async fn set_display_driver(&mut self, display_driver: u8) -> Result<(), TinkerforgeError> {
796        let mut payload = [0; 1];
797        display_driver.write_to_slice(&mut payload[0..1]);
798
799        #[allow(unused_variables)]
800        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::SetDisplayDriver), &payload).await?;
801        Ok(())
802    }
803
804    /// Returns the e-paper display driver.
805    ///
806    ///
807    /// .. versionadded:: 2.0.3$nbsp;(Plugin)
808    ///
809    /// Associated constants:
810    /// * E_PAPER_296X128_BRICKLET_DISPLAY_DRIVER_SSD1675A
811    ///	* E_PAPER_296X128_BRICKLET_DISPLAY_DRIVER_SSD1680
812    pub async fn get_display_driver(&mut self) -> Result<u8, TinkerforgeError> {
813        let payload = [0; 0];
814
815        #[allow(unused_variables)]
816        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::GetDisplayDriver), &payload).await?;
817        Ok(u8::from_le_byte_slice(result.body()))
818    }
819
820    /// Returns the error count for the communication between Brick and Bricklet.
821    ///
822    /// The errors are divided into
823    ///
824    /// * ACK checksum errors,
825    /// * message checksum errors,
826    /// * framing errors and
827    /// * overflow errors.
828    ///
829    /// The errors counts are for errors that occur on the Bricklet side. All
830    /// Bricks have a similar function that returns the errors on the Brick side.
831    pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
832        let payload = [0; 0];
833
834        #[allow(unused_variables)]
835        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::GetSpitfpErrorCount), &payload).await?;
836        Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
837    }
838
839    /// Sets the bootloader mode and returns the status after the requested
840    /// mode change was instigated.
841    ///
842    /// You can change from bootloader mode to firmware mode and vice versa. A change
843    /// from bootloader mode to firmware mode will only take place if the entry function,
844    /// device identifier and CRC are present and correct.
845    ///
846    /// This function is used by Brick Viewer during flashing. It should not be
847    /// necessary to call it in a normal user program.
848    ///
849    /// Associated constants:
850    /// * E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
851    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_FIRMWARE
852    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
853    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
854    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
855    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_OK
856    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE
857    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE
858    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT
859    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT
860    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH
861    pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
862        let mut payload = [0; 1];
863        mode.write_to_slice(&mut payload[0..1]);
864
865        #[allow(unused_variables)]
866        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::SetBootloaderMode), &payload).await?;
867        Ok(u8::from_le_byte_slice(result.body()))
868    }
869
870    /// Returns the current bootloader mode, see [`set_bootloader_mode`].
871    ///
872    /// Associated constants:
873    /// * E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
874    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_FIRMWARE
875    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
876    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
877    ///	* E_PAPER_296X128_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
878    pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
879        let payload = [0; 0];
880
881        #[allow(unused_variables)]
882        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::GetBootloaderMode), &payload).await?;
883        Ok(u8::from_le_byte_slice(result.body()))
884    }
885
886    /// Sets the firmware pointer for [`write_firmware`]. The pointer has
887    /// to be increased by chunks of size 64. The data is written to flash
888    /// every 4 chunks (which equals to one page of size 256).
889    ///
890    /// This function is used by Brick Viewer during flashing. It should not be
891    /// necessary to call it in a normal user program.
892    pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
893        let mut payload = [0; 4];
894        pointer.write_to_slice(&mut payload[0..4]);
895
896        #[allow(unused_variables)]
897        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::SetWriteFirmwarePointer), &payload).await?;
898        Ok(())
899    }
900
901    /// Writes 64 Bytes of firmware at the position as written by
902    /// [`set_write_firmware_pointer`] before. The firmware is written
903    /// to flash every 4 chunks.
904    ///
905    /// You can only write firmware in bootloader mode.
906    ///
907    /// This function is used by Brick Viewer during flashing. It should not be
908    /// necessary to call it in a normal user program.
909    pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
910        let mut payload = [0; 64];
911        data.write_to_slice(&mut payload[0..64]);
912
913        #[allow(unused_variables)]
914        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::WriteFirmware), &payload).await?;
915        Ok(u8::from_le_byte_slice(result.body()))
916    }
917
918    /// Sets the status LED configuration. By default the LED shows
919    /// communication traffic between Brick and Bricklet, it flickers once
920    /// for every 10 received data packets.
921    ///
922    /// You can also turn the LED permanently on/off or show a heartbeat.
923    ///
924    /// If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
925    ///
926    /// Associated constants:
927    /// * E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_OFF
928    ///	* E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_ON
929    ///	* E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
930    ///	* E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
931    pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
932        let mut payload = [0; 1];
933        config.write_to_slice(&mut payload[0..1]);
934
935        #[allow(unused_variables)]
936        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::SetStatusLedConfig), &payload).await?;
937        Ok(())
938    }
939
940    /// Returns the configuration as set by [`set_status_led_config`]
941    ///
942    /// Associated constants:
943    /// * E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_OFF
944    ///	* E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_ON
945    ///	* E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
946    ///	* E_PAPER_296X128_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
947    pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
948        let payload = [0; 0];
949
950        #[allow(unused_variables)]
951        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::GetStatusLedConfig), &payload).await?;
952        Ok(u8::from_le_byte_slice(result.body()))
953    }
954
955    /// Returns the temperature as measured inside the microcontroller. The
956    /// value returned is not the ambient temperature!
957    ///
958    /// The temperature is only proportional to the real temperature and it has bad
959    /// accuracy. Practically it is only useful as an indicator for
960    /// temperature changes.
961    pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
962        let payload = [0; 0];
963
964        #[allow(unused_variables)]
965        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::GetChipTemperature), &payload).await?;
966        Ok(i16::from_le_byte_slice(result.body()))
967    }
968
969    /// Calling this function will reset the Bricklet. All configurations
970    /// will be lost.
971    ///
972    /// After a reset you have to create new device objects,
973    /// calling functions on the existing ones will result in
974    /// undefined behavior!
975    pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
976        let payload = [0; 0];
977
978        #[allow(unused_variables)]
979        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::Reset), &payload).await?;
980        Ok(())
981    }
982
983    /// Writes a new UID into flash. If you want to set a new UID
984    /// you have to decode the Base58 encoded UID string into an
985    /// integer first.
986    ///
987    /// We recommend that you use Brick Viewer to change the UID.
988    pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
989        let mut payload = [0; 4];
990        uid.write_to_slice(&mut payload[0..4]);
991
992        #[allow(unused_variables)]
993        let result = self.device.set(u8::from(EPaper296x128BrickletFunction::WriteUid), &payload).await?;
994        Ok(())
995    }
996
997    /// Returns the current UID as an integer. Encode as
998    /// Base58 to get the usual string version.
999    pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
1000        let payload = [0; 0];
1001
1002        #[allow(unused_variables)]
1003        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::ReadUid), &payload).await?;
1004        Ok(u32::from_le_byte_slice(result.body()))
1005    }
1006
1007    /// Returns the UID, the UID where the Bricklet is connected to,
1008    /// the position, the hardware and firmware version as well as the
1009    /// device identifier.
1010    ///
1011    /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
1012    /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
1013    /// position 'z'.
1014    ///
1015    /// The device identifier numbers can be found [here](device_identifier).
1016    /// |device_identifier_constant|
1017    pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
1018        let payload = [0; 0];
1019
1020        #[allow(unused_variables)]
1021        let result = self.device.get(u8::from(EPaper296x128BrickletFunction::GetIdentity), &payload).await?;
1022        Ok(Identity::from_le_byte_slice(result.body()))
1023    }
1024}