1 | /* |
---|
2 | * This file contains status-gathering code *and* modescreen functions. |
---|
3 | * It's long, and messy; but that will change with V0.4. |
---|
4 | * |
---|
5 | */ |
---|
6 | |
---|
7 | #include <stdlib.h> |
---|
8 | #include <stdio.h> |
---|
9 | #include <string.h> |
---|
10 | #include <fcntl.h> |
---|
11 | #include <unistd.h> |
---|
12 | #include <time.h> |
---|
13 | #include <sys/time.h> |
---|
14 | #include <sys/utsname.h> |
---|
15 | |
---|
16 | #ifdef LINUX |
---|
17 | #include <sys/vfs.h> |
---|
18 | #else |
---|
19 | #include <sys/statfs.h> |
---|
20 | #endif |
---|
21 | |
---|
22 | #include "mode.h" |
---|
23 | #include "lcd.h" |
---|
24 | #include "main.h" |
---|
25 | |
---|
26 | #ifndef NETDEVICE |
---|
27 | #define NETDEVICE "ppp0" |
---|
28 | #endif |
---|
29 | |
---|
30 | #ifndef LOAD_MAX |
---|
31 | #define LOAD_MAX 1.3 |
---|
32 | #endif |
---|
33 | #ifndef LOAD_MIN |
---|
34 | #define LOAD_MIN 0.5 |
---|
35 | #endif |
---|
36 | |
---|
37 | |
---|
38 | int PAD=255; |
---|
39 | int ELLIPSIS=7; |
---|
40 | int TwentyFourHour=0; |
---|
41 | |
---|
42 | // TODO: Clean this up... Support multiple display sizes.. |
---|
43 | |
---|
44 | struct load { unsigned long total, user, system, nice, idle; }; |
---|
45 | struct meminfo { int total, cache, buffers, free, shared; }; |
---|
46 | static char buffer[1024]; |
---|
47 | |
---|
48 | // Nothing else can see these... |
---|
49 | static int meminfo_fd, load_fd, loadavg_fd, uptime_fd, batt_fd=0; |
---|
50 | static FILE *mtab_fd; |
---|
51 | |
---|
52 | static char kver[SYS_NMLN]; |
---|
53 | static char sysname[SYS_NMLN]; |
---|
54 | |
---|
55 | static void reread(int f, char *errmsg); |
---|
56 | static int getentry(const char *tag, const char *bufptr); |
---|
57 | static void get_mem_info(struct meminfo *result); |
---|
58 | static double get_loadavg(void); |
---|
59 | static double get_uptime(double *up, double *idle); |
---|
60 | static void get_load(struct load * result); |
---|
61 | static int get_batt_stat(int *acstat, int *battstat, |
---|
62 | int *battflag, int *percent); |
---|
63 | |
---|
64 | |
---|
65 | typedef struct mounts |
---|
66 | { |
---|
67 | char dev[256], type[64], mpoint[256]; |
---|
68 | long bsize, blocks, bfree, files, ffree; |
---|
69 | } mounts; |
---|
70 | |
---|
71 | |
---|
72 | int mode_init() |
---|
73 | { |
---|
74 | struct utsname *unamebuf = |
---|
75 | (struct utsname *) malloc( sizeof(struct utsname) ); |
---|
76 | |
---|
77 | meminfo_fd = open("/proc/meminfo",O_RDONLY); |
---|
78 | loadavg_fd = open("/proc/loadavg",O_RDONLY); |
---|
79 | load_fd = open("/proc/stat",O_RDONLY); |
---|
80 | uptime_fd = open("/proc/uptime",O_RDONLY); |
---|
81 | |
---|
82 | #if 0 |
---|
83 | kversion_fd = open("/proc/sys/kernel/osrelease",O_RDONLY); |
---|
84 | |
---|
85 | reread(kversion_fd, "main:"); |
---|
86 | sscanf(buffer, "%s", kver); |
---|
87 | |
---|
88 | close(kversion_fd); |
---|
89 | # endif |
---|
90 | |
---|
91 | /* Get OS name and version from uname() */ |
---|
92 | if( uname( unamebuf ) != 0 ) { |
---|
93 | perror( "Error calling uname:" ); |
---|
94 | } |
---|
95 | strcpy( kver, unamebuf->release ); |
---|
96 | strcpy( sysname, unamebuf->sysname ); |
---|
97 | |
---|
98 | return 0; |
---|
99 | } |
---|
100 | |
---|
101 | void mode_close() |
---|
102 | { |
---|
103 | close(meminfo_fd); |
---|
104 | close(loadavg_fd); |
---|
105 | close(load_fd); |
---|
106 | close(uptime_fd); |
---|
107 | if(batt_fd) close(batt_fd); |
---|
108 | |
---|
109 | } |
---|
110 | |
---|
111 | |
---|
112 | static void reread(int f, char *errmsg) |
---|
113 | { |
---|
114 | if (lseek(f, 0L, 0) == 0 && read(f, buffer, sizeof(buffer) - 1 ) > 0 ) |
---|
115 | return; |
---|
116 | perror(errmsg); |
---|
117 | exit(1); |
---|
118 | } |
---|
119 | |
---|
120 | static int getentry(const char *tag, const char *bufptr) |
---|
121 | { |
---|
122 | char *tail; |
---|
123 | int retval, len = strlen(tag); |
---|
124 | |
---|
125 | while (bufptr) |
---|
126 | { |
---|
127 | if (*bufptr == '\n') bufptr++; |
---|
128 | if (!strncmp(tag, bufptr, len)) |
---|
129 | { |
---|
130 | retval = strtol(bufptr + len, &tail, 10); |
---|
131 | if (tail == bufptr + len) return -1; |
---|
132 | else return retval; |
---|
133 | } |
---|
134 | bufptr = strchr( bufptr, '\n'); |
---|
135 | } |
---|
136 | return -1; |
---|
137 | } |
---|
138 | |
---|
139 | static void get_mem_info(struct meminfo *result) |
---|
140 | { |
---|
141 | // int i, res; char *bufptr; |
---|
142 | |
---|
143 | reread(meminfo_fd, "get_meminfo:"); |
---|
144 | result[0].total = getentry("MemTotal:", buffer); |
---|
145 | result[0].free = getentry("MemFree:", buffer); |
---|
146 | result[0].shared = getentry("MemShared:", buffer); |
---|
147 | result[0].buffers = getentry("Buffers:", buffer); |
---|
148 | result[0].cache = getentry("Cached:", buffer); |
---|
149 | result[1].total = getentry("SwapTotal:", buffer); |
---|
150 | result[1].free = getentry("SwapFree:", buffer); |
---|
151 | } |
---|
152 | |
---|
153 | static double get_loadavg(void) |
---|
154 | { |
---|
155 | double load; |
---|
156 | |
---|
157 | reread(loadavg_fd, "get_load:"); |
---|
158 | sscanf(buffer, "%lf", &load); |
---|
159 | return load; |
---|
160 | } |
---|
161 | |
---|
162 | static double get_uptime(double *up, double *idle) |
---|
163 | { |
---|
164 | double uptime; |
---|
165 | |
---|
166 | reread(uptime_fd, "get_uptime:"); |
---|
167 | sscanf(buffer, "%lf %lf", &uptime, idle); |
---|
168 | |
---|
169 | *up = uptime; |
---|
170 | |
---|
171 | return uptime; |
---|
172 | } |
---|
173 | |
---|
174 | static int get_fs(mounts fs[]) |
---|
175 | { |
---|
176 | struct statfs fsinfo; |
---|
177 | char line[256]; |
---|
178 | int x = 0, y; |
---|
179 | |
---|
180 | mtab_fd = fopen("/etc/mtab", "r"); |
---|
181 | |
---|
182 | // Get rid of old, unmounted filesystems... |
---|
183 | memset(fs, 0, sizeof(mounts)*256); |
---|
184 | |
---|
185 | while (x < 256) |
---|
186 | { |
---|
187 | if(fgets(line, 256, mtab_fd) == NULL) |
---|
188 | { |
---|
189 | fclose(mtab_fd); |
---|
190 | return x; |
---|
191 | } |
---|
192 | |
---|
193 | sscanf(line, "%s %s %s", fs[x].dev, fs[x].mpoint, fs[x].type); |
---|
194 | |
---|
195 | if( strcmp(fs[x].type, "proc") |
---|
196 | #ifndef STAT_NFS |
---|
197 | && strcmp(fs[x].type, "nfs") |
---|
198 | #endif |
---|
199 | #ifndef STAT_SMBFS |
---|
200 | && strcmp(fs[x].type, "smbfs") |
---|
201 | #endif |
---|
202 | ) |
---|
203 | { |
---|
204 | #ifdef LINUX |
---|
205 | y = statfs(fs[x].mpoint, &fsinfo); |
---|
206 | #else |
---|
207 | y = statfs(fs[x].mpoint, &fsinfo, sizeof(fsinfo), 0); |
---|
208 | #endif |
---|
209 | fs[x].bsize = fsinfo.f_bsize; |
---|
210 | fs[x].blocks = fsinfo.f_blocks; |
---|
211 | fs[x].bfree = fsinfo.f_bfree; |
---|
212 | fs[x].files = fsinfo.f_files; |
---|
213 | fs[x].ffree = fsinfo.f_ffree; |
---|
214 | x++; |
---|
215 | } |
---|
216 | } |
---|
217 | |
---|
218 | fclose(mtab_fd); |
---|
219 | return x; |
---|
220 | } |
---|
221 | |
---|
222 | static void get_load(struct load * result) |
---|
223 | { |
---|
224 | static struct load last_load = { 0, 0, 0, 0, 0 }; struct load curr_load; |
---|
225 | |
---|
226 | reread(load_fd, "get_load:"); |
---|
227 | sscanf(buffer, "%*s %lu %lu %lu %lu\n", &curr_load.user, &curr_load.nice, &curr_load.system, &curr_load.idle); |
---|
228 | curr_load.total = curr_load.user + curr_load.nice + curr_load.system + curr_load.idle; |
---|
229 | result->total = curr_load.total - last_load.total; |
---|
230 | result->user = curr_load.user - last_load.user; |
---|
231 | result->nice = curr_load.nice - last_load.nice; |
---|
232 | result->system = curr_load.system - last_load.system; |
---|
233 | result->idle = curr_load.idle - last_load.idle; |
---|
234 | last_load.total = curr_load.total; |
---|
235 | last_load.user = curr_load.user; |
---|
236 | last_load.nice = curr_load.nice; |
---|
237 | last_load.system = curr_load.system; |
---|
238 | last_load.idle = curr_load.idle; |
---|
239 | } |
---|
240 | |
---|
241 | |
---|
242 | static int get_batt_stat(int *acstat, int *battstat, |
---|
243 | int *battflag, int *percent) |
---|
244 | { |
---|
245 | char str[64]; |
---|
246 | |
---|
247 | if(!batt_fd) |
---|
248 | batt_fd = open("/proc/apm", O_RDONLY); |
---|
249 | if(batt_fd <= 0) return -1; |
---|
250 | |
---|
251 | if(lseek(batt_fd, 0, 0) != 0) return -1; |
---|
252 | |
---|
253 | if(read(batt_fd, str, sizeof(str)-1) < 0) return -1; |
---|
254 | |
---|
255 | if(3 > sscanf(str+13, "0x%x 0x%x 0x%x %d", |
---|
256 | acstat, battstat, battflag, percent)) |
---|
257 | return -1; |
---|
258 | |
---|
259 | return 0; |
---|
260 | |
---|
261 | } |
---|
262 | |
---|
263 | |
---|
264 | /////////////////////////////////////////////////////////////////////////// |
---|
265 | //////////////////////// Let the Modes Begin! ///////////////////////////// |
---|
266 | /////////////////////////////////////////////////////////////////////////// |
---|
267 | |
---|
268 | // TODO: Implement more return values for behavior changing... |
---|
269 | // TODO: more modes... |
---|
270 | |
---|
271 | static char tmp[256]; |
---|
272 | |
---|
273 | // A couple of tables for later use... |
---|
274 | static char *days[] = { |
---|
275 | "Sunday, ", |
---|
276 | "Monday, ", |
---|
277 | "Tuesday, ", |
---|
278 | "Wednesday,", |
---|
279 | "Thursday, ", |
---|
280 | "Friday, ", |
---|
281 | "Saturday, ", |
---|
282 | }; |
---|
283 | static char *shortdays[] = { |
---|
284 | "Sun", |
---|
285 | "Mon", |
---|
286 | "Tue", |
---|
287 | "Wed", |
---|
288 | "Thu", |
---|
289 | "Fri", |
---|
290 | "Sat", |
---|
291 | }; |
---|
292 | |
---|
293 | static char *months[] = { |
---|
294 | " January", |
---|
295 | " February", |
---|
296 | " March", |
---|
297 | " April", |
---|
298 | " May", |
---|
299 | " June", |
---|
300 | " July", |
---|
301 | " August", |
---|
302 | "September", |
---|
303 | " October", |
---|
304 | " November", |
---|
305 | " December", |
---|
306 | }; |
---|
307 | static char *shortmonths[] = { |
---|
308 | "Jan", |
---|
309 | "Feb", |
---|
310 | "Mar", |
---|
311 | "Apr", |
---|
312 | "May", |
---|
313 | "Jun", |
---|
314 | "Jul", |
---|
315 | "Aug", |
---|
316 | "Sep", |
---|
317 | "Oct", |
---|
318 | "Nov", |
---|
319 | "Dec", |
---|
320 | }; |
---|
321 | |
---|
322 | |
---|
323 | ////////////////////////////////////////////////////////////////////////// |
---|
324 | // CPU screen shows info about percentage of the CPU being used |
---|
325 | // |
---|
326 | int cpu_screen(int rep) |
---|
327 | { |
---|
328 | #undef CPU_BUF_SIZE |
---|
329 | #define CPU_BUF_SIZE 4 |
---|
330 | int i, j, n; |
---|
331 | float value; |
---|
332 | static float cpu[CPU_BUF_SIZE + 1][5];// last buffer is scratch |
---|
333 | struct load load; |
---|
334 | |
---|
335 | |
---|
336 | |
---|
337 | get_load(&load); |
---|
338 | |
---|
339 | // Shift values over by one |
---|
340 | for(i=0; i<(CPU_BUF_SIZE-1); i++) |
---|
341 | for(j=0; j<5; j++) |
---|
342 | cpu[i][j] = cpu[i+1][j]; |
---|
343 | |
---|
344 | // Read new data |
---|
345 | cpu[CPU_BUF_SIZE-1][0] = ((float)load.user / (float)load.total) * 100.0; |
---|
346 | cpu[CPU_BUF_SIZE-1][1] = ((float)load.system / (float)load.total) * 100.0; |
---|
347 | cpu[CPU_BUF_SIZE-1][2] = ((float)load.nice / (float)load.total) * 100.0; |
---|
348 | cpu[CPU_BUF_SIZE-1][3] = ((float)load.idle / (float)load.total) * 100.0; |
---|
349 | cpu[CPU_BUF_SIZE-1][4] = (((float)load.user + (float)load.system + |
---|
350 | (float)load.nice) / (float)load.total) * 100.0; |
---|
351 | |
---|
352 | // Only clear on first display... |
---|
353 | if(!rep) |
---|
354 | { |
---|
355 | lcd.clear(); |
---|
356 | lcd.init_hbar(); |
---|
357 | |
---|
358 | sprintf(tmp, "%c%c CPU LOAD %c%c", PAD, PAD, PAD, PAD); |
---|
359 | |
---|
360 | lcd.string(1, 1, tmp); |
---|
361 | lcd.string(1, 2, "Usr 0.0% Nice 0.0%"); |
---|
362 | lcd.string(1, 3, "Sys 0.0% Idle 0.0%"); |
---|
363 | lcd.string(1, 4, "0% 100%"); |
---|
364 | |
---|
365 | // Make all the same, if this is the first time... |
---|
366 | for(i=0; i<CPU_BUF_SIZE-1; i++) |
---|
367 | for(j=0; j<5; j++) |
---|
368 | cpu[i][j] = cpu[CPU_BUF_SIZE-1][j]; |
---|
369 | } |
---|
370 | |
---|
371 | |
---|
372 | |
---|
373 | // Average values for final result |
---|
374 | for(i=0; i<5; i++) |
---|
375 | { |
---|
376 | value = 0; |
---|
377 | for(j=0; j<CPU_BUF_SIZE; j++) |
---|
378 | { |
---|
379 | value += cpu[j][i]; |
---|
380 | } |
---|
381 | value /= CPU_BUF_SIZE; |
---|
382 | cpu[CPU_BUF_SIZE][i] = value; |
---|
383 | } |
---|
384 | |
---|
385 | |
---|
386 | value = cpu[CPU_BUF_SIZE][4]; |
---|
387 | n = (int)(value * 70.0); |
---|
388 | if (value >= 99.9) { lcd.string(13, 1, " 100%"); } |
---|
389 | else { sprintf(tmp, "%4.1f%%", value); lcd.string(13, 1, tmp); } |
---|
390 | |
---|
391 | value = cpu[CPU_BUF_SIZE][0]; |
---|
392 | if (value >= 99.9) { lcd.string(5, 2, " 100%"); } |
---|
393 | else { sprintf(tmp, "%4.1f%%", value); lcd.string(5, 2, tmp); } |
---|
394 | |
---|
395 | value = cpu[CPU_BUF_SIZE][1]; |
---|
396 | if (value >= 99.9) { lcd.string(5, 3, " 100%"); } |
---|
397 | else { sprintf(tmp, "%4.1f%%", value); lcd.string(5, 3, tmp); } |
---|
398 | |
---|
399 | value = cpu[CPU_BUF_SIZE][2]; |
---|
400 | if (value >= 99.9) { lcd.string(16, 2, " 100%"); } |
---|
401 | else { sprintf(tmp, "%4.1f%%", value); lcd.string(16, 2, tmp); } |
---|
402 | |
---|
403 | value = cpu[CPU_BUF_SIZE][3]; |
---|
404 | if (value >= 99.9) { lcd.string(16, 3, " 100%"); } |
---|
405 | else { sprintf(tmp, "%4.1f%%", value); lcd.string(16, 3, tmp); } |
---|
406 | |
---|
407 | value = cpu[CPU_BUF_SIZE][4]; |
---|
408 | n = (int)(value * 70.0 / 100.0); |
---|
409 | lcd.string(1, 4, "0% 100%"); |
---|
410 | lcd.hbar(3, 4, n); |
---|
411 | |
---|
412 | return 0; |
---|
413 | } // End cpu_screen() |
---|
414 | |
---|
415 | |
---|
416 | |
---|
417 | ////////////////////////////////////////////////////////////////////////// |
---|
418 | // Cpu Graph Screen shows a quick-moving histogram of CPU use. |
---|
419 | // |
---|
420 | int cpu_graph_screen(int rep) |
---|
421 | { |
---|
422 | int i, j, n; |
---|
423 | float value, maxload; |
---|
424 | #undef CPU_BUF_SIZE |
---|
425 | #define CPU_BUF_SIZE 2 |
---|
426 | static float cpu[CPU_BUF_SIZE + 1];// last buffer is scratch |
---|
427 | static float cpu_past[LCD_MAX_WIDTH]; |
---|
428 | struct load load; |
---|
429 | int status=0; |
---|
430 | char out[LCD_MAX_WIDTH]; |
---|
431 | |
---|
432 | |
---|
433 | |
---|
434 | get_load(&load); |
---|
435 | |
---|
436 | // Shift values over by one |
---|
437 | for(i=0; i<(CPU_BUF_SIZE-1); i++) |
---|
438 | cpu[i] = cpu[i+1]; |
---|
439 | |
---|
440 | // Read new data |
---|
441 | cpu[CPU_BUF_SIZE-1] = ((float)load.user + (float)load.system |
---|
442 | + (float)load.nice) / (float)load.total; |
---|
443 | |
---|
444 | |
---|
445 | // Only clear on first display... |
---|
446 | if(!rep) |
---|
447 | { |
---|
448 | lcd.init_vbar(); |
---|
449 | |
---|
450 | // Make all the same, if this is the first time... |
---|
451 | for(i=0; i<CPU_BUF_SIZE-1; i++) |
---|
452 | cpu[i] = cpu[CPU_BUF_SIZE-1]; |
---|
453 | |
---|
454 | } |
---|
455 | |
---|
456 | //lcd.clear(); |
---|
457 | for(i=2; i<=lcd.hgt; i++) |
---|
458 | lcd.string(1,i," "); |
---|
459 | |
---|
460 | |
---|
461 | // Average values for final result |
---|
462 | value = 0; |
---|
463 | for(j=0; j<CPU_BUF_SIZE; j++) |
---|
464 | { |
---|
465 | value += cpu[j]; |
---|
466 | } |
---|
467 | value /= (float)CPU_BUF_SIZE; |
---|
468 | cpu[CPU_BUF_SIZE] = value; |
---|
469 | |
---|
470 | |
---|
471 | maxload=0; |
---|
472 | for(i=0; i<lcd.wid-1; i++) |
---|
473 | { |
---|
474 | cpu_past[i] = cpu_past[i+1]; |
---|
475 | lcd.vbar(i+1, cpu_past[i]); |
---|
476 | if(cpu_past[i] > maxload) maxload = cpu_past[i]; |
---|
477 | } |
---|
478 | |
---|
479 | value = cpu[CPU_BUF_SIZE]; |
---|
480 | n = (int)(value * 8.0 * (float)(lcd.hgt-1)); |
---|
481 | |
---|
482 | cpu_past[lcd.wid-1] = n; |
---|
483 | lcd.vbar(lcd.wid, cpu_past[lcd.wid-1]); |
---|
484 | |
---|
485 | sprintf(out, "%c%c CPU GRAPH %c%c%c%c%c%c", PAD,PAD, |
---|
486 | PAD,PAD,PAD,PAD,PAD,PAD); |
---|
487 | lcd.string(1,1,out); |
---|
488 | |
---|
489 | |
---|
490 | |
---|
491 | if(n > maxload) maxload = n; |
---|
492 | |
---|
493 | if(cpu_past[lcd.wid-1] > 0 ) status = BACKLIGHT_ON; |
---|
494 | if(maxload < 1) status = BACKLIGHT_OFF; |
---|
495 | |
---|
496 | // return status; |
---|
497 | return 0; |
---|
498 | } // End cpu_graph_screen() |
---|
499 | |
---|
500 | |
---|
501 | |
---|
502 | ////////////////////////////////////////////////////////////////////// |
---|
503 | // Clock Screen displays current time and date... |
---|
504 | // |
---|
505 | // TODO: 24-hour time on old clock screen, if desired. |
---|
506 | int clock_screen(int rep) |
---|
507 | { |
---|
508 | char hr[8], min[8], sec[8], ampm[8]; |
---|
509 | char day[16], month[16]; |
---|
510 | time_t thetime; |
---|
511 | struct tm *rtime; |
---|
512 | int i; |
---|
513 | |
---|
514 | |
---|
515 | if(!rep) |
---|
516 | { |
---|
517 | lcd.clear(); |
---|
518 | sprintf(tmp, "%c%c DATE & TIME %c%c%c%c%c", PAD, PAD, PAD, PAD, PAD, PAD, PAD); |
---|
519 | lcd.string(1, 1, tmp); |
---|
520 | } |
---|
521 | |
---|
522 | time(&thetime); |
---|
523 | rtime = localtime(&thetime); |
---|
524 | |
---|
525 | strcpy(day, days[rtime->tm_wday]); |
---|
526 | |
---|
527 | if (rtime->tm_hour > 12) { i = 1; sprintf(hr, "%02d", (rtime->tm_hour - 12)); } |
---|
528 | else { i = 0; sprintf(hr, "%02d", rtime->tm_hour); } |
---|
529 | if(rtime->tm_hour == 12) i=1; |
---|
530 | sprintf(min, "%02d", rtime->tm_min); |
---|
531 | sprintf(sec, "%02d", rtime->tm_sec); |
---|
532 | if (i == 1) { sprintf(ampm, "%s", "P"); } |
---|
533 | else { sprintf(ampm, "%s", "A"); } |
---|
534 | if (rep & 1) { sprintf(tmp, "%s:%s:%s%s %s", hr, min, sec, ampm, day); } |
---|
535 | else { sprintf(tmp, "%s %s %s%s %s", hr, min, sec, ampm, day); } |
---|
536 | |
---|
537 | strcpy(month, months[rtime->tm_mon]); |
---|
538 | |
---|
539 | lcd.string(1, 3, tmp); |
---|
540 | |
---|
541 | sprintf(tmp, "%s %d, %d", month, rtime->tm_mday, (rtime->tm_year + 1900)); |
---|
542 | lcd.string(2, 4, tmp); |
---|
543 | |
---|
544 | return 0; |
---|
545 | } // End clock_screen() |
---|
546 | |
---|
547 | |
---|
548 | |
---|
549 | ////////////////////////////////////////////////////////////////////// |
---|
550 | // Time Screen displays current time and date, uptime, OS ver... |
---|
551 | // |
---|
552 | //+--------------------+ |
---|
553 | //|## Linux 2.0.33 ###@| |
---|
554 | //|Up xxx days hh:mm:ss| |
---|
555 | //| Wed May 17, 1998 | |
---|
556 | //|11:32:57a 100% idle| |
---|
557 | //+--------------------+ |
---|
558 | // |
---|
559 | |
---|
560 | int time_screen(int rep) |
---|
561 | { |
---|
562 | char hr[8], min[8], sec[8], ampm[8]; |
---|
563 | char day[16], month[16]; |
---|
564 | time_t thetime; |
---|
565 | struct tm *rtime; |
---|
566 | double uptime, idle; |
---|
567 | int i; |
---|
568 | |
---|
569 | |
---|
570 | |
---|
571 | if(!rep) |
---|
572 | { |
---|
573 | lcd.clear(); |
---|
574 | } |
---|
575 | |
---|
576 | |
---|
577 | get_uptime(&uptime, &idle); |
---|
578 | idle = (idle * 100) / uptime; |
---|
579 | |
---|
580 | |
---|
581 | ///////////////////// Write the title bar (os name and version) |
---|
582 | memset(tmp, 0, lcd.wid+1); |
---|
583 | sprintf(tmp, "%c%c %s %s ", |
---|
584 | PAD, PAD, sysname, kver); |
---|
585 | for(i=1; i<(20-strlen(sysname)-strlen(kver)-4); i++) |
---|
586 | tmp[lcd.wid-i]=PAD; |
---|
587 | |
---|
588 | lcd.string(1, 1, tmp); |
---|
589 | |
---|
590 | /////////////////////// Display the time... |
---|
591 | time(&thetime); |
---|
592 | rtime = localtime(&thetime); |
---|
593 | |
---|
594 | if(TwentyFourHour) |
---|
595 | { |
---|
596 | sprintf(hr, "%02d", rtime->tm_hour); |
---|
597 | } |
---|
598 | else |
---|
599 | { |
---|
600 | if (rtime->tm_hour > 12) |
---|
601 | { i = 1; sprintf(hr, "%02d", (rtime->tm_hour - 12)); } |
---|
602 | else { i = 0; sprintf(hr, "%02d", rtime->tm_hour); } |
---|
603 | } |
---|
604 | if(rtime->tm_hour == 12) i=1; |
---|
605 | if (i == 1) { sprintf(ampm, "%s", "P"); } |
---|
606 | else { sprintf(ampm, "%s", "A"); } |
---|
607 | |
---|
608 | sprintf(min, "%02d", rtime->tm_min); |
---|
609 | sprintf(sec, "%02d", rtime->tm_sec); |
---|
610 | if (rep & 1) |
---|
611 | { |
---|
612 | if(TwentyFourHour) |
---|
613 | sprintf(tmp, "%s:%s:%s %2i%% idle", hr, min, sec, (int)idle); |
---|
614 | else |
---|
615 | sprintf(tmp, "%s:%s:%s%s %2i%% idle", hr, min, sec, ampm, (int)idle); |
---|
616 | } |
---|
617 | else |
---|
618 | { |
---|
619 | if(TwentyFourHour) |
---|
620 | sprintf(tmp, "%s %s %s %2i%% idle", hr, min, sec, (int)idle); |
---|
621 | else |
---|
622 | sprintf(tmp, "%s %s %s%s %2i%% idle", hr, min, sec, ampm, (int)idle); |
---|
623 | } |
---|
624 | // Center the output line... |
---|
625 | i = ((lcd.wid - strlen(tmp)) / 2) + 1; |
---|
626 | lcd.string(i, 4, tmp); |
---|
627 | |
---|
628 | |
---|
629 | |
---|
630 | |
---|
631 | /////////////////////// Display the uptime... |
---|
632 | strcpy(day, shortdays[rtime->tm_wday]); |
---|
633 | strcpy(month, shortmonths[rtime->tm_mon]); |
---|
634 | |
---|
635 | sprintf(tmp, "%s %s %d, %d", day, month, |
---|
636 | rtime->tm_mday, (rtime->tm_year + 1900)); |
---|
637 | lcd.string(3, 3, tmp); |
---|
638 | |
---|
639 | |
---|
640 | i = (int)uptime / 86400; |
---|
641 | sprintf(day, "%d day%s,", i, (i != 1 ? "s" : "")); |
---|
642 | i = ((int)uptime % 86400) / 60 / 60; |
---|
643 | sprintf(hr, "%02i",i); |
---|
644 | i = (((int)uptime % 86400) % 3600) / 60; |
---|
645 | sprintf(min, "%02i",i); |
---|
646 | i = ((int)uptime % 60); |
---|
647 | sprintf(sec, "%02i",i); |
---|
648 | if (rep & 1) |
---|
649 | sprintf(tmp, "%s %s:%s:%s", day, hr, min, sec); |
---|
650 | else |
---|
651 | sprintf(tmp, "%s %s %s %s", day, hr, min, sec); |
---|
652 | // Center this line automatically... |
---|
653 | i = ((lcd.wid - strlen(tmp)) / 2) + 1; |
---|
654 | lcd.string(i, 2, tmp); |
---|
655 | |
---|
656 | return 0; |
---|
657 | } // End time_screen() |
---|
658 | |
---|
659 | |
---|
660 | ///////////////////////////////////////////////////////////////////////// |
---|
661 | // Mem Screen displays info about memory and swap usage... |
---|
662 | // |
---|
663 | int mem_screen(int rep) |
---|
664 | { |
---|
665 | int n; |
---|
666 | struct meminfo mem[2]; |
---|
667 | |
---|
668 | |
---|
669 | if(!rep) |
---|
670 | { |
---|
671 | lcd.clear(); |
---|
672 | lcd.init_hbar(); |
---|
673 | sprintf(tmp, "%c%c%c MEM %c%c%c%c SWAP %c%c", |
---|
674 | PAD,PAD,PAD,PAD,PAD,PAD,PAD,PAD,PAD); |
---|
675 | lcd.string(1, 1, tmp); |
---|
676 | lcd.string(9, 2, "Totl"); |
---|
677 | lcd.string(9, 3, "Free"); |
---|
678 | //lcd.string(1, 4, "E F E F"); |
---|
679 | } |
---|
680 | |
---|
681 | |
---|
682 | // Total memory |
---|
683 | get_mem_info(mem); |
---|
684 | sprintf(tmp, "%6dk", mem[0].total); |
---|
685 | lcd.string(1, 2, tmp); |
---|
686 | |
---|
687 | // Free memory (plus buffers and cache) |
---|
688 | sprintf(tmp, "%6dk", |
---|
689 | mem[0].free + mem[0].buffers + mem[0].cache); |
---|
690 | lcd.string(1, 3, tmp); |
---|
691 | |
---|
692 | // Total swap |
---|
693 | sprintf(tmp, "%6dk", mem[1].total); |
---|
694 | lcd.string(14, 2, tmp); |
---|
695 | |
---|
696 | // Free swap |
---|
697 | sprintf(tmp, "%6dk", mem[1].free); |
---|
698 | lcd.string(14, 3, tmp); |
---|
699 | |
---|
700 | |
---|
701 | // Empty or full? |
---|
702 | lcd.string(1, 4, "E F E F"); |
---|
703 | |
---|
704 | // Free memory graph |
---|
705 | n = (int)(35.0 - |
---|
706 | ((float)mem[0].free + (float)mem[0].buffers + (float)mem[0].cache) |
---|
707 | / (float)mem[0].total |
---|
708 | * 35.0); |
---|
709 | lcd.hbar(2, 4, n); |
---|
710 | |
---|
711 | // Free swap graph |
---|
712 | n = (int)(35.0 - |
---|
713 | (float)mem[1].free / (float)mem[1].total |
---|
714 | * 35.0); |
---|
715 | lcd.hbar(13, 4, n); |
---|
716 | |
---|
717 | |
---|
718 | return 0; |
---|
719 | } // End mem_screen() |
---|
720 | |
---|
721 | |
---|
722 | //////////////////////////////////////////////////////////////////// |
---|
723 | // Uptime Screen shows info about system uptime and OS version |
---|
724 | // |
---|
725 | int uptime_screen(int rep) |
---|
726 | { |
---|
727 | int i; |
---|
728 | char date[16], hour[8], min[8], sec[8]; |
---|
729 | double uptime, idle; |
---|
730 | |
---|
731 | |
---|
732 | if(!rep) |
---|
733 | { |
---|
734 | lcd.clear(); |
---|
735 | sprintf(tmp, "%c%c SYSTEM UPTIME %c%c%c", PAD, PAD, PAD, PAD, PAD); |
---|
736 | lcd.string(1, 1, tmp); |
---|
737 | |
---|
738 | sprintf(tmp, "%s %s", sysname, kver); |
---|
739 | lcd.string(5, 4, tmp); |
---|
740 | } |
---|
741 | |
---|
742 | get_uptime(&uptime, &idle); |
---|
743 | i = (int)uptime / 86400; |
---|
744 | sprintf(date, "%d day%s,", i, (i != 1 ? "s" : "")); |
---|
745 | i = ((int)uptime % 86400) / 60 / 60; |
---|
746 | sprintf(hour, "%02i",i); |
---|
747 | i = (((int)uptime % 86400) % 3600) / 60; |
---|
748 | sprintf(min, "%02i",i); |
---|
749 | i = ((int)uptime % 60); |
---|
750 | sprintf(sec, "%02i",i); |
---|
751 | if (rep & 1) |
---|
752 | sprintf(tmp, "%s %s:%s:%s", date, hour, min, sec); |
---|
753 | else |
---|
754 | sprintf(tmp, "%s %s %s %s", date, hour, min, sec); |
---|
755 | i = ((20 - strlen(tmp)) / 2) + 1; |
---|
756 | lcd.string(i, 3, tmp); |
---|
757 | |
---|
758 | |
---|
759 | return 0; |
---|
760 | } // End uptime_screen() |
---|
761 | |
---|
762 | |
---|
763 | /////////////////////////////////////////////////////////////////////////// |
---|
764 | // Gives disk stats. |
---|
765 | // |
---|
766 | // Stays onscreen until it is done. |
---|
767 | // |
---|
768 | int disk_screen(int rep) |
---|
769 | { |
---|
770 | static mounts mnt[256]; |
---|
771 | static int count=0; |
---|
772 | |
---|
773 | struct disp // Holds info to display (avoid recalculating it) |
---|
774 | { |
---|
775 | char dev[8]; |
---|
776 | char cap[8]; |
---|
777 | int full; |
---|
778 | } table[256]; |
---|
779 | int i, y; |
---|
780 | static int first=0; // First line to display, sort of. |
---|
781 | |
---|
782 | #define huge long long int |
---|
783 | huge size; |
---|
784 | |
---|
785 | |
---|
786 | // Grab disk stats on first display, and fill "table". |
---|
787 | if(!rep) |
---|
788 | { |
---|
789 | lcd.clear(); |
---|
790 | lcd.init_hbar(); |
---|
791 | lcd.icon(2,7); |
---|
792 | |
---|
793 | // Get rid of old, unmounted filesystems... |
---|
794 | memset(table, 0, sizeof(struct disp)*256); |
---|
795 | |
---|
796 | count = get_fs(mnt); |
---|
797 | first = 0; |
---|
798 | |
---|
799 | sprintf(tmp, "%c%c FILESYSTEMS %c%c%c%c", |
---|
800 | PAD, PAD, PAD, PAD, PAD, PAD); |
---|
801 | lcd.string(1, 1, tmp); |
---|
802 | |
---|
803 | // Fill the display structure... |
---|
804 | if(count) |
---|
805 | { |
---|
806 | for(i=0; i<count; i++) |
---|
807 | { |
---|
808 | if(strlen(mnt[i].mpoint) > 6) |
---|
809 | { |
---|
810 | sprintf(table[i].dev, "%c%s", ELLIPSIS, |
---|
811 | (mnt[i].mpoint)+(strlen(mnt[i].mpoint)-5)); |
---|
812 | } |
---|
813 | else |
---|
814 | { |
---|
815 | sprintf(table[i].dev, "%s", mnt[i].mpoint); |
---|
816 | } |
---|
817 | |
---|
818 | table[i].full = (lcd.cellwid * 4) |
---|
819 | * (huge)(mnt[i].blocks - mnt[i].bfree) |
---|
820 | / (huge)mnt[i].blocks; |
---|
821 | |
---|
822 | size = (huge)mnt[i].bsize * (huge)mnt[i].blocks; |
---|
823 | memset(table[i].cap, 0, 8); |
---|
824 | |
---|
825 | // Kilobytes |
---|
826 | if(size > 0 && size < (huge)1000*(huge)1000) |
---|
827 | sprintf(table[i].cap, "%3.1fk", |
---|
828 | (double)(size)/1024.0); |
---|
829 | // Megabytes |
---|
830 | else if(size >= (huge)1000*(huge)1000 |
---|
831 | && size < (huge)1000*(huge)1000*(huge)1000) |
---|
832 | sprintf(table[i].cap, "%3.1fM", |
---|
833 | (float)(size/(huge)1024)/1024.0); |
---|
834 | // Gigabytes |
---|
835 | else if(size >= (huge)1000*(huge)1000*(huge)1000 |
---|
836 | && size < (huge)1000*(huge)1000*(huge)1000*(huge)1000) |
---|
837 | sprintf(table[i].cap, "%3.1fG", |
---|
838 | (float)(size/((huge)1024*(huge)1024))/1024.0); |
---|
839 | // Terabytes |
---|
840 | else if(size >= (huge)1000*(huge)1000*(huge)1000*(huge)1000 |
---|
841 | && size < (huge)1000*(huge)1000*(huge)1000*(huge)1000*(huge)1000) |
---|
842 | sprintf(table[i].cap, "%3.1fT", |
---|
843 | (float)(size/((huge)1024*(huge)1024*(huge)1024))/1024.0); |
---|
844 | |
---|
845 | // PectaBytes -- Yeah! I want some! |
---|
846 | else if(size >= (huge)1000*(huge)1000*(huge)1000*(huge)1000*(huge)1000 |
---|
847 | && size < (huge)1000*(huge)1000*(huge)1000*(huge)1000*(huge)1000*(huge)1000) |
---|
848 | sprintf(table[i].cap, "%3.1fP", |
---|
849 | (float)(size/((huge)1024*(huge)1024*(huge)1024*(huge)1024))/1024.0); |
---|
850 | |
---|
851 | } |
---|
852 | } |
---|
853 | } // End if(!rep) |
---|
854 | |
---|
855 | |
---|
856 | // Increment this once per second. |
---|
857 | if((rep&7) == 0) first++; |
---|
858 | |
---|
859 | |
---|
860 | if (!count) |
---|
861 | { |
---|
862 | lcd.string(1, 2, "Error Retrieving"); |
---|
863 | lcd.string(5, 3, "Filesystem Stats"); |
---|
864 | return 0; |
---|
865 | } |
---|
866 | |
---|
867 | // If we are done, tell the system to keep going. |
---|
868 | if (first >= count+1) |
---|
869 | return CONTINUE; |
---|
870 | |
---|
871 | |
---|
872 | // Display stuff... (show for two seconds, then scroll once per |
---|
873 | // second, then hold at the end for two seconds) |
---|
874 | for(y=0; y<3; y++) |
---|
875 | { |
---|
876 | i = first - 2; |
---|
877 | if(i>count-3) i=count-3; |
---|
878 | if(i<0) i=0; |
---|
879 | i += y; |
---|
880 | |
---|
881 | if(table[i].dev[0] == 0) continue; |
---|
882 | sprintf(tmp, "%-6s %6s E F", table[i].dev, table[i].cap); |
---|
883 | |
---|
884 | lcd.string(1, y+2, tmp); |
---|
885 | lcd.hbar(16, y+2, table[i].full); |
---|
886 | } |
---|
887 | |
---|
888 | |
---|
889 | #undef huge |
---|
890 | |
---|
891 | /* |
---|
892 | // ** FILESYSTEMS ***** |
---|
893 | // / 543.2M E----F |
---|
894 | // /dos/c 2.1G E----F |
---|
895 | // /stuff 4.3G E----F |
---|
896 | */ |
---|
897 | return HOLD_SCREEN; |
---|
898 | } |
---|
899 | |
---|
900 | |
---|
901 | /////////////////////////////////////////////////////////////////////////// |
---|
902 | // Shows a display very similar to "xload"'s histogram. |
---|
903 | // |
---|
904 | |
---|
905 | int xload_screen(int rep) |
---|
906 | { |
---|
907 | static float loads[LCD_MAX_WIDTH]; |
---|
908 | static int first_time=1; |
---|
909 | int n; |
---|
910 | float loadmax=0, factor, x; |
---|
911 | int status = 0; |
---|
912 | |
---|
913 | |
---|
914 | if(first_time) // Only the first time this is ever called... |
---|
915 | { |
---|
916 | memset(loads, 0, sizeof(float)*LCD_MAX_WIDTH); |
---|
917 | first_time = 0; |
---|
918 | } |
---|
919 | |
---|
920 | if(!rep) |
---|
921 | { |
---|
922 | lcd.clear(); |
---|
923 | } |
---|
924 | |
---|
925 | |
---|
926 | for(n=0; n<(lcd.wid-2); n++) loads[n] = loads[n+1]; |
---|
927 | loads[lcd.wid-2] = get_loadavg(); |
---|
928 | |
---|
929 | for(n=0; n<lcd.wid-1; n++) |
---|
930 | if(loads[n] > loadmax) loadmax = loads[n]; |
---|
931 | |
---|
932 | lcd.string(20, 4, "0"); |
---|
933 | n = (int)loadmax; |
---|
934 | if ((float)n < loadmax) { n++; } |
---|
935 | sprintf(tmp, "%i", n); lcd.string(20, 2, tmp); |
---|
936 | |
---|
937 | if (loadmax < 1.0) factor = 24.0; |
---|
938 | else factor = 24 / (float)n; |
---|
939 | |
---|
940 | for(n=0; n<lcd.wid-1; n++) |
---|
941 | { |
---|
942 | x = (loads[n] * factor); |
---|
943 | lcd.vbar(n+1, (int)x); |
---|
944 | } |
---|
945 | |
---|
946 | if(loadmax < LOAD_MIN) status = BACKLIGHT_OFF; |
---|
947 | if(loadmax > LOAD_MIN) status = BACKLIGHT_ON; |
---|
948 | if(loads[lcd.wid-2] > LOAD_MAX) status = BLINK_ON; |
---|
949 | |
---|
950 | // This must be drawn *after* the vertical bars... (?) |
---|
951 | sprintf(tmp, "%c%c LOAD AVG %2.2f %c%c", PAD, PAD, loads[lcd.wid-2], PAD, PAD); |
---|
952 | lcd.string(1, 1, tmp); |
---|
953 | |
---|
954 | if(!rep) |
---|
955 | lcd.init_vbar(); |
---|
956 | |
---|
957 | |
---|
958 | return status; |
---|
959 | } // End xload_screen() |
---|
960 | |
---|
961 | |
---|
962 | |
---|
963 | |
---|
964 | |
---|
965 | //////////////////////////////////////////////////////////////////////// |
---|
966 | // Battery Screen shows apm battery status... |
---|
967 | // |
---|
968 | |
---|
969 | //#################### |
---|
970 | //## Battery: 100% ### |
---|
971 | //AC: Unknown |
---|
972 | //Batt: Low (Charging) |
---|
973 | //E------------------F |
---|
974 | |
---|
975 | int battery_screen(int rep) |
---|
976 | { |
---|
977 | int acstat=0, battstat=0, battflag=0, percent=0; |
---|
978 | |
---|
979 | |
---|
980 | // Only run once every 16 frames... |
---|
981 | if(rep&0x0f) return 0; |
---|
982 | |
---|
983 | get_batt_stat(&acstat, &battstat, &battflag, &percent); |
---|
984 | |
---|
985 | lcd.clear(); |
---|
986 | |
---|
987 | |
---|
988 | sprintf(tmp, "%c%c Battery: ", PAD, PAD); |
---|
989 | |
---|
990 | if(percent >= 0) sprintf(tmp+strlen(tmp), "%i%% %c%c%c%c", |
---|
991 | percent, PAD, PAD, PAD, PAD); |
---|
992 | else sprintf(tmp+strlen(tmp), "??%% %c%c%c", PAD, PAD, PAD); |
---|
993 | |
---|
994 | lcd.string(1,1,tmp); |
---|
995 | |
---|
996 | |
---|
997 | switch(acstat) |
---|
998 | { |
---|
999 | case 0: sprintf(tmp, "AC: Off"); |
---|
1000 | break; |
---|
1001 | case 1: sprintf(tmp, "AC: On"); |
---|
1002 | break; |
---|
1003 | case 2: sprintf(tmp, "AC: Backup"); |
---|
1004 | break; |
---|
1005 | default: sprintf(tmp, "AC: Unknown"); |
---|
1006 | break; |
---|
1007 | } |
---|
1008 | |
---|
1009 | lcd.string(1,2,tmp); |
---|
1010 | |
---|
1011 | |
---|
1012 | if(battflag == 0xff) |
---|
1013 | { |
---|
1014 | sprintf(tmp, "Battery Stat Unknown"); |
---|
1015 | } |
---|
1016 | else |
---|
1017 | { |
---|
1018 | sprintf(tmp, "Batt:"); |
---|
1019 | if(battflag & 1) sprintf(tmp+strlen(tmp), " High"); |
---|
1020 | if(battflag & 2) sprintf(tmp+strlen(tmp), " Low"); |
---|
1021 | if(battflag & 4) sprintf(tmp+strlen(tmp), " Critical"); |
---|
1022 | if(battflag & 8 |
---|
1023 | ||battstat == 3) sprintf(tmp+strlen(tmp), " Charging"); |
---|
1024 | if(battflag & 128) sprintf(tmp+strlen(tmp), " (NONE)"); |
---|
1025 | } |
---|
1026 | lcd.string(1,3,tmp); |
---|
1027 | |
---|
1028 | lcd.chr(1,4, 'E'); |
---|
1029 | lcd.chr(lcd.wid,4, 'F'); |
---|
1030 | |
---|
1031 | if(percent > 0) |
---|
1032 | { |
---|
1033 | lcd.hbar(2,4, (percent * ((lcd.wid-2)*lcd.cellwid)/100)); |
---|
1034 | } |
---|
1035 | |
---|
1036 | |
---|
1037 | return 0; |
---|
1038 | } |
---|
1039 | |
---|
1040 | |
---|
1041 | |
---|
1042 | //////////////////////////////////////////////////////////////////////// |
---|
1043 | // Credit Screen shows who wrote this... |
---|
1044 | // |
---|
1045 | int credit_screen(int rep) |
---|
1046 | { |
---|
1047 | |
---|
1048 | if(!rep) |
---|
1049 | { |
---|
1050 | lcd.clear(); |
---|
1051 | sprintf(tmp, "%c%c LCDPROC %s %c%c%c%c", |
---|
1052 | PAD, PAD, version, PAD, PAD, PAD, PAD); |
---|
1053 | lcd.string(1, 1, tmp); |
---|
1054 | lcd.string(1, 2, " for Linux "); |
---|
1055 | lcd.string(1, 3, " by William Ferrell "); |
---|
1056 | lcd.string(1, 4, " and Scott Scriven "); |
---|
1057 | } |
---|
1058 | |
---|
1059 | return 0; |
---|
1060 | } // End credit_screen() |
---|
1061 | |
---|
1062 | |
---|
1063 | ////////////////////////////////////////////////////////////////////// |
---|
1064 | // This is mostly for debugging. It should never show up. |
---|
1065 | // |
---|
1066 | int dumbass_screen(int rep) |
---|
1067 | { |
---|
1068 | |
---|
1069 | lcd.string(1,1, "---=== Haha... ==---"); |
---|
1070 | lcd.string(1,2, " You specified an "); |
---|
1071 | lcd.string(1,3, " INVALID MODE!!! "); |
---|
1072 | lcd.string(1,4, "---== Ya LOSER! ==--"); |
---|
1073 | /* |
---|
1074 | lcd.string(1,1, "--===GO AWAY!!!===--"); |
---|
1075 | lcd.string(1,2, " You're a slimy, "); |
---|
1076 | lcd.string(1,3, " mold-ridden "); |
---|
1077 | lcd.string(1,4, " pop-tart! "); |
---|
1078 | */ |
---|
1079 | |
---|
1080 | return BLINK_ON; |
---|
1081 | } |
---|
1082 | |
---|
1083 | |
---|
1084 | ////////////////////////////////////////////////////////////////////////// |
---|
1085 | // This gets called upon program exit, to say "goodbye" |
---|
1086 | // |
---|
1087 | int goodbye_screen(int rep) |
---|
1088 | { |
---|
1089 | |
---|
1090 | lcd.clear(); |
---|
1091 | /* |
---|
1092 | lcd.string(1,1, "---===SHUTDOWN===---"); |
---|
1093 | lcd.string(1,2, " DANGER, WILL "); |
---|
1094 | lcd.string(1,3, " ROBINSON! "); |
---|
1095 | lcd.string(1,4, "---===EJECT!!!===---"); |
---|
1096 | usleep(250000); |
---|
1097 | */ |
---|
1098 | |
---|
1099 | lcd.string(1,1, " "); |
---|
1100 | lcd.string(1,2, " Thanks for using "); |
---|
1101 | lcd.string(1,3, " LCDproc and Linux! "); |
---|
1102 | lcd.string(1,4, " "); |
---|
1103 | |
---|
1104 | return 0; |
---|
1105 | } |
---|
1106 | |
---|
1107 | |
---|