Skip to content

Commit

Permalink
redraw at 1s interval
Browse files Browse the repository at this point in the history
  • Loading branch information
galister committed Apr 15, 2024
1 parent 8b81fd5 commit d999f95
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/backend/uidev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pub fn uidev_run(panel_name: &str) -> anyhow::Result<()> {
let watch_path = config_io::CONFIG_ROOT_PATH.join(format!("{}.yaml", panel_name));
let mut path_last_modified = watch_path.metadata()?.modified()?;
let mut recreate = false;
let mut last_draw = std::time::Instant::now();

event_loop.run(move |event, elwt| {
elwt.set_control_flow(ControlFlow::Poll);
Expand Down Expand Up @@ -190,6 +191,7 @@ pub fn uidev_run(panel_name: &str) -> anyhow::Result<()> {
window.request_redraw();
}
cmd_buf.end_rendering().unwrap();
last_draw = std::time::Instant::now();

let command_buffer = cmd_buf.build().unwrap();
let future = previous_frame_end
Expand Down Expand Up @@ -223,6 +225,11 @@ pub fn uidev_run(panel_name: &str) -> anyhow::Result<()> {
}
}
}
Event::AboutToWait => {
if last_draw.elapsed().as_secs() > 1 {
window.request_redraw();
}
}
_ => (),
}
})?;
Expand Down

0 comments on commit d999f95

Please sign in to comment.