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