-
Notifications
You must be signed in to change notification settings - Fork 1
/
LcdHistogram.h
64 lines (50 loc) · 1.51 KB
/
LcdHistogram.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* LcdHistogram
*
* LcdHistogram.h
* Pierre Faivre - oct. 2014 - dec. 2016
*/
#ifndef LcdHistogram_h
#define LcdHistogram_h
#include <LiquidCrystal.h>
/**
* Defines the drawing behavior
* For example, for the numbers {80, 95, 100, 70, 90}, it will print :
* - FIXED : ▅█ (with setBounds(90, 100);)
* - ABSOLUTE : ▆██▆▇
* - DYNAMIC : ▃▇█ ▅
*/
enum GraphMode {
/**
* Allow you to manually set the min and max values
*/
FIXED,
/**
* Draw each bar considering 0 as minimum value
*/
ABSOLUTE,
/**
* Get the chart more readable by adjusting the length of the bars according to the minimum value
*/
DYNAMIC
};
class LcdHistogram {
public:
LcdHistogram(LiquidCrystal* lcd, byte posx, byte posy, byte length);
~LcdHistogram();
void push(float number);
void plot();
void setMode(GraphMode m);
void setBounds(float min, float max);
private:
LiquidCrystal* _lcd; // LCD to print the graph
byte _posx; // Row on the screen of the first bar
byte _posy; // Line on the screen of the first bar
byte _length; // Length of the histogram in characters
float* _data; // Numbers to plot
GraphMode _mode; // Current mode of drawing (default : DYNAMIC)
float _min; // Custom minimum value in fixed mode (default : 0)
float _max; // Custom maximum value in fixed mode (default : 100)
void _init();
};
#endif