Fix test
This commit is contained in:
parent
dc0e2f947a
commit
7781c12809
2 changed files with 19 additions and 8 deletions
|
@ -123,7 +123,7 @@ where
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::{Color, UI};
|
||||
use crate::UI;
|
||||
use core::marker::PhantomData;
|
||||
use embedded_graphics::drawable::Pixel;
|
||||
use embedded_graphics::geometry::Size;
|
||||
|
@ -133,14 +133,14 @@ mod test {
|
|||
|
||||
struct FakeDisplay<C>
|
||||
where
|
||||
C: PixelColor + From<Color>,
|
||||
C: PixelColor,
|
||||
{
|
||||
p: PhantomData<C>,
|
||||
}
|
||||
|
||||
impl<C> DrawTarget<C> for FakeDisplay<C>
|
||||
where
|
||||
C: PixelColor + From<Color>,
|
||||
C: PixelColor,
|
||||
{
|
||||
type Error = ();
|
||||
|
||||
|
@ -161,14 +161,13 @@ mod test {
|
|||
|
||||
let disp: FakeDisplay<Rgb565> = FakeDisplay { p: PhantomData };
|
||||
|
||||
ui.disp_drv_register(disp);
|
||||
ui.disp_drv_register(disp)?;
|
||||
|
||||
fn read_touchpad_device() -> Point {
|
||||
Point::new(120, 23)
|
||||
fn read_touchpad_device() -> BufferStatus {
|
||||
InputData::Touch(Point::new(120, 23)).pressed().once()
|
||||
}
|
||||
|
||||
let mut touch_screen =
|
||||
Pointer::new(|| InputData::Touch(read_touchpad_device()).pressed().once());
|
||||
let mut touch_screen = Pointer::new(|| read_touchpad_device());
|
||||
|
||||
ui.indev_drv_register(&mut touch_screen)?;
|
||||
|
||||
|
|
|
@ -58,6 +58,18 @@ where
|
|||
}
|
||||
|
||||
pub fn indev_drv_register(&mut self, input_device: &mut Pointer) -> LvResult<()> {
|
||||
if self.display_data.is_none() {
|
||||
// TODO: Better yet would be to create a display struct that one register the
|
||||
// input device in that instance. Represents better the LVGL correct usage. Also it's
|
||||
// inline with unrepresentable invalid states using Rust type system.
|
||||
// ```rust
|
||||
// let disp = ui.disp_drv_register(embed_graph_disp)?;
|
||||
// disp.indev_drv_register(disp);
|
||||
// ...
|
||||
// window.update(&disp)
|
||||
// ```
|
||||
return Err(LvError::Uninitialized);
|
||||
}
|
||||
unsafe {
|
||||
let descr = lvgl_sys::lv_indev_drv_register(&mut input_device.driver as *mut _);
|
||||
input_device.set_descriptor(descr)?;
|
||||
|
|
Loading…
Reference in a new issue