lcd_async/dcs/
set_scroll_start.rs1use super::DcsCommand;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8pub struct SetScrollStart(u16);
9
10impl SetScrollStart {
11 pub const fn new(offset: u16) -> Self {
13 Self(offset)
14 }
15}
16
17impl DcsCommand for SetScrollStart {
18 fn instruction(&self) -> u8 {
19 0x37
20 }
21
22 fn fill_params_buf(&self, buffer: &mut [u8]) -> usize {
23 let bytes = self.0.to_be_bytes();
24 buffer[0] = bytes[0];
25 buffer[1] = bytes[1];
26
27 2
28 }
29}
30
31#[cfg(test)]
32mod tests {
33 use super::*;
34
35 #[test]
36 fn vscad_fills_offset_properly() {
37 let vscad = SetScrollStart::new(320);
38
39 let mut buffer = [0u8; 2];
40 assert_eq!(vscad.fill_params_buf(&mut buffer), 2);
41 assert_eq!(buffer, [0x1, 0x40]);
42 }
43}