STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
flight_state.cpp File Reference
#include "flight_state.h"
#include "apogee.h"
#include "config.h"
#include "flight_log.h"
#include "pins.h"
Include dependency graph for flight_state.cpp:

Go to the source code of this file.

Functions

static void driveAllSolenoids (bool high)
void flightStateInit ()
FlightState flightStateGet ()
static void transitionTo (FlightState to, uint8_t reason)
void flightStateOnLaunchDetect ()
 Idle → Launch (call from main when LIS3 launch ISR fires).
void flightStateOnApogee ()
 Launch → Active when apogee algorithm confirms (only valid from Launch).
void flightStateOnActiveTimeout ()
 Active → Venting when Active timer expires.
void flightStateTick ()
void runNoseConeControlLoop ()
void applyActuatorOutputs ()

Variables

static FlightState s_state = FlightState::Idle
static uint32_t s_activeEnterMs = 0

Function Documentation

◆ applyActuatorOutputs()

void applyActuatorOutputs ( )

Definition at line 75 of file flight_state.cpp.

References Active, driveAllSolenoids(), Idle, Launch, runNoseConeControlLoop(), s_state, and Venting.

Referenced by loop().

◆ driveAllSolenoids()

void driveAllSolenoids ( bool high)
static

◆ flightStateGet()

FlightState flightStateGet ( )

Definition at line 31 of file flight_state.cpp.

References s_state.

Referenced by loop(), and sensorsShouldLog().

◆ flightStateInit()

void flightStateInit ( )

Definition at line 20 of file flight_state.cpp.

References digitalWrite(), LOW, OUTPUT, p, PIN_DRIVE_1, PIN_DRIVE_2, PIN_DRIVE_3, PIN_DRIVE_4, PIN_DRIVE_5, PIN_DRIVE_6, and pinMode().

Referenced by setup().

◆ flightStateOnActiveTimeout()

void flightStateOnActiveTimeout ( )

Active → Venting when Active timer expires.

Definition at line 58 of file flight_state.cpp.

References Active, s_state, transitionTo(), and Venting.

Referenced by flightStateTick().

◆ flightStateOnApogee()

void flightStateOnApogee ( )

Launch → Active when apogee algorithm confirms (only valid from Launch).

Definition at line 50 of file flight_state.cpp.

References Active, apogeeReset(), Launch, millis(), s_activeEnterMs, s_state, and transitionTo().

Referenced by loop().

◆ flightStateOnLaunchDetect()

void flightStateOnLaunchDetect ( )

Idle → Launch (call from main when LIS3 launch ISR fires).

Definition at line 43 of file flight_state.cpp.

References apogeeReset(), Idle, Launch, s_state, and transitionTo().

Referenced by loop().

◆ flightStateTick()

void flightStateTick ( )

Definition at line 64 of file flight_state.cpp.

References Active, ACTIVE_DURATION_MS, flightStateOnActiveTimeout(), millis(), s_activeEnterMs, and s_state.

Referenced by loop().

◆ runNoseConeControlLoop()

void runNoseConeControlLoop ( )

Definition at line 71 of file flight_state.cpp.

Referenced by applyActuatorOutputs().

◆ transitionTo()

void transitionTo ( FlightState to,
uint8_t reason )
static

Variable Documentation

◆ s_activeEnterMs

uint32_t s_activeEnterMs = 0
static

Definition at line 9 of file flight_state.cpp.

Referenced by flightStateOnApogee(), and flightStateTick().

◆ s_state