Skip to content

Commit

Permalink
more skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanCavers committed Sep 30, 2024
1 parent 59e44bf commit 70287f4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/state_machine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name = "hyped_state_machine"
version = "0.1.0"
edition = "2021"

[lib]
path = "src/state_machine.rs"
[features]
std = []
4 changes: 4 additions & 0 deletions lib/state_machine/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod state_machine;
pub mod types;
13 changes: 12 additions & 1 deletion lib/state_machine/src/state_machine.rs
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
#![no_std]
use crate::types::State;

pub struct StateMachine {
current_state: State,
// transition_map: HashMap<SourceAndTarget, State> (use heapless::FnvIndexMap)?
}

impl StateMachine {
pub fn handle_transition(&mut self) {
self.current_state = State::KStopped;
}
}
27 changes: 27 additions & 0 deletions lib/state_machine/src/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#[derive(Hash)]
pub enum State {
KIdle,
KCalibrate,
KPrecharge,
KReadyForLevitation,
KBeginLevitation,
KLevitating,
KReady,
KAccelerate,
KLimBrake,
KFrictionBrake,
KStopLevitation,
KStopped,
KBatteryRecharge,
KCapacitorDischarge,
KFailureBrake,
KFailure,
KSafe,
KShutdown,
}

#[derive(Hash)]
pub struct SourceAndTarget {
source: State,
target: State,
}

0 comments on commit 70287f4

Please sign in to comment.