Touch input device #27

Open
rafaelcaricio wants to merge 15 commits from indev into master
Showing only changes of commit 42ae30700a - Show all commits

View file

@ -27,6 +27,24 @@ impl Color {
pub fn from_raw(raw: lvgl_sys::lv_color_t) -> Self {
Self { raw }
}
pub fn r(&self) -> u8 {
unsafe {
lvgl_sys::_LV_COLOR_GET_R(self.raw) as u8
}
}
pub fn g(&self) -> u8 {
unsafe {
lvgl_sys::_LV_COLOR_GET_G(self.raw) as u8
}
}
pub fn b(&self) -> u8 {
unsafe {
lvgl_sys::_LV_COLOR_GET_B(self.raw) as u8
}
}
}
impl From<Color> for Rgb888 {
@ -233,3 +251,25 @@ impl From<Animation> for lvgl_sys::lv_anim_enable_t {
}
}
}
#[cfg(test)]
mod test {
use super::*;
use lvgl_sys;
#[test]
fn color_properties_accessible() {
let color = Color::from_rgb((206, 51, 255));
if lvgl_sys::LV_COLOR_DEPTH == 32 {
assert_eq!(color.r(), 206);
assert_eq!(color.g(), 51);
assert_eq!(color.b(), 255);
} else if lvgl_sys::LV_COLOR_DEPTH == 16 {
assert_eq!(color.r(), 25);
assert_eq!(color.g(), 12);
assert_eq!(color.b(), 31);
}
}
}