Alexander De Geeter / Rgb

Dependents:   coap

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rgb.cpp Source File

rgb.cpp

00001 #include "rgb.h"
00002 
00003 RGB::RGB(PinName r_pin, PinName g_pin, PinName b_pin){
00004     this->r_out=new PwmOut(r_pin);
00005     this->g_out=new PwmOut(g_pin);
00006     this->b_out=new PwmOut(b_pin);
00007     setColor(0,0,0);
00008     }
00009 
00010 void RGB::setColor(int red, int green, int blue){
00011     r_out->write(1.0-toFloat(red));
00012     g_out->write(1.0-toFloat(green));
00013     b_out->write(1.0-toFloat(blue));
00014     }
00015 
00016 void RGB::setColor(int color){
00017     Color kleur=Color(color);
00018     r_out->write(1.0-toFloat(kleur.getRed()));
00019     g_out->write(1.0-toFloat(kleur.getGreen()));
00020     b_out->write(1.0-toFloat(kleur.getBlue()));
00021     }
00022 
00023 void RGB::setColor(Color color){
00024     r_out->write(toFloat(color.getRed()));
00025     g_out->write(toFloat(color.getGreen()));
00026     b_out->write(toFloat(color.getBlue()));
00027     }
00028     
00029 
00030 float RGB::toFloat (int floater){
00031     return (float) ((floater)/255.0f);
00032     }