Skip to main content

Module led

Module led 

Source
Expand description

Status LED: LEDC PWM patterns driven by a dedicated embassy task.

The LED is the device status indicator. Patterns and timings follow the mockups in assets/led/*.svg:

LedStatusPatternPeriod
Offdark—
Startupbreathing, peak brightness1000ms
Resettingfast breathing, peak300ms
Oksolid, config brightness—
Warningblink, config brightness1000ms
Errorblink, peak brightness200ms

All timing lives inside task; every other task (or interrupt) only calls set — a lock-free atomic store. Config-driven brightness flows in through set_brightness, pushed by crate::config::Config::apply.

Enums§

LedStatus
Semantic status shown by the LED (timings in the module docs).

Constants§

DEFAULT_BRIGHTNESS 🔒
Brightness assumed until set_brightness delivers the configured value (mirrors Config::default().led_brightness).
DUTY_MAX 🔒
Maximum duty count for the configured 14-bit resolution ([timer::config::Duty::Duty14Bit], i.e. 2^14 − 1).
ERROR_PERIOD_MS 🔒
Blink period of LedStatus::Error (200 ms per assets/led/blinking_200ms.svg).
PEAK_BRIGHTNESS 🔒
Brightness of the attention states (full scale).
RESETTING_PERIOD_MS 🔒
Breathing period of LedStatus::Resetting (300 ms per assets/led/breathing_300ms.svg).
STARTUP_PERIOD_MS 🔒
Breathing period of LedStatus::Startup (1000 ms per assets/led/breathing_1000ms.svg).
TICK 🔒
Effect refresh interval.
WARNING_PERIOD_MS 🔒
Blink period of LedStatus::Warning (1000 ms per assets/led/blinking_1000ms.svg).

Statics§

BRIGHTNESS 🔒
Config-driven brightness (0–255) for LedStatus::Ok / LedStatus::Warning.
STATUS 🔒
Requested status; written by set, consumed by task.

Functions§

apply 🔒
Applies status to the LEDC channel.
blink 🔒
Blink: on for the first half of period_ms, off for the second.
breathing 🔒
Breathing: raised sine over period_ms, scaled to brightness.
brightness_counts 🔒
Scale an 8-bit brightness (0–255) to raw duty counts (0–DUTY_MAX).
current_status 🔒
Reads the requested status; unknown codes fall back to LedStatus::Off.
set
Selects the status pattern.
set_brightness
Sets the config-driven brightness (0–255) used by LedStatus::Ok and LedStatus::Warning.
task
Runs the status-LED effect loop, owning the LEDC peripheral.