test

Dependencies:   LM75B Color mbed yeswecancoap Rgb

Committer:
de_geeter_alexander
Date:
Fri Oct 23 13:37:50 2015 +0000
Revision:
0:06473a4ace3b
test

Who changed what in which revision?

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