ESP32/components/status_led/status_led.h

76 lines
2.6 KiB
C

/*
* status_led.h
*
* Copyright (c) 2025 Umber Networks & Robert McMahon
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
// Logical states for the device
typedef enum {
LED_STATE_NO_CONFIG,
LED_STATE_WAITING,
LED_STATE_CONNECTED,
LED_STATE_MONITORING,
LED_STATE_TRANSMITTING, // Busy / Fast Flash (Healthy)
LED_STATE_TRANSMITTING_SLOW, // Slow Pulse (Falling behind)
LED_STATE_STALLED, // Solid Purple (Blocked)
LED_STATE_FAILED
} led_state_t;
/**
* @brief Initialize the status LED driver
* Supports both Addressable RGB (WS2812) and Simple GPIO LEDs.
* @param gpio_pin The GPIO pin number
* @param is_rgb_strip Set true for NeoPixel/WS2812, false for simple ON/OFF LED
*/
void status_led_init(int gpio_pin, bool is_rgb_strip);
/**
* @brief Thread-safe function to set the visual state
* @param state Desired logical state
*/
void status_led_set_state(led_state_t state);
/**
* @brief Get current state (useful for status console commands)
*/
led_state_t status_led_get_state(void);
#ifdef __cplusplus
}
#endif