tasks: safetyui: re-add waiting for the renderer before starting up

This commit is contained in:
2026-03-09 10:25:09 +01:00
parent 74d753e0b3
commit 45d84a91dc

View File

@@ -6,7 +6,7 @@ use rgb::Rgba;
use core::fmt::Debug;
use log::*;
use crate::{animation::{AnimDisplay, AnimatedSurface, Animation}, events::{Personality, Prediction}, graphics::{display::{DisplayControls, SegmentSpace, Uniforms}, shaders::*}, tasks::ui::UiSurfacePool};
use crate::{animation::{AnimDisplay, AnimatedSurface, Animation}, events::{Personality, Prediction}, graphics::{display::{DEFAULT_FPS, DisplayControls, LOW_POWER_FPS, SegmentSpace, Uniforms}, shaders::*}, tasks::ui::UiSurfacePool};
#[derive(Debug)]
pub struct SafetyUi<S: Surface> {
@@ -48,7 +48,7 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
pub async fn sleep(&mut self) {
info!("Running sleep sequence");
let mut disp_anim = AnimDisplay(&mut self.display);
TURN_OFF.apply([&mut disp_anim]).await;
TURN_OFF_FAST.apply([&mut disp_anim]).await;
warn!("Resetting safety lights");
self.brakelight.set_visible(false);
@@ -57,8 +57,7 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
warn!("Turning off display");
self.display.set_on(false);
// Wait for the display hardware to actually turn off, before we return to process the next event, which could cause funky behaviors.
// FIXME: also deadlocks :(
//self.display.render_is_running.wait().await;
self.display.wait_until_render_is_running().await;
}
pub async fn wake(&mut self) {
@@ -69,8 +68,7 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
self.display.set_brightness(Fract8::MIN);
self.display.set_on(true);
// Wait for the renderer to start running again
// FIXME: This deadlocks :(
//self.display.render_is_running.wait().await;
self.display.wait_until_render_is_running().await;
trace!("Fading in brightness with overlay={:?}", self.overlay);
self.overlay.set_opacity(Fract8::MAX);
@@ -128,12 +126,6 @@ const TURN_ON_SLOW: Animation<Fract8> = Animation::new().duration(Duration::from
#[embassy_executor::task]
pub async fn safety_ui_main(mut events: DynSubscriber<'static, Prediction>, mut ui: SafetyUi<<UiSurfacePool as Surfaces>::Surface>) {
// Wait for the renderer to start running
//ui.display.render_is_running.wait().await;
trace!("spooling until render starts ui={ui:?}");
ui.display.wait_until_render_is_running().await;
trace!("spooling wait task ui={ui:?}");
// Run the wake sequence, and turn on the lights
ui.wake().await;