Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: LEDColors.cpp
- Revision:
- 7:19da09fe546b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LEDColors.cpp Mon Apr 14 03:04:28 2014 +0000 @@ -0,0 +1,59 @@ +#include "mbed.h" +#include "LEDColors.h" + +// constructor +LEDColors::LEDColors() +{ + // DigitalOut ledRed(LED_RED), ledBlue(LED_BLUE), ledGreen(LED_GREEN); + ledRed = new DigitalOut(LED_RED); + ledBlue = new DigitalOut(LED_BLUE); + ledGreen = new DigitalOut(LED_GREEN); + + // turn all three LEDs off + *ledRed = true; + redTimer = 0; + + *ledBlue = true; + blueTimer = 0; + + *ledGreen = true; + greenTimer = 0; +} +//----------------------------------------------------------------------------- + +void LEDColors::tick10ms() +{ + if(redTimer && !--redTimer) *ledRed = true; + if(blueTimer && !--blueTimer) *ledBlue = true; + if(greenTimer && !--greenTimer) *ledGreen = true; +} +//----------------------------------------------------------------------------- + +void LEDColors::flashRed(uint32_t duration) +{ + *ledRed = false; + redTimer = duration; +} +//----------------------------------------------------------------------------- + +void LEDColors::flashBlue(uint32_t duration) +{ + *ledBlue = false; + blueTimer = duration; +} +//----------------------------------------------------------------------------- + +void LEDColors::flashGreen(uint32_t duration) +{ + *ledGreen = false; + greenTimer = duration; +} +//----------------------------------------------------------------------------- + +void LEDColors::flashWhite(uint32_t duration) +{ + flashRed(duration); + flashBlue(duration); + flashGreen(duration); +} +//----------------------------------------------------------------------------- \ No newline at end of file