forked from filmote/WiFiManagerGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_screen.ino
137 lines (82 loc) · 3.77 KB
/
utils_screen.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// -------------------------------------------------------------------------------------------------------
// Draw an up arrow as part of the scroll bar (5 x 3 pixels) ..
void drawArrowUp(int left, int top) {
display.setPixel(left + 2, top);
display.drawRect(left + 1, top + 1, 3, 0);
display.drawRect(left, top + 2, 5, 0);
}
// -------------------------------------------------------------------------------------------------------
// Draw a down arrow as part of the scroll bar (5 x 3 pixels) ..
void drawArrowDown(int left, int top) {
display.drawRect(left, top, 5, 0);
display.drawRect(left + 1, top + 1, 3, 0);
display.setPixel(left + 2, top + 2);
}
// -------------------------------------------------------------------------------------------------------
// Draw a left arrow (4 x 7 pixels) ..
void drawArrowLeft(int left, int top) {
display.setPixel(left, top + 3);
display.drawRect(left + 1, top + 2, 0, 3);
display.drawRect(left + 2, top + 1, 0, 5);
display.drawRect(left + 3, top, 0, 7);
}
// -------------------------------------------------------------------------------------------------------
// Draw a dotted bar as part of the scroll bar (5 x 1 pixels) ..
void drawDottedBar(int left, int top) {
display.setPixel(left, top);
display.setPixel(left + 2, top);
display.setPixel(left + 4, top);
}
// -------------------------------------------------------------------------------------------------------
// Draw a WiFi symbol (5 x 5 pixels) ..
void drawWiFiSymbol(int left, int top) {
display.setPixel(left + 2, top + 4);
display.drawRect(left + 1, top + 2, 3, 0);
display.drawRect(left, top, 5, 0);
}
// -------------------------------------------------------------------------------------------------------
// Draw an exclamation mark for use with error or warning messages (8 x 8 pixels) ..
void drawExclamation(int left, int top) {
display.drawRect(left + 2, top, 4, 0);
display.drawRect(left + 1, top + 1, 2, 0);
display.drawRect(left + 5, top + 1, 2, 0);
display.fillRect(left, top + 2, 3, 4);
display.fillRect(left + 5, top + 2, 3, 4);
display.drawRect(left + 1, top + 6, 2, 0);
display.drawRect(left + 3, top + 5, 2, 0);
display.drawRect(left + 5, top + 6, 2, 0);
display.drawRect(left + 2, top + 7, 4, 0);
}
// -------------------------------------------------------------------------------------------------------
// Draw a scroll bar with appropriately sized and positioned slider ..
void drawScrollBar(int itemCount, int itemsVisible, int topRow) {
display.setColor(BLACK);
display.fillRect(SCROLLBAR_AREA_LEFT, SCROLLBAR_AREA_TOP, SCROLLBAR_AREA_WIDTH, SCROLLBAR_AREA_HEIGHT);
display.setColor(WHITE);
display.drawRect(SCROLLBAR_BORDER_LEFT, SCROLLBAR_BORDER_TOP, SCROLLBAR_BORDER_WIDTH, SCROLLBAR_BORDER_HEIGHT);
// Draw a top arrow ?
if (topRow > 0) {
drawArrowUp(SCROLLBAR_SLIDER_LEFT, SCROLLBAR_INDICATOR_UP_TOP);
}
else {
drawDottedBar(SCROLLBAR_SLIDER_LEFT, SCROLLBAR_INDICATOR_UP_TOP + 3);
}
// Draw a bottom arrow ?
if (topRow + itemsVisible < itemCount) {
drawArrowDown(SCROLLBAR_SLIDER_LEFT, SCROLLBAR_INDICATOR_DOWN_TOP);
}
else {
drawDottedBar(SCROLLBAR_SLIDER_LEFT, SCROLLBAR_INDICATOR_DOWN_TOP);
}
if (itemCount > itemsVisible) {
int heightPerUnit = (SCROLLBAR_SLIDE_MAX_HEIGHT) / itemCount;
int top = topRow * heightPerUnit;
int height = itemsVisible * heightPerUnit;
display.fillRect(SCROLLBAR_SLIDER_LEFT, SCROLLBAR_SLIDER_TOP + top, SCROLLBAR_SLIDER_WIDTH, height);
}
}
// -------------------------------------------------------------------------------------------------------
// Draw a horizontal line across entire screen ..
void drawHorizontalLine(int top) {
display.drawRect(0, top, 127, 0);
}