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.
Fork of RGBLED by
rgbled.cpp
00001 #include "mbed.h" 00002 #include "rgbled.h" 00003 00004 rgbled::rgbled(PinName pin_red, PinName pin_green, PinName pin_blue) 00005 : _pin_red(pin_red), _pin_green(pin_green), _pin_blue(pin_blue){ 00006 _on = false; 00007 _off = !_on; 00008 _pin_red = _off; 00009 _pin_green = _off; 00010 _pin_blue = _off; 00011 } 00012 00013 void rgbled::active(bool a){ 00014 _on = a; 00015 _off = !_on; 00016 } 00017 00018 void rgbled::_none(void){ 00019 _pin_red = _off; 00020 _pin_green = _off; 00021 _pin_blue = _off; 00022 } 00023 00024 void rgbled::_red(void){ 00025 _pin_red = _on; 00026 _pin_green = _off; 00027 _pin_blue = _off; 00028 } 00029 00030 void rgbled::_green(void){ 00031 _pin_red = _off; 00032 _pin_green = _on; 00033 _pin_blue = _off; 00034 } 00035 00036 void rgbled::_blue(void){ 00037 _pin_red = _off; 00038 _pin_green = _off; 00039 _pin_blue = _on; 00040 } 00041 00042 void rgbled::_cyan(void){ 00043 _pin_red = _off; 00044 _pin_green = _on; 00045 _pin_blue = _on; 00046 } 00047 00048 void rgbled::_yellow(void){ 00049 _pin_red = _on; 00050 _pin_green = _on; 00051 _pin_blue = _off; 00052 } 00053 00054 void rgbled::_magenta(void){ 00055 _pin_red = _on; 00056 _pin_green = _off; 00057 _pin_blue = _on; 00058 } 00059 00060 void rgbled::set(color c){ 00061 switch (c) { 00062 case none : 00063 _none(); 00064 break; 00065 case red : 00066 _red(); 00067 break; 00068 case yellow : 00069 _yellow(); 00070 break; 00071 case green : 00072 _green(); 00073 break; 00074 case cyan: 00075 _cyan(); 00076 break; 00077 case blue : 00078 _blue(); 00079 break; 00080 case magenta : 00081 _magenta(); 00082 break; 00083 } 00084 }
Generated on Wed Jul 20 2022 23:24:26 by
1.7.2
