j

Dependencies:   mbed yeswecancoap C12832 LM75B

lib/RGB.cpp

Committer:
arnedesmet
Date:
2015-10-23
Revision:
0:92d2ef9f009d
Child:
1:92958e26bf2e

File content as of revision 0:92d2ef9f009d:


#include "RGB.h"

RGB::RGB(PinName r_pin, PinName g_pin, PinName b_pin){
    this->r_out = new PwmOut(r_pin);
    this->g_out = new PwmOut(g_pin);
    this->b_out = new PwmOut(b_pin);
}

float RGB::toFloat(int intValue){
    return (float) ((255-intValue)/255);
}

void RGB::setColor(Color color){
    
    r_out->write(toFloat(color.getRed()));
    g_out->write(toFloat(color.getGreen()));
    b_out->write(toFloat(color.getBlue()));
}

void RGB::setColor(int red, int green, int blue){
    r_out->write(toFloat(red));
    g_out->write(toFloat(green));
    b_out->write(toFloat(blue));
}

void RGB::setColor(int color){
    Color kleur = Color(color);
    r_out->write(toFloat(kleur.getRed()));
    g_out->write(toFloat(kleur.getGreen()));
    b_out->write(toFloat(kleur.getBlue()));
}