oled: rewrite the oled UI to have animations, and support a version of sleeping where the display is blank, at least
This commit is contained in:
@@ -45,9 +45,8 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
|
||||
|
||||
pub async fn sleep(&mut self) {
|
||||
info!("Running sleep sequence");
|
||||
let fade_out = Animation::default().duration(Duration::from_secs(1)).from(255).to(0);
|
||||
let mut disp_anim = AnimDisplay(&mut self.display);
|
||||
fade_out.apply(&mut disp_anim).await;
|
||||
TURN_OFF.apply(&mut disp_anim).await;
|
||||
|
||||
warn!("Resetting safety lights");
|
||||
self.brakelight.set_visible(false);
|
||||
@@ -87,15 +86,14 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
|
||||
fade_in.apply(&mut self.brakelight)
|
||||
);
|
||||
|
||||
let fade_out = Animation::default().duration(Duration::from_secs(1)).from(255).to(0);
|
||||
info!("Fade out overlay");
|
||||
fade_out.apply(&mut self.overlay).await;
|
||||
TURN_OFF.apply(&mut self.overlay).await;
|
||||
self.overlay.set_visible(false);
|
||||
Timer::after_secs(3).await;
|
||||
warn!("Turning off safety lights");
|
||||
join!(
|
||||
fade_out.apply(&mut self.headlight),
|
||||
fade_out.apply(&mut self.brakelight)
|
||||
TURN_OFF.apply(&mut self.headlight),
|
||||
TURN_OFF.apply(&mut self.brakelight)
|
||||
);
|
||||
info!("Wakeup complete!");
|
||||
}
|
||||
@@ -109,8 +107,20 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
|
||||
match event {
|
||||
// Toggling head and brake lights
|
||||
// FIXME: These should be a Off/Low/High enum, so the stopping brake looks different from the dayrunning brake.
|
||||
Notification::SetBrakelight(is_on) => self.brakelight.set_on(is_on).await,
|
||||
Notification::SetHeadlight(is_on) => self.headlight.set_on(is_on).await,
|
||||
Notification::SetBrakelight(is_on) => {
|
||||
if is_on {
|
||||
TURN_ON.apply(&mut self.brakelight).await;
|
||||
} else {
|
||||
TURN_OFF.apply(&mut self.brakelight).await;
|
||||
}
|
||||
},
|
||||
Notification::SetHeadlight(is_on) => {
|
||||
if is_on {
|
||||
TURN_ON.apply(&mut self.headlight).await;
|
||||
} else {
|
||||
TURN_OFF.apply(&mut self.headlight).await;
|
||||
}
|
||||
},
|
||||
|
||||
Notification::Sleep => self.sleep().await,
|
||||
Notification::WakeUp => self.wake().await,
|
||||
@@ -119,6 +129,9 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
|
||||
}
|
||||
}
|
||||
|
||||
const TURN_ON: Animation = Animation::new().duration(Duration::from_secs(1)).from(0).to(255);
|
||||
const TURN_OFF: Animation = Animation::new().duration(Duration::from_secs(1)).from(255).to(0);
|
||||
|
||||
#[embassy_executor::task]
|
||||
pub async fn safety_ui_main(mut events: DynSubscriber<'static, Notification>, mut ui: SafetyUi<<UiSurfacePool as Surfaces<SegmentSpace>>::Surface>) {
|
||||
// Wait for the renderer to start running
|
||||
|
||||
Reference in New Issue
Block a user