Multi-game multiplayer arcade gaming system meant for the blue O when playing Super Tic-Tac-Toe.
Dependencies: 4DGL-uLCD-SE PinDetect SDFileSystem mbed wave_player
Diff: RGBLED.h
- Revision:
- 0:218d3fb75950
- Child:
- 2:da0f01fbd25c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RGBLED.h Thu Nov 26 02:58:17 2015 +0000 @@ -0,0 +1,30 @@ +// Class to control an RGB LED using three PWM pins +class RGBLED { + public: + // RGBLED constructor + RGBLED(PinName redPin, PinName greenPin, PinName bluePin) : red(redPin), green(greenPin), blue(bluePin) { + red.period(0.0005); + green.period(0.0005); + blue.period(0.0005); + red = 0.0; + green = 0.0; + blue = 0.0; + } + + RGBLED operator=(int color) { + write(color); + return *this; + } + + + private: + PwmOut red; + PwmOut green; + PwmOut blue; + + void write(int color) { + red = (color >> 16) / 255.0 / 16.0; + green = ((color >> 8) & 0xFF) / 255.0 / 16.0; + blue = (color & 0xFF) / 255.0 / 16.0; + } +}; \ No newline at end of file