tasks: use new animations api
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use embassy_sync::pubsub::DynSubscriber;
|
||||
use embassy_time::Duration;
|
||||
use figments::prelude::*;
|
||||
use figments::{liber8tion::interpolate::Fract8, prelude::*};
|
||||
use figments_render::output::Brightness;
|
||||
use rgb::Rgba;
|
||||
use core::fmt::Debug;
|
||||
@@ -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.apply([&mut disp_anim]).await;
|
||||
|
||||
warn!("Resetting safety lights");
|
||||
self.brakelight.set_visible(false);
|
||||
@@ -76,20 +76,17 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
|
||||
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;
|
||||
fade_in.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);
|
||||
embassy_futures::join::join(
|
||||
fade_in.apply(&mut self.headlight),
|
||||
fade_in.apply(&mut self.brakelight)
|
||||
).await;
|
||||
fade_in.apply([&mut self.headlight, &mut self.brakelight]).await;
|
||||
|
||||
info!("Fade out overlay");
|
||||
TURN_OFF.apply(&mut self.overlay).await;
|
||||
TURN_OFF.apply([&mut self.overlay]).await;
|
||||
self.overlay.set_visible(false);
|
||||
info!("Wakeup complete!");
|
||||
}
|
||||
@@ -99,17 +96,17 @@ 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");
|
||||
embassy_futures::join::join(
|
||||
TURN_ON.apply(&mut self.brakelight),
|
||||
TURN_ON.apply(&mut self.headlight)
|
||||
).await;
|
||||
TURN_ON.apply([
|
||||
&mut self.brakelight,
|
||||
&mut self.headlight
|
||||
]).await;
|
||||
},
|
||||
Personality::Parked => {
|
||||
warn!("Idle personality: Turning off safety lights");
|
||||
embassy_futures::join::join(
|
||||
TURN_OFF.apply(&mut self.brakelight),
|
||||
TURN_OFF.apply(&mut self.headlight)
|
||||
).await;
|
||||
TURN_OFF.apply([
|
||||
&mut self.brakelight,
|
||||
&mut self.headlight
|
||||
]).await;
|
||||
},
|
||||
Personality::Sleeping => {
|
||||
warn!("Sleeping personality: Safety UI is going to sleep");
|
||||
@@ -127,7 +124,7 @@ const TURN_ON: Animation<Fract8> = Animation::new().duration(Duration::from_secs
|
||||
const TURN_OFF: Animation<Fract8> = Animation::new().duration(Duration::from_secs(1)).from(Fract8::MAX).to(Fract8::MIN);
|
||||
|
||||
#[embassy_executor::task]
|
||||
pub async fn safety_ui_main(mut events: DynSubscriber<'static, Prediction>, mut ui: SafetyUi<<UiSurfacePool as Surfaces<SegmentSpace>>::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:?}");
|
||||
|
||||
Reference in New Issue
Block a user