status-led 0.2.0

no_std monochrome status LED abstraction with type-safe polarity and optional PWM gamma correction.
Documentation

status-led

CI crates.io docs.rs

no_std monochrome status LED abstraction for the embassy ecosystem.

  • Type-safe polarityActiveHigh / ActiveLow markers prevent logic errors at compile time.
  • Reads hardware directly — no internal state cache; is_on() reads the ODR register and applies polarity conversion.
  • Optional PWM — gamma-corrected brightness via PwmLed with a compact 16+16 byte lookup table.
  • FlexLed / FlexPwmLed — runtime polarity when the configuration comes from a config file instead of a type parameter.
  • Zero mandatory dependencies — only embedded-hal 1.0.

Usage

use embassy_stm32::gpio::{Output, Level, Speed};
use status_led::{Led, ActiveLow};

let pin = Output::new(p.PA5, Level::High, Speed::Low);
let mut led = Led::<_, ActiveLow>::from_pin(pin);

led.on().unwrap();
led.off().unwrap();

PWM with gamma correction

Enable the pwm feature:

status-led = { version = "0.2", features = ["pwm"] }
use status_led::pwm::{PwmLed, GammaCorrection};
use status_led::ActiveLow;

let mut led = PwmLed::<_, ActiveLow>::new(ch, GammaCorrection::SRGB);
led.set_brightness(128); // ~50% perceived brightness

Runtime polarity

When the polarity is read from configuration at runtime:

use status_led::{FlexLed, PolarityMode};

let pol = if config.active_low {
    PolarityMode::ActiveLow
} else {
    PolarityMode::ActiveHigh
};
let mut led = FlexLed::new(pin, pol).unwrap();
led.toggle().unwrap();

Features

Feature Description Extra deps
(none) GPIO LED with compile-time polarity
pwm PwmLed + FlexPwmLed with gamma-corrected brightness
defmt defmt::Format impls for all public types defmt

License

Licensed under either of Apache License 2.0 or MIT license at your option.