j

Dependencies:   mbed yeswecancoap C12832 LM75B

Committer:
arnedesmet
Date:
Fri Oct 23 11:51:28 2015 +0000
Revision:
0:92d2ef9f009d
Child:
1:92958e26bf2e
hallo;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arnedesmet 0:92d2ef9f009d 1
arnedesmet 0:92d2ef9f009d 2 #include "RGB.h"
arnedesmet 0:92d2ef9f009d 3
arnedesmet 0:92d2ef9f009d 4 RGB::RGB(PinName r_pin, PinName g_pin, PinName b_pin){
arnedesmet 0:92d2ef9f009d 5 this->r_out = new PwmOut(r_pin);
arnedesmet 0:92d2ef9f009d 6 this->g_out = new PwmOut(g_pin);
arnedesmet 0:92d2ef9f009d 7 this->b_out = new PwmOut(b_pin);
arnedesmet 0:92d2ef9f009d 8 }
arnedesmet 0:92d2ef9f009d 9
arnedesmet 0:92d2ef9f009d 10 float RGB::toFloat(int intValue){
arnedesmet 0:92d2ef9f009d 11 return (float) ((255-intValue)/255);
arnedesmet 0:92d2ef9f009d 12 }
arnedesmet 0:92d2ef9f009d 13
arnedesmet 0:92d2ef9f009d 14 void RGB::setColor(Color color){
arnedesmet 0:92d2ef9f009d 15
arnedesmet 0:92d2ef9f009d 16 r_out->write(toFloat(color.getRed()));
arnedesmet 0:92d2ef9f009d 17 g_out->write(toFloat(color.getGreen()));
arnedesmet 0:92d2ef9f009d 18 b_out->write(toFloat(color.getBlue()));
arnedesmet 0:92d2ef9f009d 19 }
arnedesmet 0:92d2ef9f009d 20
arnedesmet 0:92d2ef9f009d 21 void RGB::setColor(int red, int green, int blue){
arnedesmet 0:92d2ef9f009d 22 r_out->write(toFloat(red));
arnedesmet 0:92d2ef9f009d 23 g_out->write(toFloat(green));
arnedesmet 0:92d2ef9f009d 24 b_out->write(toFloat(blue));
arnedesmet 0:92d2ef9f009d 25 }
arnedesmet 0:92d2ef9f009d 26
arnedesmet 0:92d2ef9f009d 27 void RGB::setColor(int color){
arnedesmet 0:92d2ef9f009d 28 Color kleur = Color(color);
arnedesmet 0:92d2ef9f009d 29 r_out->write(toFloat(kleur.getRed()));
arnedesmet 0:92d2ef9f009d 30 g_out->write(toFloat(kleur.getGreen()));
arnedesmet 0:92d2ef9f009d 31 b_out->write(toFloat(kleur.getBlue()));
arnedesmet 0:92d2ef9f009d 32 }
arnedesmet 0:92d2ef9f009d 33
arnedesmet 0:92d2ef9f009d 34
arnedesmet 0:92d2ef9f009d 35