1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-15 23:13:07 +01:00

add simulation data for TWD, TWS history data

This commit is contained in:
Ulrich Meine
2025-08-16 16:49:17 +02:00
parent 398b8e0d02
commit 8faead0a1a
4 changed files with 123 additions and 126 deletions

View File

@@ -86,7 +86,7 @@ bool WindUtils::calcTrueWind(const double* awaVal, const double* awsVal,
double minSogVal = 0.1; // SOG below this value (m/s) is assumed to be data noise from GPS sensor
static const double DBL_MIN = std::numeric_limits<double>::lowest();
Serial.println("\ncalcTrueWind: HDT: " + String(*hdtVal) + ", HDM: " + String(*hdmVal) + ", VAR: " + String(*varVal) + ", SOG: " + String(*sogVal) + ", COG: " + String(*cogVal));
// Serial.println("\ncalcTrueWind: HDT: " + String(*hdtVal) + ", HDM: " + String(*hdmVal) + ", VAR: " + String(*varVal) + ", SOG: " + String(*sogVal) + ", COG: " + String(*cogVal));
if (*hdtVal != DBL_MIN) {
hdt = *hdtVal; // Use HDT if available
} else {
@@ -100,7 +100,7 @@ bool WindUtils::calcTrueWind(const double* awaVal, const double* awsVal,
}
}
if (*cogVal != DBL_MIN && *sogVal >= minSogVal ) { // if SOG is data noise, we don't trust COG
if (*cogVal != DBL_MIN && *sogVal >= minSogVal) { // if SOG is data noise, we don't trust COG
ctw = *cogVal; // Use COG for CTW if available
} else {
@@ -115,7 +115,7 @@ bool WindUtils::calcTrueWind(const double* awaVal, const double* awsVal,
// If STW and SOG are not available, we cannot calculate true wind
return false;
}
Serial.println("\ncalcTrueWind: HDT: " + String(hdt) + ", CTW: " + String(ctw) + ", STW: " + String(stw));
// Serial.println("\ncalcTrueWind: HDT: " + String(hdt) + ", CTW: " + String(ctw) + ", STW: " + String(stw));
if ((*awaVal == DBL_MIN) || (*awsVal == DBL_MIN)) {
// Cannot calculate true wind without valid AWA, AWS; other checks are done earlier
@@ -128,30 +128,4 @@ bool WindUtils::calcTrueWind(const double* awaVal, const double* awsVal,
return true;
}
}
void HstryBuf::fillWndBufSimData(tBoatHstryData& hstryBufs)
// Fill most part of TWD and TWS history buffer with simulated data
{
double value = 20.0;
int16_t value2 = 0;
for (int i = 0; i < 900; i++) {
value += random(-20, 20);
value = WindUtils::to360(value);
value2 = static_cast<int16_t>(value * DEG_TO_RAD * 1000);
hstryBufs.twdHstry->add(value2);
}
}
/* void HstryBuf::simWndDir(double &wndDir)
{
wndDir += random(-20, 20);
wndDir = WindUtils::to360(wndDir);
int16_t z = static_cast<int16_t>(DegToRad(wndDir) * 1000.0);
pageData.boatHstry.twdHstry->add(z); // Fill the buffer with some test data
simTws += random(-200, 150) / 10.0; // TWS value in knots
simTws = constrain(simTws, 0.0f, 50.0f); // Ensure TWS is between 0 and 50 knots
twsValue = simTws;
}*/
}