debug: add some more trace-level logging to animation and safetyui bits
This commit is contained in:
@@ -139,8 +139,9 @@ impl<S: Surface> DerefMut for AnimatedSurface<S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Surface> From<S> for AnimatedSurface<S> {
|
impl<S: Surface + Debug> From<S> for AnimatedSurface<S> {
|
||||||
fn from(surface: S) -> Self {
|
fn from(surface: S) -> Self {
|
||||||
|
trace!("create anim surface={surface:?}");
|
||||||
AnimatedSurface {
|
AnimatedSurface {
|
||||||
surface,
|
surface,
|
||||||
is_on: false,
|
is_on: false,
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ use core::fmt::Debug;
|
|||||||
use futures::join;
|
use futures::join;
|
||||||
use log::*;
|
use log::*;
|
||||||
|
|
||||||
use crate::{animation::{AnimDisplay, AnimatedSurface, Animation}, graphics::display::{DisplayControls, SegmentSpace, Uniforms}, events::Notification, graphics::shaders::*, tasks::ui::UiSurfacePool};
|
use crate::{animation::{AnimDisplay, AnimatedSurface, Animation}, events::{Notification, Prediction}, graphics::{display::{DisplayControls, SegmentSpace, Uniforms}, shaders::*}, tasks::ui::UiSurfacePool};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct SafetyUi<S: Surface> {
|
pub struct SafetyUi<S: Surface> {
|
||||||
// Headlight and brakelight layers can only be overpainted by the bootsplash overlay layer
|
// Headlight and brakelight layers can only be overpainted by the bootsplash overlay layer
|
||||||
headlight: AnimatedSurface<S>,
|
headlight: AnimatedSurface<S>,
|
||||||
@@ -21,7 +22,7 @@ pub struct SafetyUi<S: Surface> {
|
|||||||
|
|
||||||
impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pixel = Rgba<u8>>> SafetyUi<S> {
|
impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pixel = Rgba<u8>>> SafetyUi<S> {
|
||||||
pub fn new<SS: Surfaces<SegmentSpace, Surface = S>>(surfaces: &mut SS, display: DisplayControls) -> Self where SS::Error: Debug {
|
pub fn new<SS: Surfaces<SegmentSpace, Surface = S>>(surfaces: &mut SS, display: DisplayControls) -> Self where SS::Error: Debug {
|
||||||
Self {
|
let ret = Self {
|
||||||
overlay: SurfaceBuilder::build(surfaces)
|
overlay: SurfaceBuilder::build(surfaces)
|
||||||
.rect(Rectangle::everything())
|
.rect(Rectangle::everything())
|
||||||
.shader(Thinking::default())
|
.shader(Thinking::default())
|
||||||
@@ -40,7 +41,9 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
|
|||||||
.opacity(0)
|
.opacity(0)
|
||||||
.finish().unwrap().into(),
|
.finish().unwrap().into(),
|
||||||
display
|
display
|
||||||
}
|
};
|
||||||
|
trace!("shader={:?}", ret.overlay);
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn sleep(&mut self) {
|
pub async fn sleep(&mut self) {
|
||||||
@@ -71,7 +74,7 @@ impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pix
|
|||||||
//self.display.render_is_running.wait().await;
|
//self.display.render_is_running.wait().await;
|
||||||
|
|
||||||
let fade_in = Animation::default().duration(Duration::from_secs(3)).from(0).to(255);
|
let fade_in = Animation::default().duration(Duration::from_secs(3)).from(0).to(255);
|
||||||
info!("Fading in brightness with overlay");
|
trace!("Fading in brightness with overlay={:?}", self.overlay);
|
||||||
self.overlay.set_opacity(255);
|
self.overlay.set_opacity(255);
|
||||||
self.overlay.set_visible(true);
|
self.overlay.set_visible(true);
|
||||||
fade_in.apply(&mut AnimDisplay(&mut self.display)).await;
|
fade_in.apply(&mut AnimDisplay(&mut self.display)).await;
|
||||||
@@ -136,8 +139,10 @@ const TURN_OFF: Animation = Animation::new().duration(Duration::from_secs(1)).fr
|
|||||||
pub async fn safety_ui_main(mut events: DynSubscriber<'static, Notification>, mut ui: SafetyUi<<UiSurfacePool as Surfaces<SegmentSpace>>::Surface>) {
|
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
|
// Wait for the renderer to start running
|
||||||
//ui.display.render_is_running.wait().await;
|
//ui.display.render_is_running.wait().await;
|
||||||
|
trace!("spooling until render starts ui={ui:?}");
|
||||||
ui.display.wait_until_render_is_running().await;
|
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