mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-02-12 07:33:07 +01:00
Lots of fixes and enhancements for OBPcharts; ringbuffer now returns <double> values - internally still 2-byte storage; charts operate now with SI values; added flexible multiplier to history buffer; included data calibration for history data
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
// Function lib for display of boat data in various chart formats
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <Arduino.h>
|
||||
#include "Pagedata.h"
|
||||
|
||||
struct Pos {
|
||||
@@ -20,7 +18,7 @@ protected:
|
||||
RingBuffer<T> &dataBuf; // Buffer to display
|
||||
int8_t chrtDir; // Chart timeline direction: [0] = horizontal, [1] = vertical
|
||||
int8_t chrtSz; // Chart size: [0] = full size, [1] = half size left/top, [2] half size right/bottom
|
||||
int dfltRng; // Default range of chart, e.g. 30 = [0..30]
|
||||
double dfltRng; // Default range of chart, e.g. 30 = [0..30]
|
||||
uint16_t fgColor; // color code for any screen writing
|
||||
uint16_t bgColor; // color code for screen background
|
||||
bool useSimuData; // flag to indicate if simulation data is active
|
||||
@@ -34,12 +32,18 @@ protected:
|
||||
int dHeight; // Display height
|
||||
int timAxis, valAxis; // size of time and value chart axis
|
||||
Pos cStart; // start point of chart area
|
||||
int chrtRng; // Range of buffer values from min to max value
|
||||
double chrtRng; // Range of buffer values from min to max value
|
||||
double chrtMin; // Range low end value
|
||||
double chrtMax; // Range high end value
|
||||
double chrtMid; // Range mid value
|
||||
double rngStep; // Defines the step of adjustment (e.g. 10 m/s) for value axis range
|
||||
bool recalcRngCntr = false; // Flag for re-calculation of mid value of chart for wind data types
|
||||
|
||||
String dbName, dbFormat; // Name and format of data buffer
|
||||
int16_t dbMAX_VAL; // Highest possible value of buffer of type <T> -> indicates invalid value in buffer
|
||||
int chrtDataFmt; // Data format of chart: [0] size values; [1] degree of course or wind; [2] rotational degrees
|
||||
double dbMIN_VAL; // Lowest possible value of buffer of type <T>
|
||||
double dbMAX_VAL; // Highest possible value of buffer of type <T>; indicates invalid value in buffer
|
||||
size_t bufSize; // History buffer size: 1.920 values for 32 min. history chart
|
||||
int intvBufSize; // Buffer size used for currently selected time interval
|
||||
int count; // current size of buffer
|
||||
int numBufVals; // number of wind values available for current interval selection
|
||||
int bufStart; // 1st data value in buffer to show
|
||||
@@ -49,14 +53,17 @@ protected:
|
||||
size_t lastAddedIdx = 0; // Last index of TWD history buffer when new data was added
|
||||
int oldChrtIntv = 0; // remember recent user selection of data interval
|
||||
|
||||
void calcChrtRng();
|
||||
void drawChrtValAxis();
|
||||
void drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue); // Draw chart line
|
||||
double getRng(double center, size_t amount); // Calculate range between chart center and edges
|
||||
void calcChrtBorders(double& rngMid, double& rngMin, double& rngMax, double& rng); // Calculate chart points for value axis and return range between <min> and <max>
|
||||
void drawChrtTimeAxis(int8_t chrtIntv); // Draw time axis of chart, value and lines
|
||||
void drawChrtValAxis(); // Draw value axis of chart, value and lines
|
||||
void prntCurrValue(GwApi::BoatValue& currValue, Pos chrtPos); // Add current boat data value to chart
|
||||
void getAngleMinMax(const std::vector<double>& angles, double& rngMin, double& rngMax); // Identify Min and Max for course data with smallest gap
|
||||
|
||||
public:
|
||||
Chart(RingBuffer<T>& dataBuf, int8_t chrtDir, int8_t chrtSz, int dfltRng, CommonData& common, bool useSimuData);
|
||||
Chart(RingBuffer<T>& dataBuf, int8_t chrtDir, int8_t chrtSz, double dfltRng, CommonData& common, bool useSimuData); // Chart object of data chart
|
||||
~Chart();
|
||||
void drawChrtTimeAxis(int8_t chrtIntv);
|
||||
void drawChrt(int8_t chrtIntv, GwApi::BoatValue currValue);
|
||||
void prntCurrValue(GwApi::BoatValue* currValue, Pos chrtPos);
|
||||
void showChrt(int8_t chrtIntv, GwApi::BoatValue currValue); // Perform all actions to draw chart
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user