software:firmware
MakAir Firmware
MainStateMachine Class Reference

Main state machine. More...

#include <main_state_machine.h>

Public Member Functions

 MainStateMachine ()
 Default constructor. More...
 
bool isRunning ()
 Check if the state machine is enabled. More...
 
void ScreenUpdate ()
 Display information on screen. More...
 
void setupAndStart ()
 Run the state machine. More...
 

Private Attributes

bool isMsmActive
 Main state machine activation state. More...
 

Detailed Description

Main state machine.

Definition at line 16 of file main_state_machine.h.

Constructor & Destructor Documentation

◆ MainStateMachine()

MainStateMachine::MainStateMachine ( )

Default constructor.

Definition at line 50 of file main_state_machine.cpp.

50 { isMsmActive = false; }
bool isMsmActive
Main state machine activation state.

Member Function Documentation

◆ isRunning()

bool MainStateMachine::isRunning ( )

Check if the state machine is enabled.

Returns
True if the state machine is enabled

Definition at line 52 of file main_state_machine.cpp.

52 { return isMsmActive; }

◆ ScreenUpdate()

void MainStateMachine::ScreenUpdate ( )

Display information on screen.

Definition at line 54 of file main_state_machine.cpp.

54  {
60  if (msmstep == STOPPED) {
62  }
63 }
uint16_t tidalVolumeMeasure() const
Get the measured Tidal Volume. Updated only at the end of inspiration.
int16_t peepNextCommand() const
Get the desired PEEP for the next cycle.
int16_t plateauPressureNextCommand() const
Get the desired plateau pressure for the next cycle.
int16_t peakPressureNextCommand() const
Get the desired max peak for the next cycle.
uint16_t cyclesPerMinuteNextCommand() const
Get the desired number of cycles per minute for the next cycle.
MainController mainController
Step msmstep
void displayMachineStopped()
Display a message when the machine is stopped.
Definition: screen.cpp:270
void displayCurrentSettings(uint16_t peakPressureMax, uint16_t plateauPressureMax, uint16_t peepMin)
Display the current settings.
Definition: screen.cpp:76
void displayCurrentVolume(int32_t volumeMassFlow, uint16_t cyclesPerMinute)
Display the current injected air volume.
Definition: screen.cpp:53

◆ setupAndStart()

void MainStateMachine::setupAndStart ( )

Run the state machine.

Definition at line 217 of file main_state_machine.cpp.

217  {
218  isMsmActive = true;
219  ::clockMsmTimer = 0;
220  ::msmTimer = new HardwareTimer(TIM9);
221  // Set a 1 ms timer for the event loop
222  // Prescaler at 10 kHz; stm32f411 clock is 100 mHz
223  ::msmTimer->setPrescaleFactor((::msmTimer->getTimerClkFreq() / 10000) - 1);
224  // Set the period at 1 ms
225  ::msmTimer->setOverflow(10);
226  // priority level :
227  // https://stm32f4-discovery.net/2014/05/stm32f4-stm32f429-nvic-or-nested-vector-interrupt-controller/
228  ::msmTimer->setInterruptPriority(6, 0);
229  ::msmTimer->setMode(1, TIMER_OUTPUT_COMPARE, NC);
230  ::msmTimer->attachInterrupt(millisecondTimerMSM);
231  ::msmTimer->resume();
232 }
HardwareTimer * msmTimer
uint32_t clockMsmTimer
void millisecondTimerMSM(HardwareTimer *)

Member Data Documentation

◆ isMsmActive

bool MainStateMachine::isMsmActive
private

Main state machine activation state.

Definition at line 36 of file main_state_machine.h.


The documentation for this class was generated from the following files: