reduce to 1 decimal place

This commit is contained in:
Ryan Tang 2024-02-08 17:50:40 -05:00
parent a63db5b0a4
commit be3c8d0ef5

View File

@ -10,7 +10,7 @@
#include <string>
#include <sstream>
#include <vector>
#include <iomanip> // for std::setprecision
const std::string error_txt[16] = {
"Reset Button", //0
@ -163,13 +163,11 @@ void readStatus(){
std::string FormatDouble(double value){
std::string str_value = std::to_string(value);
size_t dot_position = str_value.find('.');
if (dot_position != std::string::npos && str_value.length() > dot_position + 3) {
str_value = str_value.substr(0, dot_position + 3);
}
int decimalPlaces = 1;
std::ostringstream oss;
oss << std::fixed << std::setprecision(decimalPlaces) << value;
return oss.str();
return str_value;
}
int main() {
@ -233,14 +231,15 @@ int main() {
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( "HV Supply : ", 30, 200, blackColor);
textDisplay( hv ? "On" : "Off", 230, 200, hv ? greenColor : redColor);
int yPos = 300;
textDisplay( "HV Supply : ", 30, yPos, blackColor);
textDisplay( hv ? "On" : "Off", 230, yPos, hv ? greenColor : redColor);
textDisplay( "Boiler Supply : ", 30, 240, blackColor);
textDisplay( boiler ? "On" : "Off", 230, 240, boiler ? greenColor : redColor);
textDisplay( "Boiler Supply : ", 30, yPos + 40, blackColor);
textDisplay( boiler ? "On" : "Off", 230, yPos + 40, boiler ? greenColor : redColor);
textDisplay( "Ionizer Supply : ", 30, 280, blackColor);
textDisplay( ionizer ? "On" : "Off", 230, 280, ionizer ? greenColor : redColor);
textDisplay( "Ionizer Supply : ", 30, yPos + 80, blackColor);
textDisplay( ionizer ? "On" : "Off", 230, yPos + 80, ionizer ? greenColor : redColor);
switch (statusReading){
case 0: textDisplay( "Start-Up", 10, 40, blueColor); break;