-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonDisp.ino
101 lines (85 loc) · 2.61 KB
/
monDisp.ino
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
88
89
90
91
92
93
94
95
96
97
// =====================================================================
//
// Output function
//
// =====================================================================
/* ******************************************************************** */
void LCDML_lcd_menu_display()
/* ******************************************************************** */
{
// check if menu needs an update
if (LCDML_DISP_update()) {
// init vars
uint8_t n_max = (LCDML.getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.getChilds());
uint8_t scrollbar_min = 0;
uint8_t scrollbar_max = LCDML.getChilds();
uint8_t scrollbar_cur_pos = LCDML.getCursorPosAbs();
uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos);
// update content
if (LCDML_DISP_update_content()) {
// clear menu
LCDML_lcd_menu_clear();
// display rows
for (uint8_t n = 0; n < n_max; n++)
{
// set cursor
lcd.setCursor(1, n);
// set content
lcd.print(LCDML.content[n]);
}
}
// update cursor and scrollbar
if (LCDML_DISP_update_cursor()) {
// display rows
for (uint8_t n = 0; n < n_max; n++)
{
//set cursor
lcd.setCursor(0, n);
//set cursor char
if (n == LCDML.getCursorPos()) {
lcd.write(_LCDML_DISP_cfg_cursor);
} else {
lcd.write(' ');
}
// delete or reset scrollbar
if (_LCDML_DISP_cfg_scrollbar == 1) {
if (scrollbar_max > n_max) {
lcd.setCursor((_LCDML_DISP_cols - 1), n);
lcd.write((uint8_t)0);
}
else {
lcd.setCursor((_LCDML_DISP_cols - 1), n);
lcd.print(' ');
}
}
}
// display scrollbar
if (_LCDML_DISP_cfg_scrollbar == 1) {
if (scrollbar_max > n_max) {
//set scroll position
if (scrollbar_cur_pos == scrollbar_min) {
// min pos
lcd.setCursor((_LCDML_DISP_cols - 1), 0);
lcd.write((uint8_t)1);
} else if (scrollbar_cur_pos == (scrollbar_max - 1)) {
// max pos
lcd.setCursor((_LCDML_DISP_cols - 1), (n_max - 1));
lcd.write((uint8_t)4);
} else {
// between
lcd.setCursor((_LCDML_DISP_cols - 1), scroll_pos / n_max);
lcd.write((uint8_t)(scroll_pos % n_max) + 1);
}
}
}
}
}
// reinit some vars
LCDML_DISP_update_end();
}
// lcd clear
void LCDML_lcd_menu_clear()
{
lcd.clear();
lcd.setCursor(0, 0);
}