Graphics/Color/
RGB888.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use crate::LVGL;

#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Color_RGB888_type {
    Red: u8,
    Green: u8,
    Blue: u8,
}

impl Color_RGB888_type {
    pub const White: Color_RGB888_type = Color_RGB888_type::New(0xFF, 0xFF, 0xFF);
    pub const Black: Color_RGB888_type = Color_RGB888_type::New(0x00, 0x00, 0x00);

    pub const fn New(Red: u8, Green: u8, Blue: u8) -> Self {
        Self { Red, Green, Blue }
    }

    pub const fn Get_red(&self) -> u8 {
        self.Red
    }

    pub const fn Get_green(&self) -> u8 {
        self.Green
    }

    pub const fn Get_blue(&self) -> u8 {
        self.Blue
    }

    pub const fn Set_red(mut self, Value: u8) -> Self {
        self.Red = Value;
        self
    }

    pub const fn Set_green(mut self, Value: u8) -> Self {
        self.Green = Value;
        self
    }

    pub const fn Set_blue(mut self, Value: u8) -> Self {
        self.Blue = Value;
        self
    }

    pub const fn From_LVGL_color(Value: LVGL::lv_color_t) -> Self {
        Self::New(Value.red, Value.green, Value.blue)
    }

    pub const fn Into_LVGL_color(self) -> LVGL::lv_color_t {
        LVGL::lv_color_t {
            red: self.Get_red(),
            green: self.Get_green(),
            blue: self.Get_blue(),
        }
    }
}

impl From<Color_RGB888_type> for LVGL::lv_color_t {
    fn from(Value: Color_RGB888_type) -> Self {
        Value.Into_LVGL_color()
    }
}

impl From<LVGL::lv_color_t> for Color_RGB888_type {
    fn from(Value: LVGL::lv_color_t) -> Self {
        Color_RGB888_type::From_LVGL_color(Value)
    }
}