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 annunciators 33.Sh SYNOPSIS 34.In dev/led/led.h 35.Pp 36.Fd "typedef void led_t(void *priv, int onoff);" 37.Ft dev_t 38.Fn led_create "led_t *func" "void *priv" "char const *name" 39.Ft void 40.Fn led_destroy "dev_t dev" 41.Sh DESCRIPTION 42The 43.Nm 44driver provides generic support for handling LEDs, lamps and other 45annunciators. 46.Pp 47The hardware driver must supply a function to turn the annunciator on and off 48and the device 49.Fa name 50of the annunciator relative to 51.Pa /dev/led/ . 52The 53.Fa priv 54argument is passed back to this on/off function and can be used however 55the hardware driver sees fit. 56.Pp 57The lamp can be controlled by opening and writing 58.Tn ASCII 59strings to the 60.Pa /dev/led/bla 61device. 62.Pp 63In the following, we will use this special notation to indicate the resulting 64output of the annunciator: 65.Pp 66.Bl -tag -width indent -offset indent -compact 67.It Ic * 68The annunciator is on for 1/10th second. 69.It Ic _ 70The annunciator is off for 1/10th second. 71.El 72.Pp 73State can be set directly, and since the change happens immediately, 74it is possible to flash the annunciator with very short periods and 75synchronize it with program events. 76It should be noted that there is a non-trivial overhead, so this may 77not be usable for benchmarking or measuring short intervals. 78.Pp 79.Bl -tag -width indent -offset indent -compact 80.It Ic 0 81Turn the annunciator off immediately. 82.It Ic 1 83Turn the annunciator on immediately. 84.El 85.Pp 86Flashing can be set with a given period. 87The pattern continues endlessly. 88.Pp 89.Bl -tag -width indent -offset indent -compact 90.It Ic f 91_* 92.It Ic f1 93_* 94.It Ic f2 95__** 96.It Ic f3 97___*** 98.It ... 99.It Ic f9 100_________********* 101.El 102.Pp 103Three high-level commands are available: 104.Bl -tag -width indent -offset indent 105.It Ic d%d 106Numbers. 107Each digit is blinked out at 1/10th second, zero as ten pulses. 108Between digits a one second pause and after the last 109digit a two second pause after which the sequence is repeated. 110.It Ic s%s 111String. 112This gives full control over the annunciator. 113Letters 114.Ql A 115.No ... 116.Ql J 117turn the annunciator on for from 1/10th to one full 118second. 119Letters 120.Ql a 121.No ... 122.Ql j 123turn the annunciator off for 1/10th 124to one full second. 125Unless terminated with a 126.Ql \&. , 127the sequence is immediately repeated. 128.It Ic m%s 129Morse. 130.Pp 131.Bl -tag -width indent -offset indent -compact 132.It Ql \&. 133becomes 134.Ql _* 135.It Ql - 136becomes 137.Sq Li _*** 138.It Ql "\ " 139becomes 140.Sq Li __ 141.It Ql \en 142becomes 143.Sq Li ____ 144.El 145.El 146.Pp 147The sequence is repeated after a one second pause. 148.Sh EXAMPLES 149A 150.Sq Li d12 151flashes the lamp 152.Pp 153.Dl *__________*_*______________________________ 154.Pp 155A 156.Sq Li sAaAbBa 157flashes 158.Pp 159.Dl _*_**__* 160.Pp 161.Bd -literal 162/usr/games/morse -l "Soekris rocks" > /dev/led/error 163.Ed 164.Sh FILES 165.Bl -tag -width ".Pa /dev/led/*" 166.It Pa /dev/led/* 167.El 168.Sh SEE ALSO 169.Xr morse 6 170.Sh HISTORY 171The 172.Nm 173driver first appeared in 174.Fx 5.2 . 175.Sh AUTHORS 176.An -nosplit 177This software was written by 178.An Poul-Henning Kamp 179.Aq phk@FreeBSD.org . 180.Pp 181This manual page was written by 182.An Sergey A. Osokin 183.Aq osa@FreeBSD.org 184and 185.An Poul-Henning Kamp 186.Aq phk@FreeBSD.org . 187