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.
LEDColors.cpp
- Committer:
- silverpanda
- Date:
- 2014-04-14
- Revision:
- 7:19da09fe546b
File content as of revision 7:19da09fe546b:
#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); } //-----------------------------------------------------------------------------