forked from arendst/Tasmota
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathdisplay_demo.tc
More file actions
213 lines (190 loc) · 4.5 KB
/
Copy pathdisplay_demo.tc
File metadata and controls
213 lines (190 loc) · 4.5 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// Sensor Dashboard for ILI9488 (480x320)
// Static layout drawn once, only values update each second
// dspPad(n) pads text to n chars — overwrites old text cleanly
char buf[64];
int w;
int h;
global float btemp; // auto-updated from UDP
global float bhumi; // auto-updated from UDP
void drawStatic() {
w = dspWidth();
h = dspHeight();
dspClear();
// Title bar
dspColor(NAVY, WHITE);
dspPos(0, 0);
dspFillRect(w, 30);
dspFont(2);
dspSize(1);
dspPos(10, 7);
dspColor(WHITE, NAVY);
dspDraw("Tasmota Dashboard");
// Separator
dspColor(DARKGREY, BLACK);
dspPos(0, 100);
dspHLine(w);
// Labels
dspFont(2);
dspSize(1);
dspColor(WHITE, BLACK);
dspPos(20, 115);
dspDraw("Temp:");
dspPos(20, 155);
dspDraw("Hum:");
// Separator
dspColor(DARKGREY, BLACK);
dspPos(0, 195);
dspHLine(w);
// Static labels
dspFont(1);
dspSize(1);
dspColor(GREY, BLACK);
dspPos(20, 210);
dspDraw("Uptime:");
dspPos(20, 230);
dspDraw("Heap:");
dspPos(20, 250);
dspDraw("MQTT:");
dspPos(250, 250);
dspDraw("Power:");
// Bottom bar
dspColor(NAVY, WHITE);
dspPos(0, h - 22);
dspFillRect(w, 22);
dspFont(1);
dspSize(1);
dspPos(10, h - 17);
dspColor(WHITE, NAVY);
dspDraw("TinyC Sensor Dashboard");
dspPad(0);
dspUpdate();
}
void EverySecond() {
dspText("[D0]"); // disable auto-draw — batch all updates
// ── Clock ──
dspColor(CYAN, BLACK);
dspFont(2);
dspSize(1);
sprintf(buf, "%02d", tasm_hour);
strcat(buf, ":");
sprintfAppend(buf, "%02d", tasm_minute);
strcat(buf, ":");
sprintfAppend(buf, "%02d", tasm_second);
dspPos(20, 40);
dspDraw(buf);
// ── Date ──
dspColor(LIGHTGREY, BLACK);
dspFont(2);
dspSize(1);
sprintf(buf, "%02d", tasm_day);
strcat(buf, ".");
sprintfAppend(buf, "%02d", tasm_month);
strcat(buf, ".");
sprintfAppend(buf, "%d", tasm_year);
dspPos(20, 70);
dspDraw(buf);
// ── WiFi indicator ──
dspFont(1);
dspSize(1);
dspPad(10);
if (tasm_wifi) {
dspColor(GREEN, NAVY);
dspPos(w - 78, 10);
dspDraw("WiFi OK");
} else {
dspColor(RED, NAVY);
dspPos(w - 78, 10);
dspDraw("No WiFi");
}
// ── Temperature value (auto-updated from UDP) ──
float temp = btemp;
dspFont(2);
dspSize(1);
dspPad(10);
dspPos(200, 112);
sprintf(buf, "%.1f", temp);
if (buf[0] == 'n' || buf[0] == 'N' || buf[0] == 0) {
dspColor(DARKGREY, BLACK);
dspDraw("--.-");
} else {
dspColor(YELLOW, BLACK);
strcat(buf, " C");
dspDraw(buf);
//dspPad(0);
//dspDraw(" C");
}
// ── Humidity value (auto-updated from UDP) ──
float hum = bhumi;
dspFont(2);
dspSize(1);
dspPad(10);
dspPos(200, 152);
sprintf(buf, "%.1f", hum);
if (buf[0] == 'n' || buf[0] == 'N' || buf[0] == 0) {
dspColor(DARKGREY, BLACK);
dspDraw("--.-");
} else {
dspColor(CYAN, BLACK);
strcat(buf, " %");
dspDraw(buf);
//dspPad(0);
//dspDraw(" %%");
}
// ── Uptime value ──
/* int days;
int hrs;
int mins;
days = tasm_uptime / 86400;
hrs = (tasm_uptime % 86400) / 3600;
mins = (tasm_uptime % 3600) / 60;
dspColor(GREY, BLACK);
dspFont(1);
dspSize(1);
dspPad(20);
sprintf(buf, "%dd ", days);
dspPos(90, 210);
dspDraw(buf);
dspPad(0);
sprintf(buf, "%dh ", hrs);
dspDraw(buf);
sprintf(buf, "%dm", mins);
*/
dspFont(1);
dspSize(1);
dspPos(90, 210);
sprintf(buf, "%d secs", tasm_uptime);
dspDraw(buf);
// ── Heap value ──
dspColor(GREY, BLACK);
dspPad(16);
sprintf(buf, "%d bytes", tasm_heap);
dspPos(90, 230);
dspDraw(buf);
// ── MQTT status ──
dspPad(14);
dspPos(70, 250);
if (tasm_mqttcon) {
dspColor(GREEN, BLACK);
dspDraw("Connected");
} else {
dspColor(RED, BLACK);
dspDraw("Disconnected");
}
// ── Power status ──
dspPad(4);
dspPos(310, 250);
if (tasm_power) {
dspColor(GREEN, BLACK);
dspDraw("ON");
} else {
dspColor(DARKGREY, BLACK);
dspDraw("OFF");
}
dspPad(0);
dspText("[D1]"); // re-enable auto-draw
dspUpdate(); // single frame update
}
int main() {
drawStatic();
return 0;
}