1.\" Copyright (c) 2003 Sergey A. Osokin <osa@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" 27.Dd November 3, 2003 28.Dt LED 4 29.Os 30.Sh NAME 31.Nm led 32.Nd API for manipulating LED's, lamps and other announciators. 33.Sh SYNOPSIS 34.In dev/led/led.h 35.Bd -literal 36typedef void led_t(void *priv, int onoff); 37.Ed 38.Ft dev_t 39.Fo led_create 40.Fa "led_t *func" 41.Fa "void *priv" 42.Fa "char const *name" 43.Fc 44.Ft void 45.Fo led_destroy 46.Fa "dev_t dev" 47.Fc 48.Sh DESCRIPTION 49The 50.Nm 51driver provides generic support for handling LEDs, lamps and other 52announciators. 53.Pp 54The hardware driver must supply a function to turn the announciator on and off 55and the device 56.Va name 57of the announciator relative "/dev/led/". 58The 59.Va priv 60argument is passed back to this on/off function and can be used however 61the hardware driver sees fit. 62.Pp 63The lamp can be controlled by opening and writing ascii strings to the 64"/dev/led/bla" device. 65.Pp 66In the following we will use this special notation to indicate the resulting 67output of the announciator: 68.Bl -tag -width Ds -offset indent -compact 69.It Ic * 70The announciator is on for 1/10th secound. 71.It Ic _ 72The announciator is off for 1/10th secound. 73.El 74.Pp 75State can be set directly, and since the change happens immediately, 76it is possible to flash the announciator with very short periods and 77synchronize it with program events. 78It should be noted that there is a non-trivial overhead, so this may 79not be usable for benchmarking or measuring short intervals. 80.Bl -tag -width Ds -offset indent -compact 81.It Ic 0 82Turn the announciator off immediately. 83.It Ic 1 84Turn the announciator on immediately. 85.El 86.Pp 87Flashing can be set with a given period. The pattern continues endlessly. 88.Bl -tag -width Ds -offset indent -compact 89.It Ic f 90_* 91.It Ic f1 92_* 93.It Ic f2 94__** 95.It Ic f3 96___*** 97.It Ic ... 98.It Ic f9 99_________********* 100.El 101.Pp 102Three high-level commands are available: 103.Bl -tag -width Ds -offset indent -compact 104.It Ic d%d 105numbers. Each digit is blinked out at 1/10th second, zero as 106ten pulses. Between digits a one second pause and after the last 107digit a two second pause after which the sequence is repeated. 108.It Ic s%s 109string. 110This gives full control over the announciator. 111Letters 'A' ... 'J' turns the announciator on for from 1/10th to one full 112second. 113Letters 'a' ... 'j' turns the announciator off for 1/10th 114to one full second. 115Unless terminated with a '.', the sequence is immediately repeated. 116.It Ic m%s 117morse. 118.Bl -tag -width Ds -offset indent -compact 119.It Ic '.' 120becomes _* 121.It Ic '-' 122becomes _*** 123.It Ic ' ' 124becomes __ 125.It Ic '\en' 126becomes ____ 127.El 128.Pp 129.El 130The sequence is repeated after a one second pause. 131.Sh EXAMPLES 132A 'd12' flashes the lamp 133.Bd -literal -offset indent 134*__________*_*______________________________ 135.Ed 136.Pp 137A 'sAaAbBa' flashes 138.Bd -literal -offset indent 139_*_**__* 140.Ed 141.Pp 142/usr/games/morse -l "Soekris rocks" > /dev/led/error 143.Sh FILES 144.Bl -tag -width /dev/led/* 145.It Pa /dev/led/* 146.El 147.Sh SEE ALSO 148.Xr morse 6 149.Sh HISTORY 150The 151.Nm 152driver first appeared in 153.Fx 5.2 . 154.Sh AUTHORS 155.An -nosplit 156This software was written by 157.An Poul-Henning Kamp 158.Aq phk@FreeBSD.org . 159.Pp 160This manual page was written by 161.An Sergey A. Osokin 162.Aq osa@FreeBSD.org 163and 164.An Poul-Henning Kamp 165.Aq phk@FreeBSD.org . 166