LED(4)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

🌈 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