j

Dependencies:   mbed yeswecancoap C12832 LM75B

Committer:
arnedesmet
Date:
Fri Oct 23 14:58:08 2015 +0000
Revision:
1:92958e26bf2e
Parent:
0:92d2ef9f009d
mlkj;

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 1:92958e26bf2e 15 delete this->color;
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 1:92958e26bf2e 19 this->color = &color;
arnedesmet 0:92d2ef9f009d 20 }
arnedesmet 0:92d2ef9f009d 21
arnedesmet 0:92d2ef9f009d 22 void RGB::setColor(int red, int green, int blue){
arnedesmet 1:92958e26bf2e 23 delete this->color;
arnedesmet 0:92d2ef9f009d 24 r_out->write(toFloat(red));
arnedesmet 0:92d2ef9f009d 25 g_out->write(toFloat(green));
arnedesmet 0:92d2ef9f009d 26 b_out->write(toFloat(blue));
arnedesmet 1:92958e26bf2e 27 this->color = new Color(red, green, blue);
arnedesmet 0:92d2ef9f009d 28 }
arnedesmet 0:92d2ef9f009d 29
arnedesmet 0:92d2ef9f009d 30 void RGB::setColor(int color){
arnedesmet 1:92958e26bf2e 31 delete this->color;
arnedesmet 1:92958e26bf2e 32 Color* kleur = new Color(color);
arnedesmet 1:92958e26bf2e 33 r_out->write(toFloat(kleur->getRed()));
arnedesmet 1:92958e26bf2e 34 g_out->write(toFloat(kleur->getGreen()));
arnedesmet 1:92958e26bf2e 35 b_out->write(toFloat(kleur->getBlue()));
arnedesmet 1:92958e26bf2e 36 this->color = kleur;
arnedesmet 0:92d2ef9f009d 37 }
arnedesmet 0:92d2ef9f009d 38
arnedesmet 1:92958e26bf2e 39 Color* RGB::getColor(){
arnedesmet 1:92958e26bf2e 40 return color;
arnedesmet 1:92958e26bf2e 41 }
arnedesmet 0:92d2ef9f009d 42