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.
Dependencies: 4DGL-uLCD-SE PinDetect SDFileSystem mbed wave_player
RGBLED.h
00001 /****************************************************** 00002 * This header program declares all the functions and 00003 * variables used by RGB LED component. 00004 ******************************************************/ 00005 00006 00007 // Class to control an RGB LED using three PWM pins 00008 class RGBLED { 00009 public: 00010 // RGBLED constructor 00011 RGBLED(PinName redPin, PinName greenPin, PinName bluePin) : red(redPin), green(greenPin), blue(bluePin) { 00012 red.period(0.0005); 00013 green.period(0.0005); 00014 blue.period(0.0005); 00015 red = 0.0; 00016 green = 0.0; 00017 blue = 0.0; 00018 } 00019 00020 RGBLED operator=(int color) { 00021 write(color); 00022 return *this; 00023 } 00024 00025 00026 private: 00027 PwmOut red; 00028 PwmOut green; 00029 PwmOut blue; 00030 00031 void write(int color) { 00032 red = (color >> 16) / 255.0 / 16.0; 00033 green = ((color >> 8) & 0xFF) / 255.0 / 16.0; 00034 blue = (color & 0xFF) / 255.0 / 16.0; 00035 } 00036 };
Generated on Mon Aug 1 2022 07:20:13 by
1.7.2