src: implement ego tracking models, and port shaders from renderbug into here
This commit is contained in:
@@ -1,19 +1,68 @@
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
use core::sync::atomic::{AtomicBool, AtomicU8};
|
||||
|
||||
use embassy_sync::{blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}, channel::Channel};
|
||||
use nalgebra::{Vector2, Vector3};
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug)]
|
||||
pub enum Scene {
|
||||
ParkedIdle, // Default state when booting up or waking up from long term (overnight, eg) parking, or entered when accelerometers and GPS both show zero motion for ~30 seconds
|
||||
#[default]
|
||||
Startup, // Default state when booting up
|
||||
ParkedIdle, // Default state when waking up from long term (overnight, eg) parking, or entered when accelerometers and GPS both show zero motion for ~30 seconds
|
||||
StoplightIdle, // Entered when GPS speed is zero after decelerating
|
||||
Accelerating, // GPS speed is increasing
|
||||
Decelerating, // GPS speed is decreasing
|
||||
ParkedLongTerm, // GPS has not changed location in the last ~5 minutes
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Measurement {
|
||||
// GPS coordinates
|
||||
GPS(Vector2<f64>),
|
||||
// Accelerometer values in body frame where x=forwards
|
||||
IMU(Vector3<f32>)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Notification {
|
||||
SceneChange(Scene),
|
||||
WifiConnected,
|
||||
WifiDisconnected,
|
||||
GPSLost,
|
||||
GPSAcquired,
|
||||
BPMBeat
|
||||
CalibrationComplete,
|
||||
SetHeadlight(bool),
|
||||
SetBrakelight(bool)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DisplayControls {
|
||||
pub on: AtomicBool,
|
||||
pub brightness: AtomicU8
|
||||
}
|
||||
|
||||
impl Default for DisplayControls {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
on: AtomicBool::new(true),
|
||||
brightness: AtomicU8::new(255)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BusGarage {
|
||||
pub motion: Channel<NoopRawMutex, Measurement, 4>,
|
||||
pub scenes: Channel<CriticalSectionRawMutex, Notification, 4>,
|
||||
pub display: DisplayControls
|
||||
}
|
||||
|
||||
impl Default for BusGarage {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
motion: Channel::new(),
|
||||
scenes: Channel::new(),
|
||||
display: Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user