Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
#include <LedEngine.h>
Inheritance diagram for LedEngine:
Provides a collection of special effects so that the code can be reused various places as feedback to to the user.
Cycling ("pulsing") and single-value setting are mutually exclusive - one will cut off the other
A flash will invert and override the current setting, so that it will "reset" after the flash. Flashes change mid-range values to extremes to make the flash visible (ie not just (1-current)) Normal invert will do simple inverses (just (1-current))
getSetting() returns value of last set(); getValue() returns what's actually being returned to Motion at the moment
There's some nice functions for using the LEDs to display numbers. This is handy for when you want to be free of the terminal.
Definition at line 31 of file LedEngine.h.
Public Types | |
enum | numStyle_t { onedigit, twodigit } |
Use these to specify a style for displaying numbers using displayNumber(). More... | |
enum | percentStyle_t { major, minor, none } |
Use these to specify a style for displaying a percentage value [0-1] using displayPercent(). More... | |
Public Member Functions | |
LedEngine () | |
constructor - don't forget to call if you inherit | |
virtual | ~LedEngine () |
destructor | |
int | updateLEDs (const MotionCommand *caller, LEDBitMask_t mask=AllLEDMask) |
call this from a MotionCommand's updateOutputs() - makes calls to MotionManager to update LED values | |
int | updateLEDs (OutputCmd cmds[NumLEDs]) |
call this from a MotionCommand's updateOutputs() - performs the calculations to update LEDs' values | |
int | updateLEDFrames (OutputCmd cmds[NumLEDs][NumFrames]) |
call this from a MotionCommand's updateOutputs() - performs the calculations to update LEDs' values | |
int | isDirty () |
returns true if there are changes since the last updateLEDs() | |
void | invert (LEDBitMask_t leds) |
sets the leds specified by leds to the inverse of their current value | |
void | cset (LEDBitMask_t leds, float value) |
sets the leds specified by leds to value, clears all the rest | |
void | set (LEDBitMask_t leds, float value) |
sets the leds specified by leds to value | |
void | cflash (LEDBitMask_t leds, float value, unsigned int ms) |
sets the leds specified by leds to value for ms milliseconds, then sets back. Clears ~leds | |
void | flash (LEDBitMask_t leds, unsigned int ms=500) |
sets the leds specified by leds to value for ms milliseconds, then sets back. | |
void | ccycle (LEDBitMask_t leds, unsigned int period, float amp, float offset=0, int phase=0) |
causes the leds specified by leds to cycle between low and high, clears others. See cycle() for parameter documentation. | |
void | cycle (LEDBitMask_t leds, unsigned int period, float amp, float offset=0, int phase=0) |
causes the leds specified by leds to cycle between low and high | |
void | clear () |
sets all leds to 0. | |
float | getSetting (LEDOffset_t led_id) |
returns the current setting of the LED specified by led_id (the value you passed in set()) | |
float | getValue (LEDOffset_t led_id, unsigned int planahead=0) |
returns the current value of the LED specified by led_id (the value being expressed - may change if cycling for instance) | |
void | displayNumber (int x, numStyle_t style) |
Allows convenient display of numerical information to the LEDs on the face. | |
void | displayPercent (float x, percentStyle_t left_style, percentStyle_t right_style) |
Allows convenient display of percentage information to the LEDs on the face. | |
Static Public Attributes | |
const LEDBitMask_t | ERS210numMasks [11] |
holds a series of bit masks for the onedigit style of numerical display (0-10 and '.') | |
const LEDBitMask_t | ERS220numMasks [11] |
Protected Member Functions | |
float | calcValue (unsigned int i, unsigned int t) |
Calculates the current value of led i for current time t. | |
void | setOneOfTwo (unsigned int x, unsigned int low, unsigned int mid, unsigned int high) |
used by displayNumber() to determine settings of LEDs when using #numStyle_t::twodigit | |
void | setColumn (float x, unsigned int low, unsigned int mid, unsigned int high, unsigned int top) |
used by displayPercent() to determine settings of LEDs | |
Static Protected Member Functions | |
float | calcInvert (float value) |
Performs the 'invert' calculation based on current value (returns 1-value). | |
float | calcFlash (float value) |
Performs the 'flash' calculation based on current value (uses calcInvert() if value upper or lower third, 0 or 1 otherwise). | |
float | calcCycle (unsigned int period, float amp, float offset, unsigned int t) |
Performs the 'cycle' calculation based on desired period, amplituted, amplitude offset, and time since start. See cycle(). | |
Protected Attributes | |
LEDInfo | infos [NumLEDs] |
the information regarding each of the LEDs | |
unsigned int | numCycling |
the number of LEDs currently cycling (if non-zero, always dirty) | |
bool | dirty |
true if changes since last updateLEDs | |
unsigned int | dirtyTime |
the time at which it becomes dirty again (if flashing) |
|
Use these to specify a style for displaying numbers using displayNumber().
Definition at line 82 of file LedEngine.h. |
|
Use these to specify a style for displaying a percentage value [0-1] using displayPercent().
Definition at line 87 of file LedEngine.h. |
|
constructor - don't forget to call if you inherit
Definition at line 35 of file LedEngine.cc. References clear(), LedEngine::LEDInfo::flashtime, infos, ERS210Info::NumLEDs, and LedEngine::LEDInfo::starttime. |
|
destructor
Definition at line 36 of file LedEngine.h. |
|
Performs the 'cycle' calculation based on desired period, amplituted, amplitude offset, and time since start. See cycle().
Definition at line 121 of file LedEngine.h. |
|
Performs the 'flash' calculation based on current value (uses calcInvert() if value upper or lower third, 0 or 1 otherwise).
Definition at line 114 of file LedEngine.h. References calcInvert(). |
|
Performs the 'invert' calculation based on current value (returns 1-value).
Definition at line 110 of file LedEngine.h. |
|
Calculates the current value of led i for current time t.
Definition at line 127 of file LedEngine.h. References calcCycle(), LedEngine::LEDInfo::flashtime, and infos. |
|
causes the leds specified by leds to cycle between low and high, clears others. See cycle() for parameter documentation.
Definition at line 65 of file LedEngine.h. |
|
sets the leds specified by leds to value for ms milliseconds, then sets back. Clears ~leds
Definition at line 109 of file LedEngine.cc. References dirty, dirtyTime, LedEngine::LEDInfo::flashtime, LedEngine::LEDInfo::flashvalue, get_time(), infos, and ERS210Info::NumLEDs. |
|
sets all leds to 0.
Definition at line 167 of file LedEngine.cc. References dirty, infos, LedEngine::LEDInfo::isCycling, numCycling, ERS210Info::NumLEDs, and LedEngine::LEDInfo::value. |
|
sets the leds specified by leds to value, clears all the rest
Definition at line 57 of file LedEngine.h. |
|
causes the leds specified by leds to cycle between low and high
The equation used is
The idea is that with a amplitude=1 and offset=0, it will start at 0, ramp up to 1, and then ramp down again. The arguments to this function will let you control all parameters of the cycle. You can get a blink-on/off instead of cycle on/off by using a very large amplitude. Definition at line 150 of file LedEngine.cc. References LedEngine::LEDInfo::amp, dirty, get_time(), infos, LedEngine::LEDInfo::isCycling, numCycling, ERS210Info::NumLEDs, LedEngine::LEDInfo::offset, LedEngine::LEDInfo::period, and LedEngine::LEDInfo::starttime. |
|
Allows convenient display of numerical information to the LEDs on the face. If overflow occurs, the face LEDs are set to flash on and off 3 every 333 milliseconds Definition at line 176 of file LedEngine.cc. References ERS210Info::BotLLEDOffset, ERS210Info::BotRLEDOffset, ccycle(), clear(), ERS210numMasks, WorldState::ERS220Mask, ERS220numMasks, ERS210Info::FaceLEDMask, infos, ERS210Info::LEDBitMask_t, ERS210Info::LEDOffset, ERS210Info::MidLLEDOffset, ERS210Info::MidRLEDOffset, onedigit, WorldState::robotDesign, set(), setOneOfTwo(), state, ERS210Info::TopBrLEDMask, ERS210Info::TopBrLEDOffset, ERS210Info::TopLLEDOffset, ERS210Info::TopRLEDOffset, and twodigit. |
|
Allows convenient display of percentage information to the LEDs on the face. Besides allowing a two-digit display, the 'edge' bar for each type is blinked to denote how full it is. So you can get up to a two-digit, base 5 display, with an extra digit of estimated value.
If overflow (>1) occurs, sets everything to .75. The left and right columns are combined with an OR operation. (they overlap on the top bar) Left and right designations are dog centric! Definition at line 234 of file LedEngine.cc. References ERS210Info::BotLLEDMask, ERS210Info::BotRLEDMask, clear(), ERS210Info::FaceLEDMask, major, ERS210Info::MidLLEDMask, ERS210Info::MidRLEDMask, minor, set(), setColumn(), ERS210Info::TopBrLEDMask, ERS210Info::TopLLEDMask, and ERS210Info::TopRLEDMask. |
|
sets the leds specified by leds to value for ms milliseconds, then sets back.
Definition at line 121 of file LedEngine.cc. References calcFlash(), calcValue(), dirty, dirtyTime, LedEngine::LEDInfo::flashtime, LedEngine::LEDInfo::flashvalue, get_time(), infos, and ERS210Info::NumLEDs. |
|
returns the current setting of the LED specified by led_id (the value you passed in set())
Definition at line 72 of file LedEngine.h. References infos, and ERS210Info::LEDOffset. |
|
returns the current value of the LED specified by led_id (the value being expressed - may change if cycling for instance)
Definition at line 74 of file LedEngine.h. References calcValue(), get_time(), and ERS210Info::LEDOffset. |
|
sets the leds specified by leds to the inverse of their current value
Definition at line 85 of file LedEngine.cc. References LedEngine::LEDInfo::amp, dirty, infos, LedEngine::LEDInfo::isCycling, ERS210Info::NumLEDs, and LedEngine::LEDInfo::value. |
|
returns true if there are changes since the last updateLEDs()
Reimplemented in LedMC. Definition at line 43 of file LedEngine.cc. References dirty, dirtyTime, LedEngine::LEDInfo::flashtime, get_time(), infos, numCycling, and ERS210Info::NumLEDs. |
|
sets the leds specified by leds to value
Definition at line 96 of file LedEngine.cc. References dirty, infos, LedEngine::LEDInfo::isCycling, numCycling, ERS210Info::NumLEDs, and LedEngine::LEDInfo::value. |
|
used by displayPercent() to determine settings of LEDs
Definition at line 256 of file LedEngine.cc. References ERS210Info::LEDBitMask_t, and set(). |
|
used by displayNumber() to determine settings of LEDs when using #numStyle_t::twodigit
Definition at line 210 of file LedEngine.cc. References infos, and LedEngine::LEDInfo::value. |
|
call this from a MotionCommand's updateOutputs() - performs the calculations to update LEDs' values
Definition at line 75 of file LedEngine.cc. References calcValue(), dirty, ERS210Info::FrameTime, get_time(), ERS210Info::NumFrames, and ERS210Info::NumLEDs. |
|
call this from a MotionCommand's updateOutputs() - performs the calculations to update LEDs' values
Definition at line 66 of file LedEngine.cc. References calcValue(), dirty, get_time(), and ERS210Info::NumLEDs. |
|
call this from a MotionCommand's updateOutputs() - makes calls to MotionManager to update LED values
Definition at line 55 of file LedEngine.cc. References calcValue(), dirty, ERS210Info::FrameTime, get_time(), ERS210Info::LEDOffset, motman, ERS210Info::NumFrames, ERS210Info::NumLEDs, and MotionManager::setOutput(). |
|
true if changes since last updateLEDs
Definition at line 154 of file LedEngine.h. |
|
the time at which it becomes dirty again (if flashing)
Definition at line 155 of file LedEngine.h. |
|
Initial value: { ERS210Info::BotRLEDMask|ERS210Info::BotLLEDMask|ERS210Info::TopBrLEDMask, ERS210Info::BotLLEDMask|ERS210Info::MidLLEDMask|ERS210Info::TopLLEDMask, ERS210Info::BotRLEDMask|ERS210Info::BotLLEDMask|ERS210Info::TopLLEDMask|ERS210Info::TopBrLEDMask, ERS210Info::BotRLEDMask|ERS210Info::BotLLEDMask|ERS210Info::MidRLEDMask|ERS210Info::TopLLEDMask|ERS210Info::TopBrLEDMask, ERS210Info::BotLLEDMask|ERS210Info::MidLLEDMask|ERS210Info::TopRLEDMask|ERS210Info::TopLLEDMask, ERS210Info::BotRLEDMask|ERS210Info::BotLLEDMask|ERS210Info::TopRLEDMask|ERS210Info::TopBrLEDMask, ERS210Info::BotRLEDMask|ERS210Info::BotLLEDMask|ERS210Info::MidRLEDMask|ERS210Info::MidLLEDMask|ERS210Info::TopRLEDMask|ERS210Info::TopBrLEDMask, ERS210Info::BotLLEDMask|ERS210Info::MidLLEDMask|ERS210Info::TopLLEDMask|ERS210Info::TopBrLEDMask, ERS210Info::BotRLEDMask|ERS210Info::BotLLEDMask|ERS210Info::MidRLEDMask|ERS210Info::MidLLEDMask|ERS210Info::TopRLEDMask|ERS210Info::TopLLEDMask|ERS210Info::TopBrLEDMask, ERS210Info::BotLLEDMask|ERS210Info::MidLLEDMask|ERS210Info::TopRLEDMask|ERS210Info::TopLLEDMask|ERS210Info::TopBrLEDMask, ERS210Info::BotLLEDMask } the hope is that these actually resemble the shapes of the numbers so people can recognize them more easily - without converting base 2 in their heads. Definition at line 7 of file LedEngine.cc. |
|
Initial value: { ERS220Info::ModeLEDMask, ERS220Info::FaceBackLeftLEDMask, ERS220Info::FaceBackLeftLEDMask|ERS220Info::FaceCenterLeftLEDMask, ERS220Info::FaceBackLeftLEDMask|ERS220Info::FaceCenterLeftLEDMask|ERS220Info::FaceFrontLeftLEDMask, ERS220Info::FaceBackLeftLEDMask|ERS220Info::FaceCenterLeftLEDMask|ERS220Info::FaceFrontLeftLEDMask|ERS220Info::FaceFrontRightLEDMask, ERS220Info::FaceBackLeftLEDMask|ERS220Info::FaceCenterLeftLEDMask|ERS220Info::FaceFrontLeftLEDMask|ERS220Info::FaceFrontRightLEDMask|ERS220Info::FaceCenterRightLEDMask, ERS220Info::FaceBackLeftLEDMask|ERS220Info::FaceCenterLeftLEDMask|ERS220Info::FaceFrontLeftLEDMask|ERS220Info::FaceFrontRightLEDMask|ERS220Info::FaceCenterRightLEDMask|ERS220Info::FaceBackRightLEDMask, ERS220Info::FaceBackLeftLEDMask|ERS220Info::FaceCenterLeftLEDMask|ERS220Info::FaceFrontLeftLEDMask|ERS220Info::FaceFrontRightLEDMask|ERS220Info::FaceCenterRightLEDMask|ERS220Info::FaceBackRightLEDMask|ERS220Info::FaceFrontALEDMask, ERS220Info::FaceBackLeftLEDMask|ERS220Info::FaceCenterLeftLEDMask|ERS220Info::FaceFrontLeftLEDMask|ERS220Info::FaceFrontRightLEDMask|ERS220Info::FaceCenterRightLEDMask|ERS220Info::FaceBackRightLEDMask|ERS220Info::FaceFrontALEDMask|ERS220Info::FaceFrontBLEDMask, ERS220Info::FaceBackLeftLEDMask|ERS220Info::FaceCenterLeftLEDMask|ERS220Info::FaceFrontLeftLEDMask|ERS220Info::FaceFrontRightLEDMask|ERS220Info::FaceCenterRightLEDMask|ERS220Info::FaceBackRightLEDMask|ERS220Info::FaceFrontALEDMask|ERS220Info::FaceFrontBLEDMask|ERS220Info::FaceFrontCLEDMask, ERS220Info::FaceFrontLeftLEDMask } Definition at line 20 of file LedEngine.cc. |
|
the information regarding each of the LEDs
Definition at line 152 of file LedEngine.h. |
|
the number of LEDs currently cycling (if non-zero, always dirty)
Definition at line 153 of file LedEngine.h. |
Tekkotsu v1.4 |
Generated Sat Jul 19 00:09:01 2003 by Doxygen 1.3.2 |