Moved some of the things from the "communicatinon" subsection of core directly into core. This is because some of these structs will be needed for logic as well.

This commit is contained in:
2026-05-23 17:45:06 -05:00
parent eb29b97f9b
commit b7393971e2
5 changed files with 96 additions and 38 deletions
+64 -3
View File
@@ -1,4 +1,65 @@
use serde::{Deserialize, Serialize};
pub struct MotorRPM{
use core::fmt::Display;
use serde::{Deserialize, Serialize};
///Motor Drivers reported shaft speed. This can be in any of the given unit types by the Unit enum and timescalse given by the TimeScales enum
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct MotorDriverShaftSpeed {
shaft_speed: Option<f32>,
unit: Unit,
time_scale: TimeScale,
}
impl MotorDriverShaftSpeed {
}
impl Display for MotorDriverShaftSpeed {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.shaft_speed {
Some(speed) => {
let unit = match self.unit {
Unit::Radians => "rad",
Unit::Rotations => "R",
_ => "",
};
write!(f, "")
}
None => {write!(f, "No Given Speeds")}
}
}
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[repr(u8)]
pub enum Unit {
Unknown = 0,
Rotations = 1,
Radians = 2,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[repr(u8)]
pub enum TimeScale {
Unknown = 0,
PerSecond = 1,
PerMinute = 2,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
pub struct MotorDriverDiagData {
///Current draw of the motor if readable, reported in microAmps
current: Option<i32>,
///Voltage of the motor if readable, reported in microVolts
voltage: Option<i32>,
///Shaft speed of the motor if readable.
shaft_speed: Option<MotorDriverShaftSpeed>,
///Status of the hardware brake if present, none if not present.
brake_status: Option<bool>,
}
}