2003-11-03 17:06:10 +00:00
|
|
|
.\" 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$
|
|
|
|
.\"
|
2007-04-24 07:10:10 +00:00
|
|
|
.Dd April 24, 2007
|
2003-11-03 17:06:10 +00:00
|
|
|
.Dt LED 4
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm led
|
2004-06-30 17:24:27 +00:00
|
|
|
.Nd API for manipulating LED's, lamps and other annunciators
|
2003-11-03 17:06:10 +00:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In dev/led/led.h
|
2004-06-30 17:24:27 +00:00
|
|
|
.Pp
|
|
|
|
.Fd "typedef void led_t(void *priv, int onoff);"
|
2007-04-24 06:30:23 +00:00
|
|
|
.Ft struct cdev *
|
|
|
|
.Fn led_create_state "led_t *func" "void *priv" "char const *name" "int state"
|
2005-05-29 21:23:50 +00:00
|
|
|
.Ft struct cdev *
|
2004-06-30 17:24:27 +00:00
|
|
|
.Fn led_create "led_t *func" "void *priv" "char const *name"
|
2003-11-03 17:06:10 +00:00
|
|
|
.Ft void
|
2005-05-29 21:23:50 +00:00
|
|
|
.Fn led_destroy "struct cdev *"
|
2003-11-03 17:06:10 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver provides generic support for handling LEDs, lamps and other
|
2004-06-21 17:42:49 +00:00
|
|
|
annunciators.
|
2003-11-03 17:06:10 +00:00
|
|
|
.Pp
|
2004-06-21 17:42:49 +00:00
|
|
|
The hardware driver must supply a function to turn the annunciator on and off
|
2003-11-03 17:06:10 +00:00
|
|
|
and the device
|
2004-06-30 17:24:27 +00:00
|
|
|
.Fa name
|
|
|
|
of the annunciator relative to
|
|
|
|
.Pa /dev/led/ .
|
2003-11-03 17:06:10 +00:00
|
|
|
The
|
2004-06-30 17:24:27 +00:00
|
|
|
.Fa priv
|
2003-11-03 17:06:10 +00:00
|
|
|
argument is passed back to this on/off function and can be used however
|
|
|
|
the hardware driver sees fit.
|
|
|
|
.Pp
|
2004-06-30 17:24:27 +00:00
|
|
|
The lamp can be controlled by opening and writing
|
|
|
|
.Tn ASCII
|
|
|
|
strings to the
|
|
|
|
.Pa /dev/led/bla
|
|
|
|
device.
|
2003-11-03 17:06:10 +00:00
|
|
|
.Pp
|
2004-06-30 17:24:27 +00:00
|
|
|
In the following, we will use this special notation to indicate the resulting
|
2004-06-21 17:42:49 +00:00
|
|
|
output of the annunciator:
|
2004-06-30 17:24:27 +00:00
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent -offset indent -compact
|
2003-11-03 17:06:10 +00:00
|
|
|
.It Ic *
|
2004-06-21 17:42:49 +00:00
|
|
|
The annunciator is on for 1/10th second.
|
2003-11-03 17:06:10 +00:00
|
|
|
.It Ic _
|
2004-06-21 17:42:49 +00:00
|
|
|
The annunciator is off for 1/10th second.
|
2003-11-03 17:06:10 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2004-06-30 17:24:27 +00:00
|
|
|
State can be set directly, and since the change happens immediately,
|
2004-06-21 17:42:49 +00:00
|
|
|
it is possible to flash the annunciator with very short periods and
|
2003-11-03 17:06:10 +00:00
|
|
|
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.
|
2004-06-30 17:24:27 +00:00
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent -offset indent -compact
|
2003-11-03 17:06:10 +00:00
|
|
|
.It Ic 0
|
2004-06-21 17:42:49 +00:00
|
|
|
Turn the annunciator off immediately.
|
2003-11-03 17:06:10 +00:00
|
|
|
.It Ic 1
|
2004-06-21 17:42:49 +00:00
|
|
|
Turn the annunciator on immediately.
|
2003-11-03 17:06:10 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2004-06-30 17:24:27 +00:00
|
|
|
Flashing can be set with a given period.
|
|
|
|
The pattern continues endlessly.
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent -offset indent -compact
|
2003-11-03 17:06:10 +00:00
|
|
|
.It Ic f
|
|
|
|
_*
|
|
|
|
.It Ic f1
|
|
|
|
_*
|
|
|
|
.It Ic f2
|
|
|
|
__**
|
|
|
|
.It Ic f3
|
|
|
|
___***
|
2004-06-30 17:24:27 +00:00
|
|
|
.It ...
|
2003-11-03 17:06:10 +00:00
|
|
|
.It Ic f9
|
|
|
|
_________*********
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Three high-level commands are available:
|
2004-06-30 17:24:27 +00:00
|
|
|
.Bl -tag -width indent -offset indent
|
2003-11-03 17:06:10 +00:00
|
|
|
.It Ic d%d
|
2004-06-30 17:24:27 +00:00
|
|
|
Numbers.
|
|
|
|
Each digit is blinked out at 1/10th second, zero as ten pulses.
|
|
|
|
Between digits a one second pause and after the last
|
2003-11-03 17:06:10 +00:00
|
|
|
digit a two second pause after which the sequence is repeated.
|
|
|
|
.It Ic s%s
|
2004-06-30 17:24:27 +00:00
|
|
|
String.
|
2004-06-21 17:42:49 +00:00
|
|
|
This gives full control over the annunciator.
|
2004-06-30 17:24:27 +00:00
|
|
|
Letters
|
|
|
|
.Ql A
|
|
|
|
.No ...
|
|
|
|
.Ql J
|
|
|
|
turn the annunciator on for from 1/10th to one full
|
2003-11-03 17:06:10 +00:00
|
|
|
second.
|
2004-06-30 17:24:27 +00:00
|
|
|
Letters
|
|
|
|
.Ql a
|
|
|
|
.No ...
|
|
|
|
.Ql j
|
|
|
|
turn the annunciator off for 1/10th
|
2004-04-27 13:11:20 +00:00
|
|
|
to one full second.
|
2005-01-29 16:34:10 +00:00
|
|
|
Letters
|
|
|
|
.Ql u
|
|
|
|
and
|
|
|
|
.Ql U
|
2005-01-30 13:27:59 +00:00
|
|
|
turn the annunciator off and on respectively when the next
|
2005-01-29 16:34:10 +00:00
|
|
|
UTC second starts.
|
2004-06-30 17:24:27 +00:00
|
|
|
Unless terminated with a
|
|
|
|
.Ql \&. ,
|
|
|
|
the sequence is immediately repeated.
|
2003-11-03 17:06:10 +00:00
|
|
|
.It Ic m%s
|
2004-06-30 17:24:27 +00:00
|
|
|
Morse.
|
2003-11-03 17:06:10 +00:00
|
|
|
.Pp
|
2004-06-30 17:24:27 +00:00
|
|
|
.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
|
2003-11-03 17:06:10 +00:00
|
|
|
.El
|
2004-06-30 17:24:27 +00:00
|
|
|
.Pp
|
2003-11-03 17:55:02 +00:00
|
|
|
The sequence is repeated after a one second pause.
|
2005-01-21 08:36:40 +00:00
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width ".Pa /dev/led/*"
|
|
|
|
.It Pa /dev/led/*
|
|
|
|
.El
|
2003-11-03 17:06:10 +00:00
|
|
|
.Sh EXAMPLES
|
2004-06-30 17:24:27 +00:00
|
|
|
A
|
|
|
|
.Sq Li d12
|
|
|
|
flashes the lamp
|
2003-11-03 17:06:10 +00:00
|
|
|
.Pp
|
2004-06-30 17:24:27 +00:00
|
|
|
.Dl *__________*_*______________________________
|
|
|
|
.Pp
|
|
|
|
A
|
|
|
|
.Sq Li sAaAbBa
|
|
|
|
flashes
|
2003-11-03 17:06:10 +00:00
|
|
|
.Pp
|
2005-07-21 08:55:46 +00:00
|
|
|
.Dl *_*__**_
|
2004-06-30 17:24:27 +00:00
|
|
|
.Bd -literal
|
2003-11-03 17:06:10 +00:00
|
|
|
/usr/games/morse -l "Soekris rocks" > /dev/led/error
|
2004-06-30 17:24:27 +00:00
|
|
|
.Ed
|
2003-11-03 17:06:10 +00:00
|
|
|
.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 .
|