RGB LED Class

Dependencies:   mbed

Fork of RGBLED by Steven Cheldelin

Committer:
rcflyair
Date:
Mon Jun 09 14:17:39 2014 +0000
Revision:
0:7c0b6a649748
First version non-library version without doxy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rcflyair 0:7c0b6a649748 1 #include "mbed.h"
rcflyair 0:7c0b6a649748 2 #include "rgbled.h"
rcflyair 0:7c0b6a649748 3
rcflyair 0:7c0b6a649748 4 rgbled::rgbled(PinName pin_red, PinName pin_green, PinName pin_blue)
rcflyair 0:7c0b6a649748 5 : _pin_red(pin_red), _pin_green(pin_green), _pin_blue(pin_blue){
rcflyair 0:7c0b6a649748 6 _on = false;
rcflyair 0:7c0b6a649748 7 _off = !_on;
rcflyair 0:7c0b6a649748 8 _pin_red = _off;
rcflyair 0:7c0b6a649748 9 _pin_green = _off;
rcflyair 0:7c0b6a649748 10 _pin_blue = _off;
rcflyair 0:7c0b6a649748 11 }
rcflyair 0:7c0b6a649748 12
rcflyair 0:7c0b6a649748 13 void rgbled::active(bool a){
rcflyair 0:7c0b6a649748 14 _on = a;
rcflyair 0:7c0b6a649748 15 _off = !_on;
rcflyair 0:7c0b6a649748 16 }
rcflyair 0:7c0b6a649748 17
rcflyair 0:7c0b6a649748 18 void rgbled::_none(void){
rcflyair 0:7c0b6a649748 19 _pin_red = _off;
rcflyair 0:7c0b6a649748 20 _pin_green = _off;
rcflyair 0:7c0b6a649748 21 _pin_blue = _off;
rcflyair 0:7c0b6a649748 22 }
rcflyair 0:7c0b6a649748 23
rcflyair 0:7c0b6a649748 24 void rgbled::_red(void){
rcflyair 0:7c0b6a649748 25 _pin_red = _on;
rcflyair 0:7c0b6a649748 26 _pin_green = _off;
rcflyair 0:7c0b6a649748 27 _pin_blue = _off;
rcflyair 0:7c0b6a649748 28 }
rcflyair 0:7c0b6a649748 29
rcflyair 0:7c0b6a649748 30 void rgbled::_green(void){
rcflyair 0:7c0b6a649748 31 _pin_red = _off;
rcflyair 0:7c0b6a649748 32 _pin_green = _on;
rcflyair 0:7c0b6a649748 33 _pin_blue = _off;
rcflyair 0:7c0b6a649748 34 }
rcflyair 0:7c0b6a649748 35
rcflyair 0:7c0b6a649748 36 void rgbled::_blue(void){
rcflyair 0:7c0b6a649748 37 _pin_red = _off;
rcflyair 0:7c0b6a649748 38 _pin_green = _off;
rcflyair 0:7c0b6a649748 39 _pin_blue = _on;
rcflyair 0:7c0b6a649748 40 }
rcflyair 0:7c0b6a649748 41
rcflyair 0:7c0b6a649748 42 void rgbled::set(color c){
rcflyair 0:7c0b6a649748 43 switch (c) {
rcflyair 0:7c0b6a649748 44 case none :
rcflyair 0:7c0b6a649748 45 _none();
rcflyair 0:7c0b6a649748 46 break;
rcflyair 0:7c0b6a649748 47 case red :
rcflyair 0:7c0b6a649748 48 _red();
rcflyair 0:7c0b6a649748 49 break;
rcflyair 0:7c0b6a649748 50 case green :
rcflyair 0:7c0b6a649748 51 _green();
rcflyair 0:7c0b6a649748 52 break;
rcflyair 0:7c0b6a649748 53 case blue :
rcflyair 0:7c0b6a649748 54 _blue();
rcflyair 0:7c0b6a649748 55 break;
rcflyair 0:7c0b6a649748 56 }
rcflyair 0:7c0b6a649748 57 }