mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-01-26 08:13:05 +01:00
added helper method for boat value conversion to OBP60Formatter;
fixed range calculation for temperature and other value formats; fixed printing for names > len(3); show "mode" only for supported data types
This commit is contained in:
@@ -877,4 +877,21 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||
return result;
|
||||
}
|
||||
|
||||
// Helper method for conversion of boat data values from SI to user defined format
|
||||
double convertValue(const double &value, const String &format, CommonData &commondata)
|
||||
{
|
||||
std::unique_ptr<GwApi::BoatValue> tmpBValue; // Temp variable to get converted data value from <OBP60Formatter::formatValue>
|
||||
double result; // data value converted to user defined target data format
|
||||
|
||||
// prepare dummy BoatValue structure for use in <formatValue>
|
||||
tmpBValue = std::unique_ptr<GwApi::BoatValue>(new GwApi::BoatValue("dummy")); // we don't need boat value name for pure value conversion
|
||||
tmpBValue->setFormat(format);
|
||||
tmpBValue->valid = true;
|
||||
tmpBValue->value = value;
|
||||
|
||||
result = formatValue(tmpBValue.get(), commondata).cvalue; // get value (converted)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user