events: rewrite the eventing system to reduce mutex usage to just the measurement bus

This commit is contained in:
2025-12-24 09:11:16 +01:00
parent 36f232f43c
commit 046406291a
11 changed files with 185 additions and 284 deletions

View File

@@ -18,7 +18,7 @@ use nalgebra::Vector2;
use micromath::F32Ext;
use embedded_graphics::geometry::OriginDimensions;
use crate::events::{SensorSource, SensorState};
use crate::events::{Personality, SensorSource, SensorState};
use crate::graphics::images;
use crate::{ego::engine::MotionState, events::Scene};
@@ -26,12 +26,10 @@ use crate::{ego::engine::MotionState, events::Scene};
pub struct OledUI {
pub scene: Scene,
pub motion: MotionState,
pub brakelight: bool,
pub headlight: bool,
pub personality: Personality,
pub sensor_states: EnumMap<SensorSource, SensorState>,
pub velocity: f32,
pub location: Vector2<f64>,
pub sleep: bool,
}
#[derive(Default, Debug)]
@@ -179,12 +177,12 @@ impl Screen {
// The main UI content
Image::new(&images::BIKE, Point::new((128 / 2 - images::BIKE.size().width / 2) as i32, 24)).draw(sampler).unwrap();
let headlight_img = if state.ui.headlight {
let headlight_img = if state.ui.personality == Personality::Active {
&images::HEADLIGHT_ON
} else {
&images::HEADLIGHT_OFF
};
let brakelight_img = if state.ui.brakelight {
let brakelight_img = if state.ui.personality == Personality::Active {
&images::BRAKELIGHT_ON
} else {
&images::BRAKELIGHT_OFF