Part One of my Project Course. Implementation of simple I/O and a custom defined protocol over UDP/IP.

Dependencies:   C12832 LM75B mbed EthernetInterface mbed-rtos

Committer:
bertgereels
Date:
Wed Mar 14 07:59:21 2018 +0000
Revision:
1:b5c534165dfe
Parent:
0:88d3b9015f7c
Added slave state machine.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bertgereels 0:88d3b9015f7c 1 #include "mbed.h"
bertgereels 0:88d3b9015f7c 2 #include "rgb.h"
bertgereels 0:88d3b9015f7c 3
bertgereels 0:88d3b9015f7c 4 namespace ProjectOne{
bertgereels 0:88d3b9015f7c 5
bertgereels 0:88d3b9015f7c 6 const float RGB::r_values[] = {0.0, 1.0, 1.0, 0.0, 0.498, 0.0, 1.0};
bertgereels 0:88d3b9015f7c 7 const float RGB::g_values[] = {1.0, 0.0, 1.0, 0.353, 1.0, 0.0, 1.0};
bertgereels 0:88d3b9015f7c 8 const float RGB::b_values[] = {1.0, 1.0, 0.0, 1.0, 0.498, 0.0, 1.0};
bertgereels 0:88d3b9015f7c 9
bertgereels 0:88d3b9015f7c 10 RGB::RGB(PinName r_pin, PinName g_pin, PinName b_pin) : r(r_pin), g(g_pin), b(b_pin){
bertgereels 1:b5c534165dfe 11 turnOnLed("");
bertgereels 0:88d3b9015f7c 12 }
bertgereels 0:88d3b9015f7c 13
bertgereels 0:88d3b9015f7c 14 //Rood = 0, Groen = 1, Blauw = 2, Oranje = 3, Paars = 4, Wit = 5, Uit = 6
bertgereels 1:b5c534165dfe 15 void RGB::turnOnLed(string kleur){
bertgereels 1:b5c534165dfe 16 int array_index = determineRgbIndex(kleur);
bertgereels 1:b5c534165dfe 17 r = r_values[array_index];
bertgereels 1:b5c534165dfe 18 g = g_values[array_index];
bertgereels 1:b5c534165dfe 19 b = b_values[array_index];
bertgereels 1:b5c534165dfe 20 }
bertgereels 1:b5c534165dfe 21
bertgereels 1:b5c534165dfe 22 int RGB::determineRgbIndex(string kleur){
bertgereels 1:b5c534165dfe 23 if(kleur == "RED"){
bertgereels 1:b5c534165dfe 24 return 0;
bertgereels 1:b5c534165dfe 25 }
bertgereels 1:b5c534165dfe 26 else if(kleur == "GREEN"){
bertgereels 1:b5c534165dfe 27 return 1;
bertgereels 1:b5c534165dfe 28 }
bertgereels 1:b5c534165dfe 29 else if(kleur == "BLUE"){
bertgereels 1:b5c534165dfe 30 return 2;
bertgereels 1:b5c534165dfe 31 }
bertgereels 1:b5c534165dfe 32 else if(kleur == "ORANGE"){
bertgereels 1:b5c534165dfe 33 return 3;
bertgereels 1:b5c534165dfe 34 }
bertgereels 1:b5c534165dfe 35 else if(kleur == "PURPLE"){
bertgereels 1:b5c534165dfe 36 return 4;
bertgereels 1:b5c534165dfe 37 }
bertgereels 1:b5c534165dfe 38 else if(kleur == "WHITE"){
bertgereels 1:b5c534165dfe 39 return 5;
bertgereels 1:b5c534165dfe 40 }
bertgereels 1:b5c534165dfe 41 else{
bertgereels 1:b5c534165dfe 42 return 6;
bertgereels 1:b5c534165dfe 43 }
bertgereels 0:88d3b9015f7c 44 }
bertgereels 0:88d3b9015f7c 45
bertgereels 0:88d3b9015f7c 46 }
bertgereels 0:88d3b9015f7c 47
bertgereels 0:88d3b9015f7c 48