A simple class for driving an RGB LED that uses standard color specification.

Dependencies:   C12832

RGBLed.cpp

Committer:
jensva
Date:
2021-02-05
Revision:
1:f2ac6d53f63d
Parent:
0:396b3f9574ea

File content as of revision 1:f2ac6d53f63d:

#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;
}