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: N5110 ShiftReg Tone mbed
Fork of 1620_Project_Template by
ModeB/ModeB.cpp
- Committer:
- eendmo
- Date:
- 2017-07-10
- Revision:
- 2:0f91b789d90a
- Parent:
- 0:d5312060f649
- Child:
- 3:625925922d09
File content as of revision 2:0f91b789d90a:
#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) {
//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();
}
