PsiSwarm Library  0.8
Led Class Reference

#include <led.h>

Public Member Functions

void set_leds (char green, char red)
 
void set_green_leds (char green)
 
void set_red_leds (char red)
 
void set_led (char led, char state)
 
void set_base_led (char state)
 
void blink_leds (float timeout)
 
void set_center_led (char state)
 
void set_center_led (char state, float brightness)
 
void set_center_led_brightness (float brightness)
 
unsigned short get_led_states (void)
 
void save_led_states (void)
 
void restore_led_states (void)
 
void IF_init_leds (void)
 
void IF_update_leds (void)
 

Detailed Description

Led class Functions to control the various LEDs on the robot

Example:

#include "psiswarm.h"
int main() {
init();
led.set_led(0,1); //Set the outer LED number 0 (North) to red
led.set_led(4,3); //Set the outer LED number 4 (South) to orange (red+green)
}

Definition at line 42 of file led.h.

Member Function Documentation

§ blink_leds()

void Led::blink_leds ( float  timeout)

Turns on all outer LEDs for a period of time defined by timeout then restore their previous state

Parameters
timeout- The time (in seconds) to keep LEDs on

Definition at line 71 of file led.cpp.

§ get_led_states()

unsigned short Led::get_led_states ( void  )

Returns the current state of the outer LEDs

Returns
A 16-bit value when MSB represent the green states and LSB the red states of the 8 LEDs

Definition at line 33 of file led.cpp.

§ restore_led_states()

void Led::restore_led_states ( void  )

Restore the LED states to those set usign store_led_states()

Definition at line 118 of file led.cpp.

§ save_led_states()

void Led::save_led_states ( void  )

Store the current LED states for use with restore_led_states()

Definition at line 112 of file led.cpp.

§ set_base_led()

void Led::set_base_led ( char  state)

Set the state of the base LEDs [if fitted]

Parameters
state- 0 for off, 1 for on

Definition at line 45 of file led.cpp.

§ set_center_led() [1/2]

void Led::set_center_led ( char  state)

Set the state the center LED

Parameters
state- 0 for off, 1 for red, 2 for green, 3 for orange

Definition at line 78 of file led.cpp.

§ set_center_led() [2/2]

void Led::set_center_led ( char  state,
float  brightness 
)

Set the state the center LED with brightness control

Parameters
state- 0 for off, 1 for red, 2 for green, 3 for orange
brightness- brightness of LED [PWM duty cycle] - range 0.0 to 1.0

Definition at line 83 of file led.cpp.

§ set_center_led_brightness()

void Led::set_center_led_brightness ( float  brightness)

Set the brightness of center LED without changing state

Parameters
brightness- brightness of LED [PWM duty cycle] - range 0.0 to 1.0

Definition at line 107 of file led.cpp.

§ set_green_leds()

void Led::set_green_leds ( char  green)

Set the green component of all 8 outer LEDs to the defined colour sequence

Parameters
green- An 8-bit description of the green leds eg(0b00000001) means that LED 7 green is on, rest are off

Definition at line 50 of file led.cpp.

§ set_led()

void Led::set_led ( char  led,
char  state 
)

Set the state of an invididual outer LED without affecting other LEDs

Parameters
led- The LED to change state of (range 0 to 7)
state- 0 for off, 1 for red, 2 for green, 3 for orange

Definition at line 62 of file led.cpp.

§ set_leds()

void Led::set_leds ( char  green,
char  red 
)

Set all 8 outer LEDs to the defined colour sequence

Parameters
green- An 8-bit description of the green leds eg(0b00000001) means that LED 7 green is on, rest are off
red- An 8-bit description of the red leds eg(0b11111110) means that LED 7 red is off, rest are on

Definition at line 38 of file led.cpp.

§ set_red_leds()

void Led::set_red_leds ( char  red)

Set the red component of all 8 outer LEDs to the defined colour sequence

Parameters
red- An 8-bit description of the red leds eg(0b11111110) means that LED 7 red is off, rest are on

Definition at line 56 of file led.cpp.


The documentation for this class was generated from the following files: