From 7bf1ac0cae3b1867b4687efaf1ccbd9e321df54b Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Sat, 18 Apr 2020 23:11:52 +0200 Subject: [PATCH] Update display label in demo app --- examples/demo/src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/demo/src/main.rs b/examples/demo/src/main.rs index 3aee305..f06bf3a 100644 --- a/examples/demo/src/main.rs +++ b/examples/demo/src/main.rs @@ -103,8 +103,9 @@ fn main() -> Result<(), String> { power.set_align(&mut screen, lvgl::Align::InTopRight, 0, 0); let mut event_pump = sdl_context.event_pump()?; + let mut i = 0; 'running: loop { - for event in event_pump.poll_iter() { + if let Some(event) = event_pump.poll_event() { match event { Event::Quit { .. } | Event::KeyDown { @@ -117,12 +118,17 @@ fn main() -> Result<(), String> { } } - ::std::thread::sleep(Duration::from_millis( - lvgl_sys::LV_DISP_DEF_REFR_PERIOD as u64, - )); + if i > 59 { + i = 0; + } + time.set_text(format!("21:{:02}\0", i).as_str()); + i = 1 + i; + + ::std::thread::sleep(Duration::from_millis(10)); unsafe { lvgl_sys::lv_task_handler(); + lvgl_sys::lv_tick_inc(10); } }