1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2026-02-11 07:03:07 +01:00

Update data calibration: calibration in main loop on boat data values:

- modified code to calibrate affected boat data each second in main obp60task loop;
- removed individual calibration call in all pages
- moved code from BoatDataCalibration to OBPDataOperations
- added DBS and HDT to list of supported data calibration types
- changed output format for wind angles from [-180..180] to [0..360], because negative value are not displayed properly on pages
This commit is contained in:
Ulrich Meine
2026-01-17 12:25:57 +01:00
parent da975b5175
commit b8e64ff64c
17 changed files with 300 additions and 309 deletions

View File

@@ -1,9 +1,36 @@
// Function lib for history buffer handling, true wind calculation, and other operations on boat data
// Function lib for boat data calibration, history buffer handling, true wind calculation, and other operations on boat data
#pragma once
#include "OBPRingBuffer.h"
#include "Pagedata.h"
#include "obp60task.h"
#include <map>
#include <unordered_map>
// Calibration of boat data values, when user setting available
// supported boat data types are: AWA, AWS, COG, DBS, DBT, HDM, HDT, PRPOS, RPOS, SOG, STW, TWA, TWS, TWD, WTemp
class CalibrationData {
private:
typedef struct {
double offset; // calibration offset
double slope; // calibration slope
double smooth; // smoothing factor
double value; // calibrated data value (for future use)
bool isCalibrated; // is data instance value calibrated? (for future use)
} tCalibrationData;
std::unordered_map<std::string, tCalibrationData> calibrationMap; // list of calibration data instances
std::unordered_map<std::string, double> lastValue; // array for last smoothed values of boat data values
GwLog* logger;
static constexpr int8_t MAX_CALIBRATION_DATA = 3; // maximum number of calibration data instances
public:
CalibrationData(GwLog* log);
void readConfig(GwConfigHandler* config);
void handleCalibration(BoatValueList* boatValues); // Handle calibrationMap and calibrate all boat data values
bool calibrateInstance(GwApi::BoatValue* boatDataValue); // Calibrate single boat data value
bool smoothInstance(GwApi::BoatValue* boatDataValue); // Smooth single boat data value
};
class HstryBuf {
private: