diff --git a/lib/obp60task/OBP60Extensions.cpp b/lib/obp60task/OBP60Extensions.cpp index 5715b99..b4b5b67 100644 --- a/lib/obp60task/OBP60Extensions.cpp +++ b/lib/obp60task/OBP60Extensions.cpp @@ -521,7 +521,7 @@ void displayHeader(CommonData &commonData, bool symbolmode, GwApi::BoatValue *da epd->print("USB "); } } - double gpshdop = formatValue(hdop, commonData).value; + double gpshdop = commonData.fmt->formatValue(hdop, commonData).value; if(commonData.config->getString(commonData.config->useGPS) != "off" && gpshdop <= commonData.config->getInt(commonData.config->hdopAccuracy) && hdop->valid == true){ if (symbolmode) { epd->drawXBitmap(symbol_x, 1, iconmap["GPS"], icon_width, icon_height, commonData.fgcolor); @@ -606,9 +606,9 @@ void displayHeader(CommonData &commonData, bool symbolmode, GwApi::BoatValue *da else if (timesource == "GPS") { // Show date and time if date present if(date->valid == true){ - String acttime = formatValue(time, commonData).svalue; + String acttime = commonData.fmt->formatValue(time, commonData).svalue; acttime = acttime.substring(0, 5); - String actdate = formatValue(date, commonData).svalue; + String actdate = commonData.fmt->formatValue(date, commonData).svalue; epd->print(acttime); epd->print(" "); epd->print(actdate); diff --git a/lib/obp60task/OBP60Formatter.cpp b/lib/obp60task/OBP60Formatter.cpp index 8f4f26f..6a0380f 100644 --- a/lib/obp60task/OBP60Formatter.cpp +++ b/lib/obp60task/OBP60Formatter.cpp @@ -22,76 +22,7 @@ Formatter::Formatter(GwConfigHandler *config) { dateFormat = config->getString(config->dateFormat); usesimudata = config->getBool(config->useSimuData); precision = config->getString(config->valueprecision); -} -String formatDate(String fmttype, uint16_t year, uint8_t month, uint8_t day) { - char buffer[12]; - if (fmttype == "GB") { - snprintf(buffer, 12, "%02d/%02d/%04d", day , month, year); - } - else if (fmttype == "US") { - snprintf(buffer, 12, "%02d/%02d/%04d", month, day, year); - } - else if (fmttype == "ISO") { - snprintf(buffer, 12, "%04d-%02d-%02d", year, month, day); - } - else { - snprintf(buffer, 12, "%02d.%02d.%04d", day, month, year); - } - return String(buffer); -} - -String formatTime(char fmttype, uint8_t hour, uint8_t minute, uint8_t second) { - // fmttype: s: with seconds, m: only minutes - char buffer[10]; - if (fmttype == 'm') { - snprintf(buffer, 10, "%02d:%02d", hour , minute); - } - else { - snprintf(buffer, 10, "%02d:%02d:%02d", hour, minute, second); - } - return String(buffer); -} - -String formatLatitude(double lat) { - float degree = abs(int(lat)); - float minute = abs((lat - int(lat)) * 60); - return String(degree, 0) + "\x90 " + String(minute, 4) + "' " + ((lat > 0) ? "N" : "S"); -} - -String formatLongitude(double lon) { - float degree = abs(int(lon)); - float minute = abs((lon - int(lon)) * 60); - return String(degree, 0) + "\x90 " + String(minute, 4) + "' " + ((lon > 0) ? "E" : "W"); -} - -FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ - GwLog *logger = commondata.logger; - FormattedData result; - static int dayoffset = 0; - double rawvalue = 0; - - // Load configuration values - String stimeZone = commondata.config->getString(commondata.config->timeZone); // [UTC -14.00...+12.00] - double timeZone = stimeZone.toDouble(); - String lengthFormat = commondata.config->getString(commondata.config->lengthFormat); // [m|ft] - String distanceFormat = commondata.config->getString(commondata.config->distanceFormat); // [m|km|nm] - String speedFormat = commondata.config->getString(commondata.config->speedFormat); // [m/s|km/h|kn] - String windspeedFormat = commondata.config->getString(commondata.config->windspeedFormat); // [m/s|km/h|kn|bft] - String tempFormat = commondata.config->getString(commondata.config->tempFormat); // [K|°C|°F] - String dateFormat = commondata.config->getString(commondata.config->dateFormat); // [DE|GB|US] - bool usesimudata = commondata.config->getBool(commondata.config->useSimuData); // [on|off] - String precision = commondata.config->getString(commondata.config->valueprecision); // [1|2] - - // If boat value not valid - if (! value->valid && !usesimudata){ - result.svalue = "---"; - return result; - } - - const char* fmt_dec_1; - const char* fmt_dec_10; - const char* fmt_dec_100; if (precision == "1") { fmt_dec_1 = "%3.1f"; fmt_dec_10 = "%3.0f"; @@ -102,6 +33,20 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ fmt_dec_100 = "%3.0f"; } +} + +FormattedData Formatter::formatValue(GwApi::BoatValue *value, CommonData &commondata){ + GwLog *logger = commondata.logger; + FormattedData result; + static int dayoffset = 0; + double rawvalue = 0; + + // If boat value not valid + if (! value->valid && !usesimudata){ + result.svalue = "---"; + return result; + } + // LOG_DEBUG(GwLog::DEBUG,"formatValue init: getFormat: %s date->value: %f time->value: %f", value->getFormat(), commondata.date->value, commondata.time->value); static const int bsize = 30; char buffer[bsize+1]; @@ -857,4 +802,45 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ return result; } +String formatDate(String fmttype, uint16_t year, uint8_t month, uint8_t day) { + char buffer[12]; + if (fmttype == "GB") { + snprintf(buffer, 12, "%02d/%02d/%04d", day , month, year); + } + else if (fmttype == "US") { + snprintf(buffer, 12, "%02d/%02d/%04d", month, day, year); + } + else if (fmttype == "ISO") { + snprintf(buffer, 12, "%04d-%02d-%02d", year, month, day); + } + else { + snprintf(buffer, 12, "%02d.%02d.%04d", day, month, year); + } + return String(buffer); +} + +String formatTime(char fmttype, uint8_t hour, uint8_t minute, uint8_t second) { + // fmttype: s: with seconds, m: only minutes + char buffer[10]; + if (fmttype == 'm') { + snprintf(buffer, 10, "%02d:%02d", hour , minute); + } + else { + snprintf(buffer, 10, "%02d:%02d:%02d", hour, minute, second); + } + return String(buffer); +} + +String formatLatitude(double lat) { + float degree = abs(int(lat)); + float minute = abs((lat - int(lat)) * 60); + return String(degree, 0) + "\x90 " + String(minute, 4) + "' " + ((lat > 0) ? "N" : "S"); +} + +String formatLongitude(double lon) { + float degree = abs(int(lon)); + float minute = abs((lon - int(lon)) * 60); + return String(degree, 0) + "\x90 " + String(minute, 4) + "' " + ((lon > 0) ? "E" : "W"); +} + #endif diff --git a/lib/obp60task/OBP60Formatter.h b/lib/obp60task/OBP60Formatter.h index 72360f2..7977cfe 100644 --- a/lib/obp60task/OBP60Formatter.h +++ b/lib/obp60task/OBP60Formatter.h @@ -96,8 +96,6 @@ typedef struct { } FormattedData; // Formatter for boat values -FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata); - class Formatter { private: String stimeZone = "0"; @@ -109,9 +107,15 @@ private: String tempFormat = "C"; // [K|°C|°F] String dateFormat = "ISO"; // [DE|GB|US|ISO] bool usesimudata = false; // [on|off] + String precision = "2"; // [1|2] + const char* fmt_dec_1; + const char* fmt_dec_10; + const char* fmt_dec_100; + public: Formatter(GwConfigHandler *config); + FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata); }; // Standard format functions without overhead diff --git a/lib/obp60task/PageAnchor.cpp b/lib/obp60task/PageAnchor.cpp index 0f49365..ee679de 100644 --- a/lib/obp60task/PageAnchor.cpp +++ b/lib/obp60task/PageAnchor.cpp @@ -77,22 +77,22 @@ private: // Boatvalues: DBS, HDT, AWS, AWD, LAT, LON, HDOP GwApi::BoatValue *bv_dbs = pageData.values[0]; // DBS - String sval_dbs = formatValue(bv_dbs, *commonData).svalue; - String sunit_dbs = formatValue(bv_dbs, *commonData).unit; + String sval_dbs = commonData->fmt->formatValue(bv_dbs, *commonData).svalue; + String sunit_dbs = commonData->fmt->formatValue(bv_dbs, *commonData).unit; GwApi::BoatValue *bv_hdt = pageData.values[1]; // HDT - String sval_hdt = formatValue(bv_hdt, *commonData).svalue; + String sval_hdt = commonData->fmt->formatValue(bv_hdt, *commonData).svalue; GwApi::BoatValue *bv_aws = pageData.values[2]; // AWS - String sval_aws = formatValue(bv_aws, *commonData).svalue; - String sunit_aws = formatValue(bv_aws, *commonData).unit; + String sval_aws = commonData->fmt->formatValue(bv_aws, *commonData).svalue; + String sunit_aws = commonData->fmt->formatValue(bv_aws, *commonData).unit; GwApi::BoatValue *bv_awd = pageData.values[3]; // AWD - String sval_awd = formatValue(bv_awd, *commonData).svalue; + String sval_awd = commonData->fmt->formatValue(bv_awd, *commonData).svalue; GwApi::BoatValue *bv_lat = pageData.values[4]; // LAT - String sval_lat = formatValue(bv_lat, *commonData).svalue; + String sval_lat = commonData->fmt->formatValue(bv_lat, *commonData).svalue; GwApi::BoatValue *bv_lon = pageData.values[5]; // LON - String sval_lon = formatValue(bv_lon, *commonData).svalue; + String sval_lon = commonData->fmt->formatValue(bv_lon, *commonData).svalue; GwApi::BoatValue *bv_hdop = pageData.values[6]; // HDOP - String sval_hdop = formatValue(bv_hdop, *commonData).svalue; - String sunit_hdop = formatValue(bv_hdop, *commonData).unit; + String sval_hdop = commonData->fmt->formatValue(bv_hdop, *commonData).svalue; + String sunit_hdop = commonData->fmt->formatValue(bv_hdop, *commonData).unit; logger->logDebug(GwLog::DEBUG, "Drawing at PageAnchor; DBS=%f, HDT=%f, AWS=%f", bv_dbs->value, bv_hdt->value, bv_aws->value); diff --git a/lib/obp60task/PageClock.cpp b/lib/obp60task/PageClock.cpp index 7353b83..e00d31e 100644 --- a/lib/obp60task/PageClock.cpp +++ b/lib/obp60task/PageClock.cpp @@ -135,8 +135,8 @@ public: value1 = simtime++; // Simulation data for time value 11:36 in seconds } // Other simulation data see OBP60Formatter.cpp bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value if(valid1 == true){ svalue1old = svalue1; // Save old value unit1old = unit1; // Save old unit @@ -148,8 +148,8 @@ public: name2 = name2.substring(0, 6); // String length limit for value name value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value + String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value if(valid2 == true){ svalue2old = svalue2; // Save old value unit2old = unit2; // Save old unit @@ -161,8 +161,8 @@ public: name3 = name3.substring(0, 6); // String length limit for value name value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value + String svalue3 = commonData->fmt->formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = commonData->fmt->formatValue(bvalue3, *commonData).unit; // Unit of value if(valid3 == true){ svalue3old = svalue3; // Save old value unit3old = unit3; // Save old unit diff --git a/lib/obp60task/PageCompass.cpp b/lib/obp60task/PageCompass.cpp index 658e8ad..3711b2b 100644 --- a/lib/obp60task/PageCompass.cpp +++ b/lib/obp60task/PageCompass.cpp @@ -88,10 +88,10 @@ public: for (int i = 0; i < HowManyValues; i++){ bvalue = pageData.values[i]; - TheFormattedData = formatValue(bvalue, *commonData); + TheFormattedData = commonData->fmt->formatValue(bvalue, *commonData); DataName[i] = xdrDelete(bvalue->getName()); DataName[i] = DataName[i].substring(0, 6); // String length limit for value name - DataUnits[i] = formatValue(bvalue, *commonData).unit; + DataUnits[i] = commonData->fmt->formatValue(bvalue, *commonData).unit; DataText[i] = TheFormattedData.svalue; // Formatted value as string including unit conversion and switching decimal places DataValue[i] = TheFormattedData.value; // Value as double in SI unit DataValid[i] = bvalue->valid; diff --git a/lib/obp60task/PageDST810.cpp b/lib/obp60task/PageDST810.cpp index 6ab025e..d0d246c 100644 --- a/lib/obp60task/PageDST810.cpp +++ b/lib/obp60task/PageDST810.cpp @@ -45,8 +45,8 @@ public: name1 = name1.substring(0, 6); // String length limit for value name double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue) @@ -54,8 +54,8 @@ public: name2 = name2.substring(0, 6); // String length limit for value name double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value + String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value // Get boat values #3 GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue) @@ -63,8 +63,8 @@ public: name3 = name3.substring(0, 6); // String length limit for value name double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value + String svalue3 = commonData->fmt->formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = commonData->fmt->formatValue(bvalue3, *commonData).unit; // Unit of value // Get boat values #4 GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue) @@ -72,8 +72,8 @@ public: name4 = name4.substring(0, 6); // String length limit for value name double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value + String svalue4 = commonData->fmt->formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = commonData->fmt->formatValue(bvalue4, *commonData).unit; // Unit of value // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ diff --git a/lib/obp60task/PageFourValues.cpp b/lib/obp60task/PageFourValues.cpp index 160d2f2..1fd99bb 100644 --- a/lib/obp60task/PageFourValues.cpp +++ b/lib/obp60task/PageFourValues.cpp @@ -57,8 +57,8 @@ public: calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list @@ -67,8 +67,8 @@ public: calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value + String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value // Get boat values #3 GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list @@ -77,8 +77,8 @@ public: calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value + String svalue3 = commonData->fmt->formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = commonData->fmt->formatValue(bvalue3, *commonData).unit; // Unit of value // Get boat values #4 GwApi::BoatValue *bvalue4 = pageData.values[3]; // Fourth element in list @@ -87,8 +87,8 @@ public: calibrationData.calibrateInstance(bvalue4, logger); // Check if boat data value is to be calibrated double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value + String svalue4 = commonData->fmt->formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = commonData->fmt->formatValue(bvalue4, *commonData).unit; // Unit of value // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? diff --git a/lib/obp60task/PageFourValues2.cpp b/lib/obp60task/PageFourValues2.cpp index 99f1f3b..51dfa06 100644 --- a/lib/obp60task/PageFourValues2.cpp +++ b/lib/obp60task/PageFourValues2.cpp @@ -57,8 +57,8 @@ public: calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue) @@ -67,8 +67,8 @@ public: calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value + String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value // Get boat values #3 GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue) @@ -77,8 +77,8 @@ public: calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value + String svalue3 = commonData->fmt->formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = commonData->fmt->formatValue(bvalue3, *commonData).unit; // Unit of value // Get boat values #4 GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue) @@ -87,8 +87,8 @@ public: calibrationData.calibrateInstance(bvalue4, logger); // Check if boat data value is to be calibrated double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value + String svalue4 = commonData->fmt->formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = commonData->fmt->formatValue(bvalue4, *commonData).unit; // Unit of value // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? diff --git a/lib/obp60task/PageOneValue.cpp b/lib/obp60task/PageOneValue.cpp index b90fefe..c7dbc33 100644 --- a/lib/obp60task/PageOneValue.cpp +++ b/lib/obp60task/PageOneValue.cpp @@ -52,8 +52,8 @@ public: calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? diff --git a/lib/obp60task/PageRudderPosition.cpp b/lib/obp60task/PageRudderPosition.cpp index 7573fff..93a6504 100644 --- a/lib/obp60task/PageRudderPosition.cpp +++ b/lib/obp60task/PageRudderPosition.cpp @@ -52,8 +52,8 @@ public: calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated value1 = bvalue1->value; // Raw value without unit convertion bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value if (valid1 == true) { value1old = value1; // Save old value diff --git a/lib/obp60task/PageSixValues.cpp b/lib/obp60task/PageSixValues.cpp index d29fa32..5745731 100644 --- a/lib/obp60task/PageSixValues.cpp +++ b/lib/obp60task/PageSixValues.cpp @@ -68,8 +68,8 @@ public: calibrationData.calibrateInstance(bvalue, logger); // Check if boat data value is to be calibrated DataValue[i] = bvalue->value; // Value as double in SI unit DataValid[i] = bvalue->valid; - DataText[i] = formatValue(bvalue, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - DataUnits[i] = formatValue(bvalue, *commonData).unit; + DataText[i] = commonData->fmt->formatValue(bvalue, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + DataUnits[i] = commonData->fmt->formatValue(bvalue, *commonData).unit; DataFormat[i] = bvalue->getFormat(); // Unit of value } diff --git a/lib/obp60task/PageSkyView.cpp b/lib/obp60task/PageSkyView.cpp index 9c9d993..4a3a7cf 100644 --- a/lib/obp60task/PageSkyView.cpp +++ b/lib/obp60task/PageSkyView.cpp @@ -50,17 +50,17 @@ public: epd->setFont(&Ubuntu_Bold8pt8b); GwApi::BoatValue *bv_lat = pageData.values[0]; - String sv_lat = formatValue(bv_lat, *commonData).svalue; + String sv_lat = commonData->fmt->formatValue(bv_lat, *commonData).svalue; //epd->setCursor(300, 40); //epd->print(sv_lat); GwApi::BoatValue *bv_lon = pageData.values[1]; - String sv_lon = formatValue(bv_lon, *commonData).svalue; + String sv_lon = commonData->fmt->formatValue(bv_lon, *commonData).svalue; //epd->setCursor(300, 60); //epd->print(sv_lon); GwApi::BoatValue *bv_hdop = pageData.values[2]; - String sv_hdop = formatValue(bv_hdop, *commonData).svalue; + String sv_hdop = commonData->fmt->formatValue(bv_hdop, *commonData).svalue; //epd->setCursor(300, 80); //epd->print(sv_hdop); diff --git a/lib/obp60task/PageThreeValues.cpp b/lib/obp60task/PageThreeValues.cpp index 9288370..f40c73a 100644 --- a/lib/obp60task/PageThreeValues.cpp +++ b/lib/obp60task/PageThreeValues.cpp @@ -55,8 +55,8 @@ public: calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list @@ -65,8 +65,8 @@ public: calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value + String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value // Get boat values #3 GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list @@ -75,8 +75,8 @@ public: calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value + String svalue3 = commonData->fmt->formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = commonData->fmt->formatValue(bvalue3, *commonData).unit; // Unit of value // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? diff --git a/lib/obp60task/PageTwoValues.cpp b/lib/obp60task/PageTwoValues.cpp index 23c1ffc..53e9fc4 100644 --- a/lib/obp60task/PageTwoValues.cpp +++ b/lib/obp60task/PageTwoValues.cpp @@ -54,8 +54,8 @@ public: calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values #2 GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list @@ -64,8 +64,8 @@ public: calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value + String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? diff --git a/lib/obp60task/PageWind.cpp b/lib/obp60task/PageWind.cpp index 2a3f868..ec5c457 100644 --- a/lib/obp60task/PageWind.cpp +++ b/lib/obp60task/PageWind.cpp @@ -334,8 +334,8 @@ public: calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated double value1 = bvalue1->value; // Value as double in SI unit // bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value // Get boat values for angle (AWD/TWD) if (source == 'A') { @@ -351,8 +351,8 @@ public: if (simulation) { value2 = 0.62731; // some random value } - String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value + String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value // Logging boat values if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? diff --git a/lib/obp60task/PageWindPlot.cpp b/lib/obp60task/PageWindPlot.cpp index 5a30590..a30041d 100644 --- a/lib/obp60task/PageWindPlot.cpp +++ b/lib/obp60task/PageWindPlot.cpp @@ -261,8 +261,8 @@ public: calibrationData.calibrateInstance(bvalue, logger); // Check if boat data value is to be calibrated BDataValue[i] = bvalue->value; // Value as double in SI unit BDataValid[i] = bvalue->valid; - BDataText[i] = formatValue(bvalue, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - BDataUnit[i] = formatValue(bvalue, *commonData).unit; + BDataText[i] = commonData->fmt->formatValue(bvalue, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + BDataUnit[i] = commonData->fmt->formatValue(bvalue, *commonData).unit; BDataFormat[i] = bvalue->getFormat(); // Unit of value } @@ -459,7 +459,7 @@ public: wsValue = wsHstry->getLast(); wsBVal->value = wsValue; // temp variable to retreive data unit from OBP60Formater wsBVal->valid = (static_cast(wsValue) != wsHstry->getMinVal()); - wsUnit = formatValue(wsBVal, *commonData).unit; // Unit of value + wsUnit = commonData->fmt->formatValue(wsBVal, *commonData).unit; // Unit of value epd->fillRect(xPosTws - 4, yPosTws - 38, 142, 44, commonData->bgcolor); // Clear area for TWS value epd->setFont(&DSEG7Classic_BoldItalic16pt7b); epd->setCursor(xPosTws, yPosTws); diff --git a/lib/obp60task/PageWindRose.cpp b/lib/obp60task/PageWindRose.cpp index 6d5c183..b0440bb 100644 --- a/lib/obp60task/PageWindRose.cpp +++ b/lib/obp60task/PageWindRose.cpp @@ -62,9 +62,9 @@ public: calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - value1 = formatValue(bvalue1, *commonData).value;// Format only nesaccery for simulation data for pointer - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + value1 = commonData->fmt->formatValue(bvalue1, *commonData).value;// Format only nesaccery for simulation data for pointer + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value if(valid1 == true){ svalue1old = svalue1; // Save old value unit1old = unit1; // Save old unit @@ -77,8 +77,8 @@ public: calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated double value2 = bvalue2->value; // Value as double in SI unit bool valid2 = bvalue2->valid; // Valid information - String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value + String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value if(valid2 == true){ svalue2old = svalue2; // Save old value unit2old = unit2; // Save old unit @@ -91,8 +91,8 @@ public: calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value + String svalue3 = commonData->fmt->formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = commonData->fmt->formatValue(bvalue3, *commonData).unit; // Unit of value if(valid3 == true){ svalue3old = svalue3; // Save old value unit3old = unit3; // Save old unit @@ -105,8 +105,8 @@ public: calibrationData.calibrateInstance(bvalue4, logger); // Check if boat data value is to be calibrated double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value + String svalue4 = commonData->fmt->formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = commonData->fmt->formatValue(bvalue4, *commonData).unit; // Unit of value if(valid4 == true){ svalue4old = svalue4; // Save old value unit4old = unit4; // Save old unit @@ -119,8 +119,8 @@ public: calibrationData.calibrateInstance(bvalue5, logger); // Check if boat data value is to be calibrated double value5 = bvalue5->value; // Value as double in SI unit bool valid5 = bvalue5->valid; // Valid information - String svalue5 = formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit5 = formatValue(bvalue5, *commonData).unit; // Unit of value + String svalue5 = commonData->fmt->formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit5 = commonData->fmt->formatValue(bvalue5, *commonData).unit; // Unit of value if(valid5 == true){ svalue5old = svalue5; // Save old value unit5old = unit5; // Save old unit @@ -133,8 +133,8 @@ public: calibrationData.calibrateInstance(bvalue6, logger); // Check if boat data value is to be calibrated double value6 = bvalue6->value; // Value as double in SI unit bool valid6 = bvalue6->valid; // Valid information - String svalue6 = formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit6 = formatValue(bvalue6, *commonData).unit; // Unit of value + String svalue6 = commonData->fmt->formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit6 = commonData->fmt->formatValue(bvalue6, *commonData).unit; // Unit of value if(valid6 == true){ svalue6old = svalue6; // Save old value unit6old = unit6; // Save old unit diff --git a/lib/obp60task/PageWindRoseFlex.cpp b/lib/obp60task/PageWindRoseFlex.cpp index 576bc42..9ec0d89 100644 --- a/lib/obp60task/PageWindRoseFlex.cpp +++ b/lib/obp60task/PageWindRoseFlex.cpp @@ -76,8 +76,8 @@ public: calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated double value1 = bvalue1->value; // Value as double in SI unit bool valid1 = bvalue1->valid; // Valid information - String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value + String svalue1 = commonData->fmt->formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit1 = commonData->fmt->formatValue(bvalue1, *commonData).unit; // Unit of value if (valid1 == true) { svalue1old = svalue1; // Save old value unit1old = unit1; // Save old unit @@ -97,8 +97,8 @@ public: if (simulation) { value2 = 0.62731; // some random value } - String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value + String svalue2 = commonData->fmt->formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit2 = commonData->fmt->formatValue(bvalue2, *commonData).unit; // Unit of value if (valid2 == true) { svalue2old = svalue2; // Save old value unit2old = unit2; // Save old unit @@ -111,8 +111,8 @@ public: calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated double value3 = bvalue3->value; // Value as double in SI unit bool valid3 = bvalue3->valid; // Valid information - String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value + String svalue3 = commonData->fmt->formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit3 = commonData->fmt->formatValue(bvalue3, *commonData).unit; // Unit of value if(valid3 == true){ svalue3old = svalue3; // Save old value unit3old = unit3; // Save old unit @@ -125,8 +125,8 @@ public: calibrationData.calibrateInstance(bvalue4, logger); // Check if boat data value is to be calibrated double value4 = bvalue4->value; // Value as double in SI unit bool valid4 = bvalue4->valid; // Valid information - String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value + String svalue4 = commonData->fmt->formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit4 = commonData->fmt->formatValue(bvalue4, *commonData).unit; // Unit of value if(valid4 == true){ svalue4old = svalue4; // Save old value unit4old = unit4; // Save old unit @@ -139,8 +139,8 @@ public: calibrationData.calibrateInstance(bvalue5, logger); // Check if boat data value is to be calibrated double value5 = bvalue5->value; // Value as double in SI unit bool valid5 = bvalue5->valid; // Valid information - String svalue5 = formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit5 = formatValue(bvalue5, *commonData).unit; // Unit of value + String svalue5 = commonData->fmt->formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit5 = commonData->fmt->formatValue(bvalue5, *commonData).unit; // Unit of value if(valid5 == true){ svalue5old = svalue5; // Save old value unit5old = unit5; // Save old unit @@ -153,8 +153,8 @@ public: calibrationData.calibrateInstance(bvalue6, logger); // Check if boat data value is to be calibrated double value6 = bvalue6->value; // Value as double in SI unit bool valid6 = bvalue6->valid; // Valid information - String svalue6 = formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places - String unit6 = formatValue(bvalue6, *commonData).unit; // Unit of value + String svalue6 = commonData->fmt->formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places + String unit6 = commonData->fmt->formatValue(bvalue6, *commonData).unit; // Unit of value if(valid6 == true){ svalue6old = svalue6; // Save old value unit6old = unit6; // Save old unit diff --git a/lib/obp60task/PageXTETrack.cpp b/lib/obp60task/PageXTETrack.cpp index afada12..cc9f740 100644 --- a/lib/obp60task/PageXTETrack.cpp +++ b/lib/obp60task/PageXTETrack.cpp @@ -110,25 +110,25 @@ public: uint16_t w, h; GwApi::BoatValue *bv_xte = pageData.values[0]; // XTE - String sval_xte = formatValue(bv_xte, *commonData).svalue; + String sval_xte = commonData->fmt->formatValue(bv_xte, *commonData).svalue; epd->getTextBounds(sval_xte, 0, 0, &x, &y, &w, &h); epd->setCursor(160-w, 170); epd->print(sval_xte); GwApi::BoatValue *bv_cog = pageData.values[1]; // COG - String sval_cog = formatValue(bv_cog, *commonData).svalue; + String sval_cog = commonData->fmt->formatValue(bv_cog, *commonData).svalue; epd->getTextBounds(sval_cog, 0, 0, &x, &y, &w, &h); epd->setCursor(360-w, 170); epd->print(sval_cog); GwApi::BoatValue *bv_dtw = pageData.values[2]; // DTW - String sval_dtw = formatValue(bv_dtw, *commonData).svalue; + String sval_dtw = commonData->fmt->formatValue(bv_dtw, *commonData).svalue; epd->getTextBounds(sval_dtw, 0, 0, &x, &y, &w, &h); epd->setCursor(160-w, 257); epd->print(sval_dtw); GwApi::BoatValue *bv_btw = pageData.values[3]; // BTW - String sval_btw = formatValue(bv_btw, *commonData).svalue; + String sval_btw = commonData->fmt->formatValue(bv_btw, *commonData).svalue; epd->getTextBounds(sval_btw, 0, 0, &x, &y, &w, &h); epd->setCursor(360-w, 257); epd->print(sval_btw);