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

Dependencies:   C12832

RGBLed.h

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

File content as of revision 1:f2ac6d53f63d:

#ifndef RGBLED_H
#define RGBLED_H

#include "PinNames.h"
#include "mbed.h"

/** \brief A wrapper for an RGB LED connected to a PWM. This class simplifies the
  *        setting of the color and also provides some basic color definitions.
 */
class RGBLed
{
public:
    RGBLed(PinName redPin, PinName greenPin, PinName bluePin);

    /** \Brief Initialize the LED */
    void init();
    
    /** \Brief Set the color of the RGB LED */
    void setColor(const float red, const float green, const float blue);

private:
    PwmOut m_red;
    PwmOut m_green;
    PwmOut m_blue;
};

#endif