Skip to content

Status LED

Hrisabh Yadav edited this page Nov 14, 2025 · 1 revision

Status-LED.h

Status LED control interface for system indication and feedback.

Enumerations

led_status_e

typedef enum {
    GREEN,      // Green LED
    BLUE,       // Blue LED
    RED,        // Red LED
    STATUS      // Status LED
} led_status_e;

led_state_e

typedef enum {
    OFF = 0,    // LED off
    ON,         // LED on
    TOGGLE      // Toggle LED state
} led_state_e;

Global Variables

  • bool LedStatusState - Current status LED state

Functions

void Set_LED(led_status_e _led_status, led_state_e _state)

Controls the state of status LEDs.

Parameters:

  • _led_status - LED to control (GREEN, BLUE, RED, STATUS)
  • _state - State to set (ON, OFF, TOGGLE)

Usage Example

// Basic LED control
Set_LED(GREEN, ON);     // Turn green LED on
Set_LED(RED, OFF);      // Turn red LED off
Set_LED(BLUE, TOGGLE);  // Toggle blue LED
Set_LED(STATUS, ON);    // Turn status LED on

// System status indication
void indicateSystemStatus() {
    if (FlightStatus_Check(FS_ARMED)) {
        Set_LED(BLUE, ON);    // Armed - blue LED
        Set_LED(GREEN, OFF);
    } else {
        Set_LED(GREEN, ON);   // Disarmed - green LED
        Set_LED(BLUE, OFF);
    }
    
    // Battery warning
    uint16_t battery = Bms_Get(Voltage);
    if (battery < 3300) {
        Set_LED(RED, TOGGLE); // Low battery - blinking red
    } else {
        Set_LED(RED, OFF);
    }
}

// Heartbeat indication
void heartbeat() {
    static uint32_t lastBlink = 0;
    if (millis() - lastBlink > 1000) {
        Set_LED(STATUS, TOGGLE);
        lastBlink = millis();
    }
}

Clone this wiki locally