-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDisplay.h
More file actions
87 lines (64 loc) · 2.03 KB
/
Display.h
File metadata and controls
87 lines (64 loc) · 2.03 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef Display_h
#define Display_h
#include "config.h"
#include "Interactive.h"
#include "Charger.h"
#include "Sensor.h"
enum DisplayToggleMode {
DISPLAY_TOGGLE,
DISPLAY_ON,
DISPLAY_OFF
};
class AbstractDisplay {
public:
AbstractDisplay(Interactive *lineups, Charger *charger, RMSSensor *vac_in, RMSSensor *vac_out,
Sensor *ac_out, Sensor *v_bat, Sensor *c_bat) {
// link to Interactive
_lineups = lineups;
// link to Charger
_charger = charger;
// link to sensors
_vac_in = vac_in;
_vac_out = vac_out;
_ac_out = ac_out;
_v_bat = v_bat;
_c_bat = c_bat;
_active = true;
_refresh = false;
_brightness = DISPLAY_DEFAULT_BRIGHTNESS;
};
virtual void initialize() {;};
void toggle(DisplayToggleMode mode = DISPLAY_TOGGLE ) {
_active = ( !mode ? !_active : mode == DISPLAY_ON ) ;
setup_display();
};
void set_brightness(int brightness) { _brightness = brightness; setup_display(); }
virtual void toggle_display_mode(){;};
virtual void set_display_mode(uint8_t mode){;};
virtual uint8_t get_display_mode(){ return 0;};
void init_refresh(){ _refresh = true;};
void refresh() {
if(!_active || !_refresh) return;
on_refresh();
_refresh = false;
};
protected:
virtual void on_refresh(){;};
virtual void setup_display(){;};
Interactive *_lineups;
Charger *_charger;
RMSSensor *_vac_in, *_vac_out;
Sensor *_ac_out, *_v_bat, *_c_bat;
bool _active;
bool _refresh;
int _brightness;
};
#ifdef DISPLAY_TYPE_LED_TM1640
const int DISPLAY_BLINK_FREQ = TIMER_ONE_SEC * 0.5;
#include "LED_TM1640.h"
#endif
#ifdef DISPLAY_TYPE_LCD_HD44780
const int DISPLAY_BLINK_FREQ = TIMER_ONE_SEC;
#include "LCD_HD44780.h"
#endif
#endif