C++ Library for the PsiSwarm Robot - Version 0.8
Dependents:
PsiSwarm_V8_Blank_CPP
Autonomia_RndmWlk
Fork of
PsiSwarmV7_CPP
by Psi Swarm Robot
« Back to documentation index
Led Class Reference
Led class Functions to control the various LEDs on the robot.
More...
#include <led.h >
Public Member Functions
void set_leds (char green, char red)
Set all 8 outer LEDs to the defined colour sequence.
void set_green_leds (char green)
Set the green component of all 8 outer LEDs to the defined colour sequence.
void set_red_leds (char red)
Set the red component of all 8 outer LEDs to the defined colour sequence.
void set_led (char led, char state)
Set the state of an invididual outer LED without affecting other LEDs.
void set_base_led (char state)
Set the state of the base LEDs [if fitted].
void blink_leds (float timeout)
Turns on all outer LEDs for a period of time defined by timeout then restore their previous state.
void set_center_led (char state)
Set the state the center LED.
void set_center_led (char state, float brightness)
Set the state the center LED with brightness control.
void set_center_led_brightness (float brightness)
Set the brightness of center LED without changing state.
unsigned short get_led_states (void)
Returns the current state of the outer LEDs.
void save_led_states (void)
Store the current LED states for use with restore_led_states()
void restore_led_states (void)
Restore the LED states to those set usign store_led_states()
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);
led.set_led (4,3);
}
Definition at line 42 of file led.h .
Member Function Documentation
void 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 .
unsigned short 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 .
void restore_led_states
(
void
)
Restore the LED states to those set usign store_led_states()
Definition at line 118 of file led.cpp .
void save_led_states
(
void
)
void 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 .
void 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 .
void 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 .
void 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 .
void 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 .
void 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 .
void 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 .
void 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 .