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: C12832 LM75B mbed EthernetInterface mbed-rtos
rgb.cpp
00001 #include "mbed.h" 00002 #include "rgb.h" 00003 00004 namespace ProjectOne{ 00005 00006 const float RGB::r_values[] = {0.0, 1.0, 1.0, 0.0, 0.498, 0.0, 1.0}; 00007 const float RGB::g_values[] = {1.0, 0.0, 1.0, 0.353, 1.0, 0.0, 1.0}; 00008 const float RGB::b_values[] = {1.0, 1.0, 0.0, 1.0, 0.498, 0.0, 1.0}; 00009 00010 RGB::RGB(PinName r_pin, PinName g_pin, PinName b_pin) : r(r_pin), g(g_pin), b(b_pin){ 00011 turnOnLed(""); 00012 } 00013 00014 //Rood = 0, Groen = 1, Blauw = 2, Oranje = 3, Paars = 4, Wit = 5, Uit = 6 00015 void RGB::turnOnLed(string kleur){ 00016 int array_index = determineRgbIndex(kleur); 00017 r = r_values[array_index]; 00018 g = g_values[array_index]; 00019 b = b_values[array_index]; 00020 } 00021 00022 int RGB::determineRgbIndex(string kleur){ 00023 if(kleur == "RED"){ 00024 return 0; 00025 } 00026 else if(kleur == "GREEN"){ 00027 return 1; 00028 } 00029 else if(kleur == "BLUE"){ 00030 return 2; 00031 } 00032 else if(kleur == "ORANGE"){ 00033 return 3; 00034 } 00035 else if(kleur == "PURPLE"){ 00036 return 4; 00037 } 00038 else if(kleur == "WHITE"){ 00039 return 5; 00040 } 00041 else{ 00042 return 6; 00043 } 00044 } 00045 00046 } 00047 00048
Generated on Sat Jul 23 2022 22:59:36 by
1.7.2