Rust bindings API review #51
|
@ -21,6 +21,7 @@ parking_lot = "0.11.1"
|
||||||
heapless = "0.7.1"
|
heapless = "0.7.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
default = []
|
||||||
alloc = ["cstr_core/alloc"]
|
alloc = ["cstr_core/alloc"]
|
||||||
lvgl_alloc = ["alloc"]
|
lvgl_alloc = ["alloc"]
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,9 @@ impl<const N: usize> DrawBuffer<N> {
|
||||||
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 get_ptr(&self) -> Option<Box<lvgl_sys::lv_disp_buf_t>> {
|
fn get_ptr(&self) -> Option<Box<lvgl_sys::lv_disp_buf_t>> {
|
||||||
if self.initialized.swap_and_check() {
|
if self.initialized.swap_and_check() {
|
||||||
|
// TODO: needs to be 'static somehow
|
||||||
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.
|
|||||||
|
// Cannot be in the DrawBuffer struct because the type `lv_disp_buf_t` contains a raw
|
||||||
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.
|
|||||||
|
// pointer and raw pointers are not Sync and consequently cannot be in `static` variables.
|
||||||
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 inner: MaybeUninit<lvgl_sys::lv_disp_buf_t> = MaybeUninit::uninit();
|
let mut inner: MaybeUninit<lvgl_sys::lv_disp_buf_t> = MaybeUninit::uninit();
|
||||||
let primary_buffer_guard = self.refresh_buffer.lock();
|
let primary_buffer_guard = self.refresh_buffer.lock();
|
||||||
let draw_buf = unsafe {
|
let draw_buf = unsafe {
|
||||||
|
|
||||||
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.
|
|
@ -14,7 +14,7 @@ pub enum CoreError {
|
||||||
type Result<T> = result::Result<T, CoreError>;
|
type Result<T> = result::Result<T, CoreError>;
|
||||||
|
|
||||||
/// Register own buffer
|
/// Register own buffer
|
||||||
pub fn disp_drv_register<C: PixelColor + From<Color>, T: DrawTarget<C>>(
|
pub(crate) fn disp_drv_register<C: PixelColor + From<Color>, T: DrawTarget<C>>(
|
||||||
disp_drv: &mut DisplayDriver<T, C>,
|
disp_drv: &mut DisplayDriver<T, C>,
|
||||||
) -> Result<Display> {
|
) -> Result<Display> {
|
||||||
let disp_ptr = unsafe { lvgl_sys::lv_disp_drv_register(&mut disp_drv.disp_drv as *mut _) };
|
let disp_ptr = unsafe { lvgl_sys::lv_disp_drv_register(&mut disp_drv.disp_drv as *mut _) };
|
||||||
|
|
TODO: Remove this code duplication.