btnut/btnode/include/led/btn-led.h File Reference


Detailed Description

Initialization of the on-board LEDs.

Author:
Martin Hinz <btnode@hinz.ch>
Date:
26.05.2004
The LED's can be turn on and off with the set and clear function. If no LED is set the heartbeat LED 0 will flash repeatetly to let the user know that the btnode is still running (power up). This heartbeat can be set differently with the heartbeat function and can be turned off.
There are several patterns that can be displayed (even placed in a queue) with different speed and repetition to be set.

#include <io.h>

Defines

#define BTN_LED_INFINITE   0xFF
#define BTN_LED_MAX_PATTERN_QUEUE   5
LED Patterns
Several patterns can be queued up. During a pattern-flashing all LED activities (setting and clearing) will be stored and shown after the pattern is over.

#define BTN_LED_PATTERN_DOWN   6
#define BTN_LED_PATTERN_HALF   8
#define BTN_LED_PATTERN_KNIGHT   7
#define BTN_LED_PATTERN_NON   0
#define BTN_LED_PATTERN_OFF_ON   3
#define BTN_LED_PATTERN_OFF_ON_OFF   4
#define BTN_LED_PATTERN_ON   1
#define BTN_LED_PATTERN_ON_OFF   2
#define BTN_LED_PATTERN_UP   5

Functions

void btn_led_add_pattern (u_char pattern, u_char arg, u_char speed, u_char nr)
 Different patterns can be shown! With different speed and reiterations.
void btn_led_clear (u_char nr)
 Turns off LED 0-3.
void btn_led_clear_pattern_queue (void)
 To clear the pattern queue.
void btn_led_heartbeat (u_char pause, u_char bit_pattern, u_char duration)
 Sets the heartbeat pause and the bit_pattern that will be shown instead of a heartbeat with given duration.
void btn_led_init (u_char thread_on)
 Hardware setup for LED access.
void btn_led_set (u_char nr)
 Turns on LED 0-3.

Variables

u_char _btn_led_pattern_enabled
 If 0 then the led pattern queue remains cleared. Thus only btn_led_set and btn_led_clear is effective.


Define Documentation

#define BTN_LED_INFINITE   0xFF

defines infinite time for showing a pattern

Examples:
sensor-app/senso.c, uart-echo/uart-echo.c, and uart-suart/uart-suart.c.

#define BTN_LED_MAX_PATTERN_QUEUE   5

Max number of pattern that can be stored at once

#define BTN_LED_PATTERN_DOWN   6

each led flashing once going down

Examples:
uart-suart/uart-suart.c.

#define BTN_LED_PATTERN_HALF   8

lower two leds flashing, later upper two leds

#define BTN_LED_PATTERN_KNIGHT   7

knight-rider effect

Examples:
bt-lego/bt-lego.c, uart-echo/uart-echo.c, and uart-suart/uart-suart.c.

#define BTN_LED_PATTERN_NON   0

No pattern, only heartbeat or other user settings

#define BTN_LED_PATTERN_OFF_ON   3

inverse of BTN_LED_PATTERN_ON_OFF

#define BTN_LED_PATTERN_OFF_ON_OFF   4

smimilar of BTN_LED_PATTERN_ON_OFF

Examples:
sensor-app/senso.c.

#define BTN_LED_PATTERN_ON   1

flashing the selected leds once (arg 0-8 for led selection)

#define BTN_LED_PATTERN_ON_OFF   2

flashing the selected leds once, after all off for same time (arg 0-8 for led selection)

Examples:
mhop_blink/mhop_blink.c.

#define BTN_LED_PATTERN_UP   5

each led flashing once going up

Examples:
uart-echo/uart-echo.c, and uart-suart/uart-suart.c.


Function Documentation

void btn_led_add_pattern ( u_char  pattern,
u_char  arg,
u_char  speed,
u_char  nr 
)

Different patterns can be shown! With different speed and reiterations.

This function adds the pattern if a pattern is already showing!
Use btn_led_clear_pattern_queue() to delete the pattern queue!
Nr can be BTN_LED_INFINITE (0xFF) to display pattern infinitely till btn_led_clear_pattern_queue() is called!

Parameters:
pattern One of the pattern described above.
arg Some patterns need an argument to select the LEDs
speed Speed of the pattern in 100ms (0 not valid)
nr Number of repetition of this pattern (can be BTN_LED_INFINITE)
Examples:
bt-lego/bt-lego.c, mhop_blink/mhop_blink.c, sensor-app/senso.c, uart-echo/uart-echo.c, and uart-suart/uart-suart.c.

void btn_led_clear ( u_char  nr  ) 

Turns off LED 0-3.

Parameters:
nr The LED-Number (0-3)
Examples:
bt-lego/bt-lego.c, and bt-remoteprog/demo-rprog.c.

void btn_led_heartbeat ( u_char  pause,
u_char  bit_pattern,
u_char  duration 
)

Sets the heartbeat pause and the bit_pattern that will be shown instead of a heartbeat with given duration.

If this function is not called, a heatbeat with pattern 1 (LED 0) will be shown, only if no LED is turned on (to indicate that power is still o.k.)

Parameters:
pause Quite-Time of heartbeat measured in 100ms
bit_pattern 8-bit pattern that will flash as heartbeat
duration Flash-duration measured in 100ms

void btn_led_init ( u_char  thread_on  ) 

Hardware setup for LED access.

Call this function to use the on-board LEDs. If thread_on is set to 1 a new thread called "LED" will be started to display heartbeat and pattern. Passing 0 to the patterns and heartbeat won't work!

Parameters:
thread_on Pass 1 to start the LED-thread to use heartbeat and patterns
Examples:
bt-lego/bt-lego.c, bt-remoteprog/demo-rprog.c, btstreamer/receiver/btreceiver.c, btstreamer/streamer/btstreamer.c, ccc-cmd/ccc-cmd.c, l2cap-cmd/l2cap-cmd.c, mhop_blink/mhop_blink.c, rfcomm-cmd/rfcomm-cmd.c, sensor-app/senso.c, threads/threads.c, uart-echo/uart-echo.c, and uart-suart/uart-suart.c.

void btn_led_set ( u_char  nr  ) 

Turns on LED 0-3.

Parameters:
nr The LED-Number (0-3)
Examples:
bt-lego/bt-lego.c, and bt-remoteprog/demo-rprog.c.


Generated on Wed Apr 29 11:12:29 2009 for BTnut System Software by doxygen 1.5.1
!!! Dieses Dokument stammt aus dem ETH Web-Archiv und wird nicht mehr gepflegt !!!
!!! This document is stored in the ETH Web archive and is no longer maintained !!!