lcd_async/dcs/
set_invert_mode.rs1use crate::options::ColorInversion;
2
3use super::DcsCommand;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct SetInvertMode(ColorInversion);
8
9impl SetInvertMode {
10 pub fn new(color_inversion: ColorInversion) -> Self {
12 SetInvertMode(color_inversion)
13 }
14}
15
16impl DcsCommand for SetInvertMode {
17 fn instruction(&self) -> u8 {
18 match self.0 {
19 ColorInversion::Normal => 0x20,
20 ColorInversion::Inverted => 0x21,
21 }
22 }
23
24 fn fill_params_buf(&self, _buffer: &mut [u8]) -> usize {
25 0
26 }
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn set_invert_mode_chooses_correct_instruction() {
35 let ste = SetInvertMode(ColorInversion::Inverted);
36
37 let mut buffer = [0u8; 0];
38 assert_eq!(ste.instruction(), 0x21);
39 assert_eq!(ste.fill_params_buf(&mut buffer), 0);
40 }
41}