tasks: safetyui: move one more animator into a global const

This commit is contained in:
2026-03-09 10:12:36 +01:00
parent 6c43d9f2b7
commit 561fef0ed1

View File

@@ -72,21 +72,20 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
// FIXME: This deadlocks :(
//self.display.render_is_running.wait().await;
let fade_in = Animation::default().duration(Duration::from_secs(3)).from(Fract8::MIN).to(Fract8::MAX);
trace!("Fading in brightness with overlay={:?}", self.overlay);
self.overlay.set_opacity(Fract8::MAX);
self.overlay.set_visible(true);
fade_in.apply([&mut AnimDisplay(&mut self.display)]).await;
TURN_ON_SLOW.apply([&mut AnimDisplay(&mut self.display)]).await;
warn!("Turning on safety lights");
self.headlight.set_opacity(Fract8::MIN);
self.headlight.set_visible(true);
self.brakelight.set_opacity(Fract8::MIN);
self.brakelight.set_visible(true);
fade_in.apply([&mut self.headlight, &mut self.brakelight]).await;
TURN_ON_SLOW.apply([&mut self.headlight, &mut self.brakelight]).await;
info!("Fade out overlay");
TURN_OFF.apply([&mut self.overlay]).await;
TURN_OFF_FAST.apply([&mut self.overlay]).await;
self.overlay.set_visible(false);
info!("Wakeup complete!");
}
@@ -96,14 +95,14 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
Personality::Active => {
// FIXME: These should be a Off/Low/High enum, so the stopping brake looks different from the dayrunning brake.
warn!("Active personality: Turning on safety lights");
TURN_ON.apply([
TURN_ON_FAST.apply([
&mut self.brakelight,
&mut self.headlight
]).await;
},
Personality::Parked => {
warn!("Idle personality: Turning off safety lights");
TURN_OFF.apply([
TURN_OFF_FAST.apply([
&mut self.brakelight,
&mut self.headlight
]).await;
@@ -120,8 +119,9 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
}
}
const TURN_ON: Animation<Fract8> = Animation::new().duration(Duration::from_secs(1)).from(Fract8::MIN).to(Fract8::MAX);
const TURN_OFF: Animation<Fract8> = Animation::new().duration(Duration::from_secs(1)).from(Fract8::MAX).to(Fract8::MIN);
const TURN_ON_FAST: Animation<Fract8> = Animation::new().duration(Duration::from_secs(1)).from(Fract8::MIN).to(Fract8::MAX);
const TURN_OFF_FAST: Animation<Fract8> = Animation::new().duration(Duration::from_secs(1)).from(Fract8::MAX).to(Fract8::MIN);
const TURN_ON_SLOW: Animation<Fract8> = Animation::new().duration(Duration::from_secs(3)).from(Fract8::MIN).to(Fract8::MAX);
#[embassy_executor::task]
pub async fn safety_ui_main(mut events: DynSubscriber<'static, Prediction>, mut ui: SafetyUi<<UiSurfacePool as Surfaces>::Surface>) {