mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-15 23:13:07 +01:00
Semaphore + chart fixes; added simulation data
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
template <typename T>
|
||||
class RingBuffer {
|
||||
private:
|
||||
SemaphoreHandle_t locker;
|
||||
mutable SemaphoreHandle_t bufLocker;
|
||||
std::vector<T> buffer;
|
||||
size_t capacity;
|
||||
size_t head; // Points to the next insertion position
|
||||
@@ -24,13 +24,13 @@ private:
|
||||
String dataName; // Name of boat data in buffer
|
||||
String dataFmt; // Format of boat data in buffer
|
||||
int updFreq; // Update frequency in milliseconds
|
||||
int smallest; // Value range of buffer: smallest value
|
||||
int largest; // Value range of buffer: biggest value
|
||||
T smallest; // Value range of buffer: smallest value
|
||||
T largest; // Value range of buffer: biggest value
|
||||
|
||||
public:
|
||||
RingBuffer(size_t size);
|
||||
void setMetaData(String name, String format, int updateFrequency, int minValue, int maxValue); // Set meta data for buffer
|
||||
bool getMetaData(String& name, String& format, int& updateFrequency, int& minValue, int& maxValue); // Get meta data of buffer
|
||||
void setMetaData(String name, String format, int updateFrequency, T minValue, T maxValue); // Set meta data for buffer
|
||||
bool getMetaData(String& name, String& format, int& updateFrequency, T& minValue, T& maxValue); // Get meta data of buffer
|
||||
void add(const T& value); // Add a new value to buffer
|
||||
T get(size_t index) const; // Get value at specific position (0-based index from oldest to newest)
|
||||
T getFirst() const; // Get the first (oldest) value in buffer
|
||||
@@ -45,13 +45,14 @@ public:
|
||||
T getMedian(size_t amount) const; // Get the median value of the last <amount> values of buffer
|
||||
size_t getCapacity() const; // Get the buffer capacity (maximum size)
|
||||
size_t getCurrentSize() const; // Get the current number of elements in buffer
|
||||
size_t getLastIdx() const; // Get the last index of buffer
|
||||
size_t getFirstIdx() const; // Get the index of oldest value in buffer
|
||||
size_t getLastIdx() const; // Get the index of newest value in buffer
|
||||
bool isEmpty() const; // Check if buffer is empty
|
||||
bool isFull() const; // Check if buffer is full
|
||||
T getMinVal() const; // Get lowest possible value for buffer; used for initialized buffer data
|
||||
T getMaxVal() const; // Get highest possible value for buffer
|
||||
void clear(); // Clear buffer
|
||||
T operator[](size_t index); // Operator[] for convenient access (same as get())
|
||||
T operator[](size_t index) const; // Operator[] for convenient access (same as get())
|
||||
std::vector<T> getAllValues() const; // Get all current values as a vector
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user