File syn_led.c¶
Go to the source code of this file
LED controller implementation.
#include "../drivers/syn_gpio.h"#include "../util/syn_assert.h"#include "syn_led.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| void | syn_led_blink (SYN_LED * led, uint16_t on_ms, uint16_t off_ms) Start a continuous blink. |
| void | syn_led_flash (SYN_LED * led, uint16_t on_ms, uint16_t off_ms, uint8_t count) Flash the LED N times, then turn off. |
| void | syn_led_init (SYN_LED * led, SYN_GPIO_Pin pin, SYN_LEDPolarity polarity) Initialize an LED descriptor. |
| uint32_t | syn_led_next_ms (const SYN_LED * led) Milliseconds until the next state transition. |
| void | syn_led_off (SYN_LED * led) Turn the LED off. |
| void | syn_led_on (SYN_LED * led) Turn the LED on (steady). |
| void | syn_led_pattern (SYN_LED * led, const char * pattern, uint16_t unit_ms) Play a pattern string. |
| void | syn_led_service (SYN_LED * leds, size_t count) Service an array of LEDs. |
| void | syn_led_toggle (SYN_LED * led) Toggle the LED (only meaningful in ON/OFF modes). |
| void | syn_led_update (SYN_LED * led) Update the LED state machine. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | led_set_output (SYN_LED * led, bool on) Set the LED GPIO output based on polarity. |
Public Functions Documentation¶
function syn_led_blink¶
Start a continuous blink.
Parameters:
ledLED.on_msOn time in milliseconds.off_msOff time in milliseconds.
function syn_led_flash¶
Flash the LED N times, then turn off.
Parameters:
ledLED.on_msOn time per flash (ms).off_msOff time between flashes (ms).countNumber of flashes.
function syn_led_init¶
Initialize an LED descriptor.
Parameters:
ledLED to initialize.pinGPIO pin number.polarityActive-high or active-low.
function syn_led_next_ms¶
Milliseconds until the next state transition.
Returns 0 if a transition is overdue, UINT32_MAX if the LED is static (ON or OFF). Useful for sleeping in a protothread:
uint32_t wait = syn_led_next_ms(&led);
if (wait > 0 && wait < UINT32_MAX)
PT_TASK_DELAY_MS(pt, task, wait);
Parameters:
ledLED instance.
Returns:
Milliseconds until the next toggle.
function syn_led_off¶
Turn the LED off.
Parameters:
ledLED instance.
function syn_led_on¶
Turn the LED on (steady).
Parameters:
ledLED instance.
function syn_led_pattern¶
Play a pattern string.
Pattern characters: '.' = short on (1 unit) '-' = long on (3 units) ' ' = pause (1 unit) '|' = long pause (3 units)
The pattern repeats indefinitely. Set a null or empty string to stop.
Parameters:
ledLED.patternNull-terminated pattern string.unit_msBase time unit in milliseconds (e.g., 100).
function syn_led_service¶
Service an array of LEDs.
Parameters:
ledsLED array.countNumber of LEDs.
function syn_led_toggle¶
Toggle the LED (only meaningful in ON/OFF modes).
Parameters:
ledLED instance.
function syn_led_update¶
Update the LED state machine.
Call from your main loop or a scheduler task.
Parameters:
ledLED instance.
Public Static Functions Documentation¶
function led_set_output¶
Set the LED GPIO output based on polarity.
Parameters:
ledLED instance.ontrue to light the LED.
The documentation for this class was generated from the following file src/syntropic/output/syn_led.c