# Flight States

AstroNav Nano uses a controlled state machine throughout startup and flight.

## State overview

```mermaid
flowchart TD
    boot[Booting] -->|USB power| usb[USB Mode]
    boot -->|Flight startup| calibration[Calibrating]
    usb -->|Leave USB storage mode| calibration
    calibration --> idle[Idle]
    idle -->|Launch confirmed| boost[Boost]
    boost --> coast[Coast]
    coast -->|Apogee confirmed; output enabled and permitted| pyro[Pyro Fired]
    coast -->|Automatic firing disabled; apogee logged| landing[Landing detection]
    pyro --> landing
    landing --> landed[Landed]
    boot & calibration & idle & boost & coast & pyro -.->|Critical fault latched| fault[Fault]
    class fault danger-node
```

This is a workflow overview. `Landing detection` describes monitoring, not an additional flight state. With `FIRE_PYRO_APOGEE=FALSE`, apogee is still detected and logged, but automatic pyro output is blocked. A latched critical fault disables the pyro output; investigate its cause before continuing.

## Booting

The board initializes:

- Hardware
- Sensors
- Storage
- Status systems

Outputs are kept in a safe startup state.

## USB Mode

When the board detects USB power, it exposes its storage to the connected computer.

This allows access to:

- `Settings.ini`
- `Howto.txt`
- Flight logs
- Diagnostic information

## Calibrating

Before flight, AstroNav Nano establishes:

- Gravity reference
- Gyroscope bias
- Baseline pressure

The board must remain stationary during this process.

## Idle

Calibration has completed and the board is waiting for launch conditions.

## Boost

Sustained acceleration has confirmed launch and powered ascent.

## Coast

Powered ascent has ended while the vehicle remains in flight.

## Pyro Fired

Apogee has been confirmed and the pyro event has occurred.

The output is latched so the same event cannot repeatedly trigger the pyro channel.

If pyro firing is disabled, apogee can still be detected and logged.

## Landed

The vehicle has remained stable long enough for the firmware to confirm landing.

The firmware then finalizes the mission log and updates flight records.

## Fault

A critical problem has been detected.

When a critical fault is latched:

- The system enters a safe state.
- The pyro output is disabled.
- The cause must be investigated before continuing.

## Status LED

The LED communicates general device status.

Typical conditions include:

- Startup activity
- Calibration
- USB mode
- Idle
- Fault

A rapidly blinking red state indicates a fault.

Do not use the LED alone for detailed diagnostics.

Use the USB debug information and serial output to investigate warnings and faults.