STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
flight_state.cpp
Go to the documentation of this file.
1#include "flight_state.h"
2
3#include "apogee.h"
4#include "config.h"
5#include "flight_log.h"
6#include "pins.h"
7
9static uint32_t s_activeEnterMs = 0;
10
11static void driveAllSolenoids(bool high) {
12 const int pins[] = {
15 };
16 for (int p : pins)
17 digitalWrite(p, high ? HIGH : LOW);
18}
19
21 const int pins[] = {
24 };
25 for (int p : pins) {
28 }
29}
30
34
35static void transitionTo(FlightState to, uint8_t reason) {
36 FlightState from = s_state;
37 if (from == to)
38 return;
39 s_state = to;
40 logFlightStateTransition(from, to, millis(), reason);
41}
42
49
57
63
70
72 // Stub: selective thruster control — all valves stay LOW until implemented.
73}
74
76 switch (s_state) {
79 driveAllSolenoids(false);
80 break;
83 driveAllSolenoids(false);
84 break;
87 break;
88 }
89}
#define HIGH
Definition Arduino.h:19
void pinMode(int, int)
Definition Arduino.h:46
#define OUTPUT
Definition Arduino.h:22
unsigned long millis()
Definition Arduino.h:29
#define LOW
Definition Arduino.h:20
void digitalWrite(int, int)
Definition Arduino.h:48
FlightState
Definition flight_state.h:5
#define PIN_DRIVE_2
Definition pins.h:25
#define PIN_DRIVE_6
Definition pins.h:29
#define PIN_DRIVE_5
Definition pins.h:28
#define PIN_DRIVE_3
Definition pins.h:26
#define PIN_DRIVE_4
Definition pins.h:27
#define PIN_DRIVE_1
Definition pins.h:24
void apogeeReset()
Definition apogee.cpp:14
static constexpr uint32_t ACTIVE_DURATION_MS
Definition config.h:78
int32_t p
Definition flight_e2e.c:78
void logFlightStateTransition(FlightState from, FlightState to, uint32_t t_ms, uint8_t reason)
void flightStateOnActiveTimeout()
Active → Venting when Active timer expires.
void runNoseConeControlLoop()
FlightState flightStateGet()
void flightStateInit()
void flightStateOnLaunchDetect()
Idle → Launch (call from main when LIS3 launch ISR fires).
void flightStateOnApogee()
Launch → Active when apogee algorithm confirms (only valid from Launch).
static void driveAllSolenoids(bool high)
void applyActuatorOutputs()
static void transitionTo(FlightState to, uint8_t reason)
static FlightState s_state
void flightStateTick()
static uint32_t s_activeEnterMs