Compare commits
No commits in common. "34a289048f9d9e01c1d1a148b94e39cc66f7b2e1" and "e5eee37b595d4c81469bf68b7b88a9e64cf9eed2" have entirely different histories.
34a289048f
...
e5eee37b59
|
@ -39,13 +39,12 @@ public:
|
||||||
HstryBuf(){
|
HstryBuf(){
|
||||||
hstryBufList = {&twdHstry, &twsHstry, &awdHstry, &awsHstry}; // Generate history buffers of zero size
|
hstryBufList = {&twdHstry, &twsHstry, &awdHstry, &awsHstry}; // Generate history buffers of zero size
|
||||||
};
|
};
|
||||||
|
|
||||||
HstryBuf(int size) {
|
HstryBuf(int size) {
|
||||||
hstryBufList = {&twdHstry, &twsHstry, &awdHstry, &awsHstry};
|
hstryBufList = {&twdHstry, &twsHstry, &awdHstry, &awsHstry};
|
||||||
hstryBufList.twdHstry->resize(size); // store <size> xWD values for <size>/60 minutes history
|
hstryBufList.twdHstry->resize(960); // store 960 TWD values for 16 minutes history
|
||||||
hstryBufList.twsHstry->resize(size);
|
hstryBufList.twsHstry->resize(960);
|
||||||
hstryBufList.awdHstry->resize(size);
|
hstryBufList.awdHstry->resize(960);
|
||||||
hstryBufList.awsHstry->resize(size);
|
hstryBufList.awsHstry->resize(960);
|
||||||
};
|
};
|
||||||
void init(BoatValueList* boatValues, GwLog *log);
|
void init(BoatValueList* boatValues, GwLog *log);
|
||||||
void handleHstryBuf(bool useSimuData);
|
void handleHstryBuf(bool useSimuData);
|
||||||
|
|
|
@ -1,48 +1,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "GwSynchronized.h"
|
#include "GwSynchronized.h"
|
||||||
#include "WString.h"
|
|
||||||
#include "esp_heap_caps.h"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "WString.h"
|
||||||
template <typename T>
|
|
||||||
struct PSRAMAllocator {
|
|
||||||
using value_type = T;
|
|
||||||
|
|
||||||
PSRAMAllocator() = default;
|
|
||||||
|
|
||||||
template <class U>
|
|
||||||
constexpr PSRAMAllocator(const PSRAMAllocator<U>&) noexcept { }
|
|
||||||
|
|
||||||
T* allocate(std::size_t n)
|
|
||||||
{
|
|
||||||
void* ptr = heap_caps_malloc(n * sizeof(T), MALLOC_CAP_SPIRAM);
|
|
||||||
if (!ptr) {
|
|
||||||
return nullptr;
|
|
||||||
} else {
|
|
||||||
return static_cast<T*>(ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void deallocate(T* p, std::size_t) noexcept
|
|
||||||
{
|
|
||||||
heap_caps_free(p);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class U>
|
|
||||||
bool operator==(const PSRAMAllocator<T>&, const PSRAMAllocator<U>&) { return true; }
|
|
||||||
|
|
||||||
template <class T, class U>
|
|
||||||
bool operator!=(const PSRAMAllocator<T>&, const PSRAMAllocator<U>&) { return false; }
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class RingBuffer {
|
class RingBuffer {
|
||||||
private:
|
private:
|
||||||
// std::vector<T> buffer; // THE buffer vector
|
std::vector<T> buffer; // THE buffer vector
|
||||||
std::vector<T, PSRAMAllocator<T>> buffer; // THE buffer vector, allocated in PSRAM
|
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
size_t head; // Points to the next insertion position
|
size_t head; // Points to the next insertion position
|
||||||
size_t first; // Points to the first (oldest) valid element
|
size_t first; // Points to the first (oldest) valid element
|
||||||
|
|
|
@ -35,8 +35,6 @@ RingBuffer<T>::RingBuffer(size_t size)
|
||||||
, is_Full(false)
|
, is_Full(false)
|
||||||
{
|
{
|
||||||
initCommon();
|
initCommon();
|
||||||
|
|
||||||
buffer.reserve(size);
|
|
||||||
buffer.resize(size, MAX_VAL); // MAX_VAL indicate invalid values
|
buffer.resize(size, MAX_VAL); // MAX_VAL indicate invalid values
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +405,6 @@ void RingBuffer<T>::resize(size_t newSize)
|
||||||
is_Full = false;
|
is_Full = false;
|
||||||
|
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
buffer.reserve(newSize);
|
|
||||||
buffer.resize(newSize, MAX_VAL);
|
buffer.resize(newSize, MAX_VAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,10 +169,8 @@ public:
|
||||||
getdisplay().print("HDOP:");
|
getdisplay().print("HDOP:");
|
||||||
|
|
||||||
GwApi::BoatValue *bv_hdop = pageData.values[1]; // HDOP
|
GwApi::BoatValue *bv_hdop = pageData.values[1]; // HDOP
|
||||||
double hdop = formatValue(bv_hdop, *commonData).value * 4; // 4 is factor for UERE (translation in meter)
|
String sval_hdop = formatValue(bv_hdop, *commonData).svalue;
|
||||||
char sval_hdop[20];
|
sval_hdop = sval_hdop + "m";
|
||||||
dtostrf(hdop, 0, 1, sval_hdop); // Only one prefix
|
|
||||||
strcat(sval_hdop, "m");
|
|
||||||
getdisplay().setCursor(220, 269);
|
getdisplay().setCursor(220, 269);
|
||||||
getdisplay().print(sval_hdop);
|
getdisplay().print(sval_hdop);
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ class PageWindPlot : public Page {
|
||||||
bool oldShowTruW = false; // remember recent user selection of wind data type
|
bool oldShowTruW = false; // remember recent user selection of wind data type
|
||||||
|
|
||||||
int dataIntv = 1; // Update interval for wind history chart:
|
int dataIntv = 1; // Update interval for wind history chart:
|
||||||
// (1)|(2)|(3)|(4)|(8) x 240 seconds for 4, 8, 12, 16, 32 min. history chart
|
// (1)|(2)|(3)|(4) seconds for approx. 4, 8, 12, 16 min. history chart
|
||||||
bool useSimuData;
|
bool useSimuData;
|
||||||
String flashLED;
|
String flashLED;
|
||||||
String backlightMode;
|
String backlightMode;
|
||||||
|
@ -147,8 +147,6 @@ public:
|
||||||
dataIntv = 3;
|
dataIntv = 3;
|
||||||
} else if (dataIntv == 3) {
|
} else if (dataIntv == 3) {
|
||||||
dataIntv = 4;
|
dataIntv = 4;
|
||||||
} else if (dataIntv == 4) {
|
|
||||||
dataIntv = 8;
|
|
||||||
} else {
|
} else {
|
||||||
dataIntv = 1;
|
dataIntv = 1;
|
||||||
}
|
}
|
||||||
|
@ -206,7 +204,7 @@ public:
|
||||||
static int xCenter; // Center of screen in x direction
|
static int xCenter; // Center of screen in x direction
|
||||||
static const int yOffset = 48; // Offset for y coordinates of chart area
|
static const int yOffset = 48; // Offset for y coordinates of chart area
|
||||||
static int cHeight; // height of chart area
|
static int cHeight; // height of chart area
|
||||||
static int bufSize; // History buffer size: 1.920 values for 32 min. history chart
|
static int bufSize; // History buffer size: 960 values for appox. 16 min. history chart
|
||||||
static int intvBufSize; // Buffer size used for currently selected time interval
|
static int intvBufSize; // Buffer size used for currently selected time interval
|
||||||
int count; // current size of buffer
|
int count; // current size of buffer
|
||||||
static int numWndVals; // number of wind values available for current interval selection
|
static int numWndVals; // number of wind values available for current interval selection
|
||||||
|
@ -287,7 +285,7 @@ public:
|
||||||
currIdx = wdHstry->getLastIdx();
|
currIdx = wdHstry->getLastIdx();
|
||||||
numAddedBufVals = (currIdx - lastAddedIdx + bufSize) % bufSize; // Number of values added to buffer since last display
|
numAddedBufVals = (currIdx - lastAddedIdx + bufSize) % bufSize; // Number of values added to buffer since last display
|
||||||
if (dataIntv != oldDataIntv || count == 1) {
|
if (dataIntv != oldDataIntv || count == 1) {
|
||||||
// new data interval selected by user; this is only x * 230 values instead of 240 seconds (4 minutes) per interval step
|
// new data interval selected by user
|
||||||
intvBufSize = cHeight * dataIntv;
|
intvBufSize = cHeight * dataIntv;
|
||||||
numWndVals = min(count, (cHeight - 60) * dataIntv);
|
numWndVals = min(count, (cHeight - 60) * dataIntv);
|
||||||
bufStart = max(0, count - numWndVals);
|
bufStart = max(0, count - numWndVals);
|
||||||
|
@ -300,7 +298,6 @@ public:
|
||||||
bufStart = max(0, bufStart - numAddedBufVals);
|
bufStart = max(0, bufStart - numAddedBufVals);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// LOG_DEBUG(GwLog::DEBUG,"PSRAM Size: %d kByte; free: %d Byte", ESP.getPsramSize()/1024, ESP.getFreePsram());
|
|
||||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot Dataset: count: %d, xWD: %.1f, xWS: %.2f, xWD_valid? %d, intvBufSize: %d, numWndVals: %d, bufStart: %d, numAddedBufVals: %d, lastIdx: %d, wind source: %s",
|
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot Dataset: count: %d, xWD: %.1f, xWS: %.2f, xWD_valid? %d, intvBufSize: %d, numWndVals: %d, bufStart: %d, numAddedBufVals: %d, lastIdx: %d, wind source: %s",
|
||||||
count, wdHstry->getLast() / 1000.0 * radToDeg, wsHstry->getLast() / 1000.0 * 1.94384, BDataValid[0], intvBufSize, numWndVals, bufStart, numAddedBufVals, wdHstry->getLastIdx(),
|
count, wdHstry->getLast() / 1000.0 * radToDeg, wsHstry->getLast() / 1000.0 * 1.94384, BDataValid[0], intvBufSize, numWndVals, bufStart, numAddedBufVals, wdHstry->getLastIdx(),
|
||||||
showTruW ? "True" : "App");
|
showTruW ? "True" : "App");
|
||||||
|
|
|
@ -431,7 +431,7 @@ void OBP60Task(GwApi *api){
|
||||||
int lastPage=pageNumber;
|
int lastPage=pageNumber;
|
||||||
|
|
||||||
BoatValueList boatValues; //all the boat values for the api query
|
BoatValueList boatValues; //all the boat values for the api query
|
||||||
HstryBuf hstryBufList(1920); // Create ring buffers for history storage of some boat data (1920 seconds = 32 minutes)
|
HstryBuf hstryBufList(960); // Create ring buffers for history storage of some boat data
|
||||||
WindUtils trueWind(&boatValues); // Create helper object for true wind calculation
|
WindUtils trueWind(&boatValues); // Create helper object for true wind calculation
|
||||||
//commonData.distanceformat=config->getString(xxx);
|
//commonData.distanceformat=config->getString(xxx);
|
||||||
//add all necessary data to common data
|
//add all necessary data to common data
|
||||||
|
@ -710,8 +710,8 @@ void OBP60Task(GwApi *api){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Full display update afer a new selected page and 8s wait time
|
// Full display update afer a new selected page and 4s wait time
|
||||||
if(millis() > starttime4 + 8000 && delayedDisplayUpdate == true){
|
if(millis() > starttime4 + 4000 && delayedDisplayUpdate == true){
|
||||||
starttime1 = millis();
|
starttime1 = millis();
|
||||||
starttime2 = millis();
|
starttime2 = millis();
|
||||||
getdisplay().setFullWindow(); // Set full update
|
getdisplay().setFullWindow(); // Set full update
|
||||||
|
|
Loading…
Reference in New Issue