WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

led.h

Extends an output pin to cope with an LED.
Why bother? Well depending upon how the LED is configured then you may need to set the port high to turn it on, or you may need to set it low.
This file allows you to define the LED and then just use on or off commands to make it light up or not without having to worry, each time, as to how it is wired.
The file also allows you to register an 'in built' LED to use for indicating the current program status. When using a commercial board such as the Axon or the Roboduino then these boards have a built in LED and are automatically registered as the status LED. However: if you are just including a generic board such as sys/atmega168 then no status LED can be assumed. You are encouraged to add a status LED in your initialising code (appInitHardware) by calling 'statusLEDregister'.
Status LEDs are easier to use because you can use the statusLED_on/off/set commands without worrying each time which pin it is connect to. This makes your code more portable from one board to another.
The main benefit of registering a status LED is that the library, and your own program, can indicate error conditions by flashing the status LED. See errors.h for more details.
For a more complex LED see segled.h

 

Function

 


MAKE_LED(pin, activehigh)

Allows you to create a new LED. The pin parameter says which pin it is connected to and the activehigh parameter should be TRUE if the LED is lit by setting the output pin high or FALSE if not.
Example - to create an LED on B3 that is turned on when the output is high then:
#include "led.h"
LED myLED = MAKE_LED(B3,TRUE);

LED_on(LED* led)

Turn the LED on.
LED myLED = MAKE_LED(B6,TRUE);
LED_on(&myLED);

LED_off(LED* led)

Turn the LED off.
LED myLED = MAKE_LED(B6,TRUE);
LED_off(&myLED);

LED_set(LED* led, boolean value)

Allows you to turn an LED on or off depending on a variable passed in 'value'.
If 'value' is FALSE then the LED is turned off, otherwise it is turned on.

statusLEDregister(const IOPin* pin, boolean activeHigh)

Register which pin the status LED is attached to.
This is done for you automatically for boards like the Axon and Roboduino.
The first parameter specifies the IOPin and the second parameter indicates whether the LED lights when the output pin is set high or low.

statusLED_on()

Turn on the status LED

statusLED_off()

Turn off the status LED

statusLED_set(boolean value)

Turn the status LED on or off.

Valid XHTML 1.0 Transitional