| 1 |
#ifndef VALUEHISTORY_H |
| 2 |
#define VALUEHISTORY_H |
| 3 |
|
| 4 |
class ValueHistory |
| 5 |
{ |
| 6 |
static const int MAX_HISTORY = 256; |
| 7 |
float m_samples[MAX_HISTORY]; |
| 8 |
int m_hsamples; |
| 9 |
public: |
| 10 |
ValueHistory(); |
| 11 |
|
| 12 |
inline void addSample(const float val) |
| 13 |
{ |
| 14 |
m_hsamples = (m_hsamples+MAX_HISTORY-1) % MAX_HISTORY; |
| 15 |
m_samples[m_hsamples] = val; |
| 16 |
} |
| 17 |
|
| 18 |
inline int getSampleCount() const |
| 19 |
{ |
| 20 |
return MAX_HISTORY; |
| 21 |
} |
| 22 |
|
| 23 |
inline float getSample(const int i) const |
| 24 |
{ |
| 25 |
return m_samples[(m_hsamples+i) % MAX_HISTORY]; |
| 26 |
} |
| 27 |
|
| 28 |
float getSampleMin() const; |
| 29 |
float getSampleMax() const; |
| 30 |
float getAverage() const; |
| 31 |
}; |
| 32 |
|
| 33 |
struct GraphParams |
| 34 |
{ |
| 35 |
void setRect(int ix, int iy, int iw, int ih, int ipad); |
| 36 |
void setValueRange(float ivmin, float ivmax, int indiv, const char* iunits); |
| 37 |
|
| 38 |
int x, y, w, h, pad; |
| 39 |
float vmin, vmax; |
| 40 |
int ndiv; |
| 41 |
char units[16]; |
| 42 |
}; |
| 43 |
|
| 44 |
void drawGraphBackground(const GraphParams* p); |
| 45 |
|
| 46 |
void drawGraph(const GraphParams* p, const ValueHistory* graph, |
| 47 |
int idx, const char* label, const unsigned int col); |
| 48 |
|
| 49 |
|
| 50 |
#endif |
| 51 |
|