Rust bindings API review #51
|
@ -7,9 +7,10 @@ use lvgl::display::{Display, DisplayBuffer, DisplayDriver};
|
||||||
type ColorSpace = Rgb565;
|
type ColorSpace = Rgb565;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut embedded_graphics_display: SimulatorDisplay<ColorSpace> = SimulatorDisplay::new(
|
let embedded_graphics_display: SimulatorDisplay<ColorSpace> = SimulatorDisplay::new(Size::new(
|
||||||
Size::new(lvgl_sys::LV_HOR_RES_MAX, lvgl_sys::LV_VER_RES_MAX),
|
lvgl_sys::LV_HOR_RES_MAX,
|
||||||
);
|
lvgl_sys::LV_VER_RES_MAX,
|
||||||
|
));
|
||||||
|
|
||||||
let output_settings = OutputSettingsBuilder::new().scale(2).build();
|
let output_settings = OutputSettingsBuilder::new().scale(2).build();
|
||||||
let mut window = Window::new("App Example", &output_settings);
|
let mut window = Window::new("App Example", &output_settings);
|
||||||
|
@ -17,10 +18,6 @@ fn main() {
|
||||||
// LVGL usage
|
// LVGL usage
|
||||||
lvgl::init();
|
lvgl::init();
|
||||||
|
|
||||||
let mut display_diver: DisplayDriver<ColorSpace> =
|
let mut display_diver = DisplayDriver::new(DisplayBuffer::new(), embedded_graphics_display);
|
||||||
DisplayDriver::new(DisplayBuffer::new(), |pixels| {
|
let gui = lvgl::disp_drv_register(&mut display_diver).unwrap();
|
||||||
// Here we draw to the external display
|
|
||||||
let _ = embedded_graphics_display.draw_iter(pixels);
|
|
||||||
});
|
|
||||||
let _display = lvgl::disp_drv_register(&mut display_diver).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ const REFRESH_BUFFER_LEN: usize = 2;
|
||||||
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
// Declare a buffer for the refresh rate
|
// Declare a buffer for the refresh rate
|
||||||
pub(crate) const BUF_SIZE: usize = lvgl_sys::LV_HOR_RES_MAX as usize * REFRESH_BUFFER_LEN;
|
pub(crate) const BUF_SIZE: usize = lvgl_sys::LV_HOR_RES_MAX as usize * REFRESH_BUFFER_LEN;
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
pub enum DisplayError {
|
pub enum DisplayError {
|
||||||
FailedToRegister,
|
FailedToRegister,
|
||||||
NotRegistered,
|
NotRegistered,
|
||||||
|
@ -61,67 +62,64 @@ impl DisplayBuffer {
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct DisplayDriver<C>
|
pub struct DisplayDriver<T, C>
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
where
|
where
|
||||||
|
T: DrawTarget<C>,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
I'm using a Mutex here just to make this I'm using a Mutex here just to make this `Sync`, not sure if there is a way to remove it but still keep the memory statically allocated.
|
|||||||
C: PixelColor + From<Color>,
|
C: PixelColor + From<Color>,
|
||||||
{
|
{
|
||||||
pub(crate) disp_drv: lvgl_sys::lv_disp_drv_t,
|
pub(crate) disp_drv: lvgl_sys::lv_disp_drv_t,
|
||||||
phantom: PhantomData<C>,
|
phantom_display: PhantomData<T>,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
phantom_color: PhantomData<C>,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<C> DisplayDriver<C>
|
impl<T, C> DisplayDriver<T, C>
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
where
|
where
|
||||||
|
T: DrawTarget<C>,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
C: PixelColor + From<Color>,
|
C: PixelColor + From<Color>,
|
||||||
{
|
{
|
||||||
pub fn new<I, F>(display_buffer: DisplayBuffer, callback: F) -> Self
|
pub fn new(display_buffer: DisplayBuffer, native_display: T) -> Self {
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
where
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
I: IntoIterator<Item = drawable::Pixel<C>>,
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
F: FnMut(I) + 'static,
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
{
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
let mut disp_buf = ManuallyDrop::new(display_buffer.disp_buf);
|
let mut disp_buf = ManuallyDrop::new(display_buffer.disp_buf);
|
||||||
let mut callback = ManuallyDrop::new(callback);
|
let mut native_display = ManuallyDrop::new(DisplayUserData {
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
display: native_display,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
I would like to find a way to make this memory statically allocated. This seems to be a requirement for LVGL v8. I would like to find a way to make this memory statically allocated. This seems to be [a requirement for LVGL v8](https://docs.lvgl.io/8.0/get-started/quick-overview.html#add-lvgl-into-your-project).
|
|||||||
|
phantom: PhantomData,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
});
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
let mut disp_drv = unsafe {
|
let mut disp_drv = unsafe {
|
||||||
let mut disp_drv = MaybeUninit::uninit();
|
let mut disp_drv = MaybeUninit::uninit();
|
||||||
lvgl_sys::lv_disp_drv_init(disp_drv.as_mut_ptr());
|
lvgl_sys::lv_disp_drv_init(disp_drv.as_mut_ptr());
|
||||||
disp_drv.assume_init()
|
disp_drv.assume_init()
|
||||||
};
|
};
|
||||||
disp_drv.buffer = &mut *disp_buf as *mut lvgl_sys::lv_disp_buf_t;
|
disp_drv.buffer = &mut *disp_buf as *mut lvgl_sys::lv_disp_buf_t;
|
||||||
disp_drv.user_data = &mut callback as *mut _ as lvgl_sys::lv_disp_drv_user_data_t;
|
disp_drv.user_data = &mut native_display as *mut _ as lvgl_sys::lv_disp_drv_user_data_t;
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
disp_drv.flush_cb = Some(disp_flush_trampoline::<C, I, F>);
|
disp_drv.flush_cb = Some(disp_flush_trampoline::<T, C>);
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
disp_drv,
|
disp_drv,
|
||||||
phantom: PhantomData,
|
phantom_color: PhantomData,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
phantom_display: PhantomData,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl Default for DisplayDriver {
|
pub(crate) struct DisplayUserData<T, C>
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
// fn default() -> Self {
|
where
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
// Self::new(DisplayBuffer::new())
|
T: DrawTarget<C>,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
// }
|
C: PixelColor + From<Color>,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
// }
|
{
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
display: T,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
pub struct DisplayDriverBuilder {
|
phantom: PhantomData<C>,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
disp_buf: Option<DisplayBuffer>,
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DisplayDriverBuilder {
|
unsafe extern "C" fn disp_flush_trampoline<T, C>(
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
pub fn with_callback() {}
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
}
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
unsafe extern "C" fn disp_flush_trampoline<C, I, F>(
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
disp_drv: *mut lvgl_sys::lv_disp_drv_t,
|
disp_drv: *mut lvgl_sys::lv_disp_drv_t,
|
||||||
area: *const lvgl_sys::lv_area_t,
|
area: *const lvgl_sys::lv_area_t,
|
||||||
color_p: *mut lvgl_sys::lv_color_t,
|
color_p: *mut lvgl_sys::lv_color_t,
|
||||||
) where
|
) where
|
||||||
|
T: DrawTarget<C>,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
C: PixelColor + From<Color>,
|
C: PixelColor + From<Color>,
|
||||||
I: IntoIterator<Item = drawable::Pixel<C>>,
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
F: FnMut(I) + 'static,
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
{
|
{
|
||||||
let display_driver = *disp_drv;
|
let display_driver = *disp_drv;
|
||||||
if !display_driver.user_data.is_null() {
|
if !display_driver.user_data.is_null() {
|
||||||
let callback = &mut *(display_driver.user_data as *mut F);
|
let user_data = &mut *(display_driver.user_data as *mut DisplayUserData<T, C>);
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
let x1 = (*area).x1;
|
let x1 = (*area).x1;
|
||||||
let x2 = (*area).x2;
|
let x2 = (*area).x2;
|
||||||
let y1 = (*area).y1;
|
let y1 = (*area).y1;
|
||||||
|
@ -140,11 +138,25 @@ unsafe extern "C" fn disp_flush_trampoline<C, I, F>(
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
let color_len = x_len * iy + ix;
|
let color_len = x_len * iy + ix;
|
||||||
let lv_color = unsafe { *color_p.add(color_len) };
|
let lv_color = unsafe { *color_p.add(color_len) };
|
||||||
let raw_color = Color::from_raw(lv_color);
|
let raw_color = Color::from_raw(lv_color);
|
||||||
drawable::Pixel(Point::new(x as i32, y as i32), raw_color.into())
|
drawable::Pixel::<C>(Point::new(x as i32, y as i32), raw_color.into())
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.flatten();
|
.flatten();
|
||||||
|
|
||||||
callback(pixels);
|
let _ = user_data.display.draw_iter(pixels);
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
// impl Default for DisplayDriver {
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
// fn default() -> Self {
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
// Self::new(DisplayBuffer::new())
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
// }
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
// }
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
pub struct DisplayDriverBuilder {
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
disp_buf: Option<DisplayBuffer>,
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
}
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
impl DisplayDriverBuilder {
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
pub fn with_callback() {}
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
}
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|||||||
|
|
||||||
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
TODO: Remove this code duplication. TODO: Remove this code duplication.
I use a I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
|
|
@ -4,8 +4,8 @@ use core::ptr::NonNull;
|
||||||
use embedded_graphics::drawable;
|
use embedded_graphics::drawable;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
|
|
||||||
pub fn disp_drv_register<C: PixelColor + From<Color>>(
|
pub fn disp_drv_register<C: PixelColor + From<Color>, T: DrawTarget<C>>(
|
||||||
disp_drv: &mut DisplayDriver<C>,
|
disp_drv: &mut DisplayDriver<T, C>,
|
||||||
) -> Result<Display, DisplayError> {
|
) -> Result<Display, DisplayError> {
|
||||||
let disp_ptr = unsafe {
|
let disp_ptr = unsafe {
|
||||||
lvgl_sys::lv_disp_drv_register(&mut disp_drv.disp_drv as *mut lvgl_sys::lv_disp_drv_t)
|
lvgl_sys::lv_disp_drv_register(&mut disp_drv.disp_drv as *mut lvgl_sys::lv_disp_drv_t)
|
||||||
|
|
TODO: Remove this code duplication.