reduce to 1 decimal place
This commit is contained in:
parent
a63db5b0a4
commit
be3c8d0ef5
|
@ -10,7 +10,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <iomanip> // for std::setprecision
|
||||||
|
|
||||||
const std::string error_txt[16] = {
|
const std::string error_txt[16] = {
|
||||||
"Reset Button", //0
|
"Reset Button", //0
|
||||||
|
@ -163,13 +163,11 @@ void readStatus(){
|
||||||
|
|
||||||
std::string FormatDouble(double value){
|
std::string FormatDouble(double value){
|
||||||
|
|
||||||
std::string str_value = std::to_string(value);
|
int decimalPlaces = 1;
|
||||||
size_t dot_position = str_value.find('.');
|
std::ostringstream oss;
|
||||||
if (dot_position != std::string::npos && str_value.length() > dot_position + 3) {
|
oss << std::fixed << std::setprecision(decimalPlaces) << value;
|
||||||
str_value = str_value.substr(0, dot_position + 3);
|
return oss.str();
|
||||||
}
|
|
||||||
|
|
||||||
return str_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
@ -233,14 +231,15 @@ int main() {
|
||||||
textDisplay( "Pre-Accel. supply : ", 750, 455, blackColor); // pre-accel. supply text
|
textDisplay( "Pre-Accel. supply : ", 750, 455, blackColor); // pre-accel. supply text
|
||||||
textDisplay( preAccel ? "On" : "Off", 950, 455, preAccel ? greenColor : redColor); // pre-accel. supply text
|
textDisplay( preAccel ? "On" : "Off", 950, 455, preAccel ? greenColor : redColor); // pre-accel. supply text
|
||||||
|
|
||||||
textDisplay( "HV Supply : ", 30, 200, blackColor);
|
int yPos = 300;
|
||||||
textDisplay( hv ? "On" : "Off", 230, 200, hv ? greenColor : redColor);
|
textDisplay( "HV Supply : ", 30, yPos, blackColor);
|
||||||
|
textDisplay( hv ? "On" : "Off", 230, yPos, hv ? greenColor : redColor);
|
||||||
|
|
||||||
textDisplay( "Boiler Supply : ", 30, 240, blackColor);
|
textDisplay( "Boiler Supply : ", 30, yPos + 40, blackColor);
|
||||||
textDisplay( boiler ? "On" : "Off", 230, 240, boiler ? greenColor : redColor);
|
textDisplay( boiler ? "On" : "Off", 230, yPos + 40, boiler ? greenColor : redColor);
|
||||||
|
|
||||||
textDisplay( "Ionizer Supply : ", 30, 280, blackColor);
|
textDisplay( "Ionizer Supply : ", 30, yPos + 80, blackColor);
|
||||||
textDisplay( ionizer ? "On" : "Off", 230, 280, ionizer ? greenColor : redColor);
|
textDisplay( ionizer ? "On" : "Off", 230, yPos + 80, ionizer ? greenColor : redColor);
|
||||||
|
|
||||||
switch (statusReading){
|
switch (statusReading){
|
||||||
case 0: textDisplay( "Start-Up", 10, 40, blueColor); break;
|
case 0: textDisplay( "Start-Up", 10, 40, blueColor); break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user