A simple class for driving an RGB LED that uses standard color specification.
Diff: RGBLed.cpp
- Revision:
- 0:396b3f9574ea
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RGBLed.cpp Fri May 24 03:21:40 2013 +0000 @@ -0,0 +1,18 @@ +#include "RGBLed.h" + +RGBLed::RGBLed(PinName redPin, PinName greenPin, PinName bluePin) : m_red(redPin), m_green(greenPin), m_blue(bluePin) +{ +} + +void RGBLed::init() +{ + m_red.period(0.001); +} + +void RGBLed::setColor(const float red, const float green, const float blue) +{ + // Negative logic + m_red = 1.f - red; + m_green = 1.f - green; + m_blue = 1.f - blue; +} \ No newline at end of file