events: rewrite how sensor statuses are reported, and implement some oled UI icons for it
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
|
||||
use embassy_sync::{blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}, channel::Channel, pubsub::PubSubChannel};
|
||||
use embassy_time::Duration;
|
||||
use enum_map::Enum;
|
||||
use enumset::EnumSetType;
|
||||
use nalgebra::{Vector2, Vector3};
|
||||
|
||||
use crate::{graphics::display::DisplayControls, ego::engine::MotionState};
|
||||
@@ -14,6 +16,22 @@ pub enum Scene {
|
||||
Idle, // Default state when waking up from sleep, or entered when accelerometers and GPS both show zero motion for ~30 seconds
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug)]
|
||||
pub enum SensorState {
|
||||
#[default]
|
||||
// There is no connection to the sensor
|
||||
Offline,
|
||||
|
||||
// Sensor is starting up
|
||||
AcquiringFix,
|
||||
|
||||
// Sensor is ready and is generating data
|
||||
Online,
|
||||
|
||||
// Sensor was previously fully functioning but currently is not (eg, gps fix lost)
|
||||
Degraded,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Measurement {
|
||||
// GPS coordinates
|
||||
@@ -22,8 +40,7 @@ pub enum Measurement {
|
||||
IMU { accel: Vector3<f32>, gyro: Vector3<f32> },
|
||||
|
||||
// Hardware status updates
|
||||
SensorOnline(SensorSource),
|
||||
SensorOffline(SensorSource),
|
||||
SensorHardwareStatus(SensorSource, SensorState),
|
||||
|
||||
// Simulation metadata updates
|
||||
SimulationProgress(SensorSource, Duration, f32)
|
||||
@@ -43,12 +60,7 @@ pub enum Notification {
|
||||
SceneChange(Scene),
|
||||
|
||||
// States of external connections to the world
|
||||
SensorOnline(SensorSource),
|
||||
SensorOffline(SensorSource),
|
||||
|
||||
// TODO: Should be emitted by the prediction engine after it doesn't get any sensor data for some time. Perhaps the threads are somehow deadlocked and a reboot is needed if it doesn't recover
|
||||
SensorsOffline,
|
||||
|
||||
SensorStatus(SensorSource, SensorState),
|
||||
// The prediction engine has decided that the system should be woken up and begin running again
|
||||
WakeUp,
|
||||
// The prediction engine has decided that the system is inactive enough and it should go to low-power sleep
|
||||
@@ -68,10 +80,20 @@ pub enum Telemetry {
|
||||
Prediction(Prediction),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Debug, EnumSetType, Enum)]
|
||||
pub enum SensorSource {
|
||||
// Real hardware
|
||||
IMU,
|
||||
GPS
|
||||
GPS,
|
||||
|
||||
// Fusion outputs
|
||||
GravityReference,
|
||||
ForwardsReference,
|
||||
Location,
|
||||
|
||||
// Simulated sensors
|
||||
Demo,
|
||||
Simulation
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
Reference in New Issue
Block a user