xref: /freebsd/share/man/man4/led.4 (revision 4b9d6057)
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.Dd April 24, 2007
26.Dt LED 4
27.Os
28.Sh NAME
29.Nm led
30.Nd API for manipulating LED's, lamps and other annunciators
31.Sh SYNOPSIS
32.In dev/led/led.h
33.Pp
34.Fd "typedef void led_t(void *priv, int onoff);"
35.Ft struct cdev *
36.Fn led_create_state "led_t *func" "void *priv" "char const *name" "int state"
37.Ft struct cdev *
38.Fn led_create "led_t *func" "void *priv" "char const *name"
39.Ft void
40.Fn led_destroy "struct cdev *"
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.
125Letters
126.Ql u
127and
128.Ql U
129turn the annunciator off and on respectively when the next
130UTC second starts.
131Unless terminated with a
132.Ql \&. ,
133the sequence is immediately repeated.
134.It Ic m%s
135Morse.
136.Pp
137.Bl -tag -width indent -offset indent -compact
138.It Ql \&.
139becomes
140.Ql _*
141.It Ql -
142becomes
143.Sq Li _***
144.It Ql "\ "
145becomes
146.Sq Li __
147.It Ql \en
148becomes
149.Sq Li ____
150.El
151.El
152.Pp
153The sequence is repeated after a one second pause.
154.Sh FILES
155.Bl -tag -width ".Pa /dev/led/*"
156.It Pa /dev/led/*
157.El
158.Sh EXAMPLES
159A
160.Sq Li d12
161flashes the lamp
162.Pp
163.Dl *__________*_*______________________________
164.Pp
165A
166.Sq Li sAaAbBa
167flashes
168.Pp
169.Dl *_*__**_
170.Bd -literal
171/usr/bin/morse -l "Soekris rocks" > /dev/led/error
172.Ed
173.Sh SEE ALSO
174.Xr morse 6
175.Sh HISTORY
176The
177.Nm
178driver first appeared in
179.Fx 5.2 .
180.Sh AUTHORS
181.An -nosplit
182This software was written by
183.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .
184.Pp
185This manual page was written by
186.An Sergey A. Osokin Aq Mt osa@FreeBSD.org
187and
188.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .
189