LED(4)
π LED(4) β the led manual, bestie edition β¨
okay so this is the Kernel Interfaces Manual page for led, and honestly? it's lowkey iconic. it's all about making LEDs and lamps and lil annunciator thingies blink π‘β¨
β¨ NAME β¨
led β the API for manipulating LED's, lamps and other annunciators π
π SYNOPSIS π
#include <dev/led/led.h>
typedef void led_t(void *priv, int onoff);
struct cdev *
led_create_state(led_t *func, void *priv, char const *name, int state);
struct cdev *
led_create(led_t *func, void *priv, char const *name);
void
led_destroy(struct cdev *);
π¦ DESCRIPTION π¦
The led driver is giving generic support energy for handling LEDs, lamps and other annunciators. it's literally the main character of blinky things π
So here's the vibe: the hardware driver must supply a function that turns the annunciator on and off, plus the device name of the annunciator relative to /dev/led/. The priv argument gets passed right back to that on/off function, and the hardware driver can use it however it sees fit β no cap, total freedom π«Ά
You control the lamp by opening and writing ASCII strings to the /dev/led/bla device.
In the following, we're gonna use this special notation to show the resulting output of the annunciator:
* The annunciator is on for 1/10th second.
_ The annunciator is off for 1/10th second.
πΈ Setting state directly πΈ
State can be set directly, and since the change happens immediately, you can flash the annunciator with very short periods and sync it with program events. so slay for that β¨
β οΈ but heads up bestie β there's a non-trivial overhead, so this may not be usable for benchmarking or measuring short intervals. like, it's giving "cute but not a stopwatch" energy π
0 Turn the annunciator off immediately.
1 Turn the annunciator on immediately.
π Flashing π
Flashing can be set with a given period. The pattern continues endlessly β fr fr, it does not stop π₯
f _*
f1 _*
f2 __**
f3 ___***
...
f9 _________*********
π The three high-level commands π
Three high-level commands are available, and yes they ate:
d%d Numbers. Each digit is blinked out at 1/10th second, zero
as ten pulses. Between digits a one second pause and
after the last digit a two second pause after which the
sequence is repeated.
s%s String. This gives full control over the annunciator.
Letters βAβ ... βJβ turn the annunciator on for from
1/10th to one full second. Letters βaβ ... βjβ turn the
annunciator off for 1/10th to one full second. Letters
βuβ and βUβ turn the annunciator off and on respectively
when the next UTC second starts. Unless terminated with a
β.β, the sequence is immediately repeated.
m%s Morse.
β.β becomes β_*β
β-β becomes β_***β
β β becomes β__β
β\nβ becomes β____β
The sequence is repeated after a one second pause β
π FILES π
/dev/led/*
π EXAMPLES π
A d12 flashes the lamp, like so:
*__________*_*______________________________
A sAaAbBa flashes:
*_*__**_
And this one is my personal fave π§:
/usr/bin/morse -l "Soekris rocks" > /dev/led/error
π SEE ALSO π
π HISTORY π
The led driver first appeared in FreeBSD 5.2. a true OG π
πΈ AUTHORS πΈ
This software was written by Poul-Henning Kamp <phk@FreeBSD.org>.
This manual page was written by Sergey A. Osokin <osa@FreeBSD.org> and Poul-Henning Kamp <phk@FreeBSD.org>.
okay and that's the whole page bestie, no notes π this cutie came from Debian, dated April 24, 2007 β go blink something pretty πβ¨π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2003 Sergey A. Osokin <osa@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms