Graham Pentheny 5111139558
Fixes for many low-severity compiler warnings (#576)
* Fixes for many low-severity compiler warnings

Mostly a lot of pedantic things like end-of-file newlines and commas on the last enum value.  However some fixes like the weak v-tables warnings fixes might help with code gen.  It's unclear if the linker is able to elide multiple copies of the same type's v-table in different translation units, (sometimes it can) but these fixes ensure we don't have to rely on it.
2022-11-11 21:03:03 -05:00

52 lines
1001 B
C++

#ifndef VALUEHISTORY_H
#define VALUEHISTORY_H
class ValueHistory
{
static const int MAX_HISTORY = 256;
float m_samples[MAX_HISTORY];
int m_hsamples;
public:
ValueHistory();
inline void addSample(const float val)
{
m_hsamples = (m_hsamples+MAX_HISTORY-1) % MAX_HISTORY;
m_samples[m_hsamples] = val;
}
inline int getSampleCount() const
{
return MAX_HISTORY;
}
inline float getSample(const int i) const
{
return m_samples[(m_hsamples+i) % MAX_HISTORY];
}
float getSampleMin() const;
float getSampleMax() const;
float getAverage() const;
};
struct GraphParams
{
void setRect(int ix, int iy, int iw, int ih, int ipad);
void setValueRange(float ivmin, float ivmax, int indiv, const char* iunits);
int x, y, w, h, pad;
float vmin, vmax;
int ndiv;
char units[16];
};
void drawGraphBackground(const GraphParams* p);
void drawGraph(const GraphParams* p, const ValueHistory* graph,
int idx, const char* label, const unsigned int col);
#endif // VALUEHISTORY_H