LED(4)
π LED(4) β the Kernel Interfaces Manual, but make it cute π
okay bestie, gather round, we're talking about led(4) β the kernel's whole entire API for manipulating LEDs, lamps and other annunciators. yes, annunciators. it's giving fancy word for "little blinky light." slay. β¨
β¨ NAME β¨
led β API for manipulating LED's, lamps and other annunciators π¨π‘
π SYNOPSIS π
like, here's the tea, copy-paste it exactly, do not freestyle:
#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 π¦
so the led driver is basically the generic support system for handling LEDs, lamps and other annunciators. main character energy for tiny lights. π
your hardware driver has to bring two things to the party: a function that turns the annunciator on and off, and the device name of the annunciator, which lives 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 rules, just vibes (well, the vibes of a void *). π«Ά
you control the lamp by opening and writing ASCII strings to the /dev/led/bla device. that's it. that's the whole thing.
in the following, we use this special notation to indicate the resulting output of the annunciator:
* The annunciator is on for 1/10th second.
_ The annunciator is off for 1/10th second.
state can be set directly, and because the change happens immediately, you can flash the annunciator with very short periods and synchronize it with program events. iconic, honestly. but heads up bestie β there's a non-trivial overhead, so this may not be usable for benchmarking or measuring short intervals. π
0 Turn the annunciator off immediately.
1 Turn the annunciator on immediately.
flashing can be set with a given period, and the pattern continues endlessly. forever. no cap. βΎοΈ
f _*
f1 _*
f2 __**
f3 ___***
...
f9 _________*********
three high-level commands are available, and 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:
*__________*_*______________________________
a sAaAbBa flashes:
*_*__**_
and this one right here? chef's kiss. obsessed:
/usr/bin/morse -l "Soekris rocks" > /dev/led/error
β SEE ALSO β
π HISTORY π
the led driver first appeared in FreeBSD 5.2. a legend was born. π
π 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>.
and that's the whole page bestie, ty for coming to my ted talk π this one's from the Debian crew, dated April 24, 2007, and it's LED(4) β mwah, periodt. π
β¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2003 Sergey A. Osokin <osa@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms