Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 }
Generated on Sat Jul 16 2022 20:39:52 by
1.7.2