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

added calibration to buffer; separated buffer and wind code in opb60task; prepared simulation; getMin/Max fix for ringbuffer for invalid data; fix for chart center; cleanup code

This commit is contained in:
Ulrich Meine
2025-07-25 08:42:43 +02:00
parent c48c6a2e48
commit fe2223839f
9 changed files with 367 additions and 324 deletions

View File

@@ -1,48 +1,36 @@
#pragma once
// #include <Python.h>
#include "GwApi.h"
#include "OBPRingBuffer.h"
#include <Arduino.h>
#include <math.h>
// #define radians(a) (a*0.017453292519943295)
// #define degrees(a) (a*57.29577951308232)
typedef struct {
RingBuffer<int16_t>* twdHstry;
RingBuffer<int16_t>* twsHstry;
} tBoatHstryData; // Holds pointers to all history buffers for boat data
class HstryBuf {
public:
void fillWndBufSimData(tBoatHstryData& hstryBufs); // Fill most part of the TWD and TWS history buffer with simulated data
};
class WindUtils {
public:
static void to360(double* a);
static void to180(double* a);
static void to2PI(double* a);
static void toPI(double* a);
static double to2PI(double a);
static double toPI(double a);
static double to360(double a);
static double to180(double a);
static void toCart(const double* phi, const double* r, double* x, double* y);
static void toPol(const double* x, const double* y, double* phi, double* r);
static void addPolar(const double* phi1, const double* r1,
const double* phi2, const double* r2,
double* phi, double* r);
static bool calcTrueWind(const double* awaVal, const double* awsVal,
const double* cogVal, const double* stwVal, const double* hdtVal,
const double* hdmVal, double* twdVal, double* twsVal);
static void calcTwdSA(const double* AWA, const double* AWS,
const double* CTW, const double* STW, const double* HDT,
double* TWD, double* TWS);
};
/*
// make function available in Python for testing
static PyObject* true_wind(PyObject* self, PyObject* args);
static PyMethodDef methods[] = {
{"true_wind", true_wind, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef module = {
PyModuleDef_HEAD_INIT,
"truewind", // Module name
NULL, // Optional docstring
-1,
methods
};
PyMODINIT_FUNC PyInit_truewind(void) {
return PyModule_Create(&module);
} */
double* TWD, double* TWS, double* TWA);
static bool calcTrueWind(const double* awaVal, const double* awsVal,
const double* cogVal, const double* stwVal, const double* sogVal, const double* hdtVal,
const double* hdmVal, const double* varVal, double* twdVal, double* twsVal, double* twaVal);
};