
Project Template for Headstart Course 2017
Dependencies: N5110 ShiftReg Tone mbed
Fork of 1620_Project_Template by
Diff: ModeB/ModeB.cpp
- Revision:
- 2:0f91b789d90a
- Parent:
- 0:d5312060f649
- Child:
- 3:625925922d09
--- a/ModeB/ModeB.cpp Mon Mar 13 07:01:51 2017 +0000 +++ b/ModeB/ModeB.cpp Mon Jul 10 10:07:01 2017 +0000 @@ -1,18 +1,53 @@ #include "ModeB.h" +float voltage_a = 0.0; +float voltage_b = 0.0; +float voltage_c = 0.0; + void mode_B() { lcd.clear(); lcd.printString("Mode B",0,0); lcd.refresh(); + update_display(); + wait_ms(250); while (button_b.read() == 0) { - - // code goes in here - this acts like the main while(1) loop + + //All code goes in here! + + + + + update_display(); } +} + +void update_display(){ + + int red_percent = 100.0 - (red_led/1.0) * 100.0; + int blue_percent = 100.0 - (blue_led/1.0) * 100.0; + int green_percent = 100.0 -(green_led/1.0) * 100.0; + + char new_string[3]; + lcd.printString("R G B ",0,2); + sprintf(new_string, "%d%% ", red_percent); + lcd.printString(new_string,0,3); + sprintf(new_string, "%d%% ", green_percent); + lcd.printString(new_string,30,3); + sprintf(new_string, "%d%% ", blue_percent); + lcd.printString(new_string,60,3); + sprintf(new_string, "%.1fV ", voltage_a); + lcd.printString(new_string,0,3); + sprintf(new_string, "%.1fV ", voltage_b); + lcd.printString(new_string,30,3); + sprintf(new_string, "%.1fV ", voltage_c); + lcd.printString(new_string,60,3); + lcd.refresh(); + } \ No newline at end of file