tasks: safetyui: re-add waiting for the renderer before starting up
This commit is contained in:
@@ -6,7 +6,7 @@ use rgb::Rgba;
|
|||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use log::*;
|
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)]
|
#[derive(Debug)]
|
||||||
pub struct SafetyUi<S: Surface> {
|
pub struct SafetyUi<S: Surface> {
|
||||||
@@ -48,7 +48,7 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
|
|||||||
pub async fn sleep(&mut self) {
|
pub async fn sleep(&mut self) {
|
||||||
info!("Running sleep sequence");
|
info!("Running sleep sequence");
|
||||||
let mut disp_anim = AnimDisplay(&mut self.display);
|
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");
|
warn!("Resetting safety lights");
|
||||||
self.brakelight.set_visible(false);
|
self.brakelight.set_visible(false);
|
||||||
@@ -57,8 +57,7 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
|
|||||||
warn!("Turning off display");
|
warn!("Turning off display");
|
||||||
self.display.set_on(false);
|
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.
|
// 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.wait_until_render_is_running().await;
|
||||||
//self.display.render_is_running.wait().await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn wake(&mut self) {
|
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_brightness(Fract8::MIN);
|
||||||
self.display.set_on(true);
|
self.display.set_on(true);
|
||||||
// Wait for the renderer to start running again
|
// Wait for the renderer to start running again
|
||||||
// FIXME: This deadlocks :(
|
self.display.wait_until_render_is_running().await;
|
||||||
//self.display.render_is_running.wait().await;
|
|
||||||
|
|
||||||
trace!("Fading in brightness with overlay={:?}", self.overlay);
|
trace!("Fading in brightness with overlay={:?}", self.overlay);
|
||||||
self.overlay.set_opacity(Fract8::MAX);
|
self.overlay.set_opacity(Fract8::MAX);
|
||||||
@@ -128,12 +126,6 @@ const TURN_ON_SLOW: Animation<Fract8> = Animation::new().duration(Duration::from
|
|||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn safety_ui_main(mut events: DynSubscriber<'static, Prediction>, mut ui: SafetyUi<<UiSurfacePool as Surfaces>::Surface>) {
|
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
|
// Run the wake sequence, and turn on the lights
|
||||||
ui.wake().await;
|
ui.wake().await;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user