Make AddMouseRegion's index unsigned
[dockapps.git] / asmon / asmon / asmon.c
blob59a1aef16228abbe8015224907581fcaa1e01b50
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <unistd.h>
5 #include <sys/utsname.h>
7 #include <X11/X.h>
8 #include <X11/Xlib.h>
10 #include <libdockapp/wmgeneral.h>
12 #include "asmon-master.xpm"
13 #include "asmon-mask.xbm"
15 #ifdef __solaris__
16 #include <utmp.h>
17 #endif
19 #define EXEC_ON_CLICK 1
20 #define ASMON_VERSION "0.72"
21 #define CHAR_WIDTH 5
22 #define CHAR_HEIGHT 7
24 #define BCHAR_WIDTH 6
25 #define BCHAR_HEIGHT 9
27 #define BOFFX (9)
28 #define BOFFY (111)
29 #define BREDX (3)
30 #define BREDY (111)
31 #define BGREENX (87)
32 #define BGREENY (66)
34 #define LITEW (4)
35 #define LITEH (4)
37 #define B_OFF (0)
38 #define B_RED (1)
39 #define B_GREEN (2)
41 /* Evil globals I haven't removed yet */
42 long last_pageins = 0, last_pageouts = 0;
43 long last_swapins = 0, last_swapouts = 0;
45 #ifdef EXEC_ON_CLICK
46 char Command[256] = "";
47 #endif
49 /* functions */
50 void DrawUptime(void);
51 void usage(void);
52 void printversion(void);
53 void asmon_routine(int Xpid, int allmem);
54 void DrawLite(int state, int dx, int dy);
55 void DrawCPU(void);
56 void DrawLoad(void);
57 #ifdef __solaris__
58 float DrawMemSwap(void);
59 extern int getLoad(float *);
60 extern int getSwap(unsigned long *, unsigned long *);
61 extern int getMem(unsigned long *, unsigned long *);
62 extern int getCPU(unsigned long *, unsigned long *,
63 unsigned long *, unsigned long *,
64 unsigned long *, unsigned long *,
65 unsigned long *, unsigned long *);
66 #else
67 void DrawXmem(int Xpid, float total);
68 float DrawMemSwap(float total, int allmem);
69 #endif
71 int main(int argc, char *argv[])
73 FILE *fp;
74 int i;
75 int allmem = 1;
76 int Xpid = 1;
77 char *ProgName;
78 ProgName = argv[0];
80 if (strlen(ProgName) >= 5)
81 ProgName += (strlen(ProgName) - 5);
83 for (i = 1; i < argc; i++) {
84 char *arg = argv[i];
85 if (*arg == '-') {
86 switch (arg[1]) {
87 case 'd':
88 if (strcmp(arg + 1, "display")) {
89 usage();
90 exit(1);
92 break;
93 #ifdef EXEC_ON_CLICK
94 case 'e':
95 if (argv[++i]) {
96 strncpy(Command, argv[i], 253);
97 strcat(Command, " &");
98 } else {
99 usage();
100 exit(0);
102 break;
103 #endif
104 case 'v':
105 printversion();
106 exit(0);
107 break;
108 case 'u':
109 #ifdef __solaris__
110 fprintf(stderr,
111 "X Server memory stats unavailable for Solaris.\n");
112 exit(0);
113 #endif
114 Xpid = 0;
115 break;
116 default:
117 usage();
118 exit(0);
119 break;
123 #ifndef __solaris__
124 if (Xpid != 0) {
125 if ((fp = fopen("/var/run/server.0.pid", "r")) != NULL) {
126 fscanf(fp, " %d", &Xpid);
127 fclose(fp);
128 } else {
129 if ((fp = fopen("/tmp/.X0-lock", "r")) != NULL) {
130 fscanf(fp, " %d", &Xpid);
131 fclose(fp);
132 } else {
133 Xpid = 0;
137 #endif
138 /* Open 64x64 window */
139 openXwindow(argc, argv, asmon_master_xpm, asmon_mask_bits,
140 asmon_mask_width, asmon_mask_height);
142 asmon_routine(Xpid, allmem);
143 return (0);
146 /**************************************************************************/
148 void usage(void)
150 fprintf(stderr,
151 "\nasmon %s - by Brad Hall (bkh@rio.vg)\n\t\toriginally based on Timecop's wmcpu\n\n",
152 ASMON_VERSION);
153 fprintf(stderr,
154 "The top bar: left is the CPU usage, right is the load average\n");
155 fprintf(stderr,
156 "The middle bar: left memory usage devided by ticks into shared, buffers, and\n\t\t cached, respectively, and the number of megs used\n");
157 fprintf(stderr,
158 "The lower bar: the left swap usage and the number of megs swappedd avg\n");
159 fprintf(stderr,
160 "The bottom: the left is a set of LED's marking page's and swap's, the right is\n\t\t a bar representing the amount of memory that the X server \n\t\t is taking up, and the exact megs\n\n usage:\n");
161 fprintf(stderr, "\t-display <display name>\n");
162 fprintf(stderr, "\t-h\tthis screen\n");
163 fprintf(stderr, "\t-v\tprint the version number\n");
164 #ifndef __solaris__
165 fprintf(stderr,
166 "\t-u\tforce asmon to show uptime, rather than X mem use\n");
167 #endif
168 #ifdef EXEC_ON_CLICK
169 fprintf(stderr, "\t-e cmd\texecute 'cmd' on mouse click\n");
170 #endif
171 fprintf(stderr, "\n");
174 /**************************************************************************/
176 void printversion(void)
178 fprintf(stderr, "asmon %s\n", ASMON_VERSION);
181 /**************************************************************************/
183 void asmon_routine(int Xpid, int allmem)
185 int xpm_X = 0, xpm_Y = 0, count = 0;
186 XEvent Event;
187 float total = 0.0;
189 while (1) {
190 DrawCPU();
191 DrawLoad();
193 /* Only run every 15 iterations */
194 if (count == 0 || count == 15)
195 #ifdef __solaris__
196 total = DrawMemSwap();
197 #else
198 total = DrawMemSwap(total, allmem);
199 #endif
201 #ifdef __solaris__
202 DrawUptime();
203 #else
204 /* X mem or Uptime? */
205 if (Xpid == 0) {
206 DrawUptime();
207 } else {
208 if (count == 5)
209 DrawXmem(Xpid, total);
211 #endif
213 /* Redraw Windows */
214 RedrawWindowXY(xpm_X, xpm_Y);
215 while (XPending(display)) {
216 XNextEvent(display, &Event);
217 switch (Event.type) {
218 #ifdef EXEC_ON_CLICK
219 case ButtonPress:
220 #if 0
221 fprintf(stderr, "system(%s)\n", Command);
222 #endif
223 if (Command[0])
224 system(Command);
225 break;
226 #endif
227 case Expose:
228 RedrawWindowXY(xpm_X, xpm_Y);
229 break;
230 case DestroyNotify:
231 XCloseDisplay(display);
232 exit(0);
233 break;
236 count++;
237 if (count > 30)
238 count = 0;
239 usleep(150000);
243 /**************************************************************************/
245 #ifdef __solaris__
247 /* CPU Usage Meter */
248 void DrawCPU(void
250 unsigned long cpuIdle, cpuUser, cpuKern, cpuWait;
251 unsigned long pageIn, pageOut, swapIn, swapOut;
253 /* remember the statistics read last time */
254 static float cpustat[4] = { 0.0, 0.0, 0.0, 0.0 };
255 float fields[4] = { 0.0, 0.0, 0.0, 0.0 };
256 float cputotal = 0.0;
258 getCPU(&cpuIdle, &cpuUser, &cpuKern, &cpuWait,
259 &pageIn, &pageOut, &swapIn, &swapOut);
261 // Calculate CPU stuff
262 fields[0] = ((float)cpuIdle - cpustat[0]);
263 cpustat[0] = (float)cpuIdle;
264 cputotal += fields[0];
266 fields[1] = ((float)cpuUser - cpustat[1]);
267 cpustat[1] = (float)cpuUser;
268 cputotal += fields[1];
270 fields[2] = ((float)cpuKern - cpustat[2]);
271 cpustat[2] = (float)cpuKern;
272 cputotal += fields[2];
274 fields[3] = ((float)cpuWait - cpustat[3]);
275 cpustat[3] = (float)cpuWait;
276 cputotal += fields[3];
278 // CPU Bar
279 if (cputotal > 0) {
280 cputotal = ((cputotal - (fields[0] + fields[2])) * 1.55);
281 if (cputotal > 26)
282 cputotal = 26;
283 copyXPMArea(3, 84, cputotal, 9, 5, 5);
284 copyXPMArea(15, 105, (27 - cputotal), 9, (5 + cputotal), 5);
285 copyXPMArea(16, 46, 2, 14, 32, 2);
287 // Page In/Out
288 if (pageIn > last_pageins)
289 DrawLite(B_RED, 5, 48);
290 else
291 DrawLite(B_OFF, 5, 48);
293 if (pageOut > last_pageouts)
294 DrawLite(B_RED, 10, 48);
295 else
296 DrawLite(B_OFF, 10, 48);
298 last_pageins = pageIn;
299 last_pageouts = pageOut;
301 // Swap In/Out
302 if (swapIn > last_swapins)
303 DrawLite(B_RED, 5, 53);
304 else
305 DrawLite(B_OFF, 5, 53);
307 if (swapOut > last_swapouts)
308 DrawLite(B_RED, 10, 53);
309 else
310 DrawLite(B_OFF, 10, 53);
312 last_swapins = swapIn;
313 last_swapouts = swapOut;
316 #else
318 /* CPU Usage Meter */
319 void DrawCPU(void)
321 FILE *fp;
322 static double cpustat[7]; /* remember the statistics read last time */
323 //double fields[7], info[7], cputotal=0.0,idlee=0.0;
324 double fields[7], info[7], cputotal = 0.0;
325 long pageins = 0, pageouts = 0, swapins = 0, swapouts = 0;
326 char buf[128];
327 int i;
329 if ((fp = fopen("/proc/stat", "r")) != NULL) {
330 // CPU data
331 fscanf(fp, "cpu %lf %lf %lf %lf %lf %lf %lf", info,
332 info + 1, info + 2, info + 3, info + 4, info + 5,
333 info + 6);
335 fclose(fp);
337 if ((fp = fopen("/proc/vmstat", "r")) != NULL) {
338 // gather data for LED's
339 while (fgets(buf, 127, fp)) {
340 if (strstr(buf, "pgpgin"))
341 sscanf(buf, "pgpgin %ld",
342 &pageins);
344 if (strstr(buf, "pgpgout"))
345 sscanf(buf, "pgpgout %ld",
346 &pageouts);
348 if (strstr(buf, "pswpin"))
349 sscanf(buf, "pswpin %ld",
350 &swapins);
352 if (strstr(buf, "pswpout"))
353 sscanf(buf, "pswpout %ld",
354 &swapouts);
356 fclose(fp);
360 // Calculate CPU stuff
361 for (i = 0; i < 7; i++) {
362 fields[i] = info[i] - cpustat[i];
363 cputotal += fields[i];
364 cpustat[i] = info[i];
367 //idlee=info[3]-old;
368 //old=info[3];
370 //cputotal = 100 * l1 ;
371 //cputotal=(100-(idlee*100/16))*26/100;
372 if (cputotal > 0) {
373 cputotal = (cputotal - (fields[3] + fields[4])) * 1.55;
374 if (cputotal > 26)
375 cputotal = 26;
376 copyXPMArea(3, 84, cputotal, 9, 5, 5);
377 copyXPMArea(15, 105, (27 - cputotal), 9, (5 + cputotal),
379 copyXPMArea(16, 46, 2, 14, 32, 2);
381 // Page In/Out
382 if (pageins > last_pageins) {
383 DrawLite(B_RED, 5, 48);
384 } else {
385 DrawLite(B_OFF, 5, 48);
388 if (pageouts > last_pageouts) {
389 DrawLite(B_RED, 10, 48);
390 } else {
391 DrawLite(B_OFF, 10, 48);
393 last_pageins = pageins;
394 last_pageouts = pageouts;
396 // Swap In/Out
397 if (swapins > last_swapins) {
398 DrawLite(B_RED, 5, 53);
399 } else {
400 DrawLite(B_OFF, 5, 53);
403 if (swapouts > last_swapouts) {
404 DrawLite(B_RED, 10, 53);
405 } else {
406 DrawLite(B_OFF, 10, 53);
408 last_swapins = swapins;
409 last_swapouts = swapouts;
413 #endif
415 /**************************************************************************/
417 /* Load Average */
418 void DrawLoad(void)
420 int tempy, tempa;
421 static float oldv = -1.0;
422 float ftmp;
424 #ifdef __solaris__
425 if (getLoad(&ftmp) != -1) {
426 #else
427 FILE *fp;
428 if ((fp = fopen("/proc/loadavg", "r")) != NULL) {
429 fscanf(fp, "%f", &ftmp);
430 fclose(fp);
431 #endif
432 if (oldv != ftmp) {
433 oldv = ftmp;
434 tempa = (ftmp + 0.005) * 100;
435 tempy = tempa % 10;
436 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 5);
437 tempy = tempa / 10;
438 tempy = tempy % 10;
439 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 5);
440 copyXPMArea(65, 66, 3, 9, 41, 5);
441 tempy = tempa / 100;
442 if (tempy > 9) {
443 tempy = (tempy - 10);
444 copyXPMArea(3 + (tempy * 6), 95, 6, 9, 34, 5);
445 } else {
446 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 34, 5);
452 /**************************************************************************/
454 #ifdef __solaris__
456 /* Mem/Swap Meter */
457 float DrawMemSwap(void
459 unsigned long memMax, memFree, swapMax, swapFree;
460 unsigned long MEMmem, MEMswap;
461 float memUsed, swapUsed;
462 int tempy, tempa;
464 getMem(&memMax, &memFree);
465 memUsed = (float)(memMax - memFree);
467 getSwap(&swapMax, &swapFree);
468 swapUsed = (float)(swapMax - swapFree);
470 /* MEM Meter */
471 if (memMax == 0)
472 MEMmem = 0;
473 else {
474 if (((float)memMax / 1048576) >= 1)
475 MEMmem = ((memUsed * 31) / (float)memMax);
476 else
477 MEMmem = ((memUsed * 36) / (float)memMax);
480 // refresh
481 copyXPMArea(4, 115, 55, 11, 4, 18);
483 // Bar
484 copyXPMArea(3, 75, MEMmem, 9, 5, 19);
485 copyXPMArea(15, 105, (36 - MEMmem), 9, (5 + MEMmem), 19);
486 // Numbers
487 tempa = (memUsed / 1048576);
488 tempy = (tempa % 10);
489 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 50, 19);
490 tempy = ((tempa / 10) % 10);
491 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 44, 19);
492 tempy = ((tempa / 100) % 10);
493 if (tempy != 0) {
494 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 38, 19);
495 copyXPMArea(16, 46, 2, 14, 35, 16);
496 } else {
497 copyXPMArea(16, 46, 2, 14, 41, 16);
500 // refresh
501 copyXPMArea(4, 115, 55, 11, 4, 32);
503 /* SWAP Meter */
504 if (swapMax == 0)
505 MEMswap = 0;
506 else {
507 if (((float)swapMax / 1048576) >= 1)
508 MEMswap = ((swapUsed * 31) / (float)swapMax);
509 else
510 MEMswap = ((swapUsed * 36) / (float)swapMax);
512 // Bar
513 copyXPMArea(3, 75, MEMswap, 9, 5, 33);
514 copyXPMArea(15, 105, (36 - MEMswap), 9, (5 + MEMswap), 33);
515 // Numbers
516 tempa = (swapUsed / 1048576);
517 tempy = (tempa % 10);
518 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 50, 33);
519 tempy = ((tempa / 10) % 10);
520 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 44, 33);
521 tempy = ((tempa / 100) % 10);
522 if (tempy != 0) {
523 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 38, 33);
524 copyXPMArea(16, 46, 2, 14, 42, 16);
525 } else {
526 copyXPMArea(16, 46, 2, 14, 41, 30);
529 return (float)memMax;
532 #else
534 /* Mem/Swap Meter */
535 float DrawMemSwap(float total, int allmem)
537 FILE *fp;
538 if ((fp = fopen("/proc/meminfo", "r")) != NULL) {
539 char junk[128];
540 float used, freeM, buffers, cached, swaptotal,
541 swapused, swapfreeM;
542 unsigned long MEMshar, MEMbuff, MEMswap;
543 int tempy, tempa;
545 float scratch;
546 while (!feof(fp)) {
547 fgets(junk, 120, fp);
548 if (strstr(junk, "MemTotal")) {
549 sscanf(junk, "MemTotal: %f kB",
550 &scratch);
551 total = scratch * 1024;
553 if (strstr(junk, "MemFree")) {
554 sscanf(junk, "MemFree: %f kB",
555 &scratch);
556 freeM = scratch * 1024;
557 used = total - freeM;
559 if (strstr(junk, "Buffers")) {
560 sscanf(junk, "Buffers: %f kB",
561 &scratch);
562 buffers = scratch * 1024;
564 if (strstr(junk, "Cached")) {
565 sscanf(junk, "Cached: %f kB", &scratch);
566 cached = scratch * 1024;
568 if (strstr(junk, "SwapTotal")) {
569 sscanf(junk, "SwapTotal: %f kB",
570 &scratch);
571 swaptotal = scratch * 1024;
573 if (strstr(junk, "SwapFree")) {
574 sscanf(junk, "SwapFree: %f kB",
575 &scratch);
576 swapfreeM = scratch * 1024;
577 swapused = swaptotal - swapfreeM;
581 fclose(fp);
583 /* All mem areas */
584 if ((total / 101048576) >= 1) {
585 MEMshar =
586 ((used - buffers - cached) / total) * 27;
587 MEMbuff = (buffers / total) * 27;
588 } else {
589 MEMshar =
590 ((used - buffers - cached) / total) * 33;
591 MEMbuff = (buffers / total) * 33;
593 // refresh
594 copyXPMArea(4, 115, 55, 11, 4, 18);
595 // Bar
596 if ((total / 101048576) >= 1) {
597 copyXPMArea(3, 75, ((used / total) * 28), 9, 5,
598 19);
599 } else {
600 copyXPMArea(3, 75, ((used / total) * 34), 9, 5,
601 19);
603 // Separators
604 copyXPMArea(15, 105, 1, 9, 5 + MEMshar, 19);
605 copyXPMArea(15, 105, 1, 9, 7 + MEMshar + MEMbuff, 19);
606 copyXPMArea(15, 105, (36 - (used / total) * 34), 9,
607 (5 + (used / total) * 34), 19);
608 // Numbers
609 tempa = used / 1048576;
610 tempy = tempa % 10;
611 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 19);
612 tempy = (tempa / 10) % 10;
613 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 19);
614 tempy = (tempa / 100) % 10;
615 if ((total / 101048576) >= 1) {
616 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 38, 19);
617 copyXPMArea(16, 46, 2, 14, 35, 16);
618 } else {
619 copyXPMArea(16, 46, 2, 14, 41, 16);
622 /* SWAP Meter */
623 if (swaptotal == 0)
624 MEMswap = 0;
625 else {
626 if ((total / 101048576) >= 1)
627 MEMswap = (swapused * 31) / swaptotal;
628 else
629 MEMswap = (swapused * 36) / swaptotal;
631 // refresh
632 copyXPMArea(4, 115, 55, 11, 4, 32);
633 // Bar
634 copyXPMArea(3, 75, MEMswap, 9, 5, 33);
635 copyXPMArea(15, 105, (36 - (MEMswap)), 9, 5 + MEMswap, 33);
636 // Numbers
637 tempa = swapused / 1048576;
638 tempy = tempa % 10;
639 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 33);
640 tempy = (tempa / 10) % 10;
641 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 33);
642 tempy = tempa / 100;
643 if (tempy != 0) {
644 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 38, 33);
645 copyXPMArea(16, 46, 2, 14, 35, 30);
646 } else {
647 copyXPMArea(16, 46, 2, 14, 41, 30);
651 return (total);
654 #endif
656 /**************************************************************************/
658 #ifndef __solaris__
660 /* X Mem Usage */
661 void DrawXmem(int Xpid, float total)
663 FILE *fp;
664 char buf[128], XFileName[256];
665 float ratio;
666 long old_Xsize = -1, Xsize = 0;
668 sprintf(XFileName, "/proc/%d/status", Xpid);
670 if ((fp = fopen(XFileName, "r")) != NULL) {
671 while (fgets(buf, 127, fp)) {
672 if (strstr(buf, "VmSize"))
673 sscanf(buf, "VmSize: %ld", &Xsize);
675 if (old_Xsize != Xsize) {
676 int tempy, tempa, tempb;
677 old_Xsize = Xsize;
678 ratio = Xsize / (total / 1024);
679 if (Xsize > (total / 1024))
680 Xsize = total / 1024;
681 Xsize = Xsize / 1024;
682 tempy = Xsize % 10;
683 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 48);
684 tempa = Xsize / 10;
685 tempy = tempa % 10;
686 tempb = Xsize / 100;
687 if (Xsize > 100) {
688 copyXPMArea(3, 84, ((ratio) * 17), 11, 18, 47);
689 copyXPMArea(15, 105, (23 - ((ratio) * 17)), 11,
690 (18 + (ratio * 22)), 47);
691 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 48);
692 copyXPMArea(3 + (tempb * 6), 66, 6, 9, 38, 48);
693 copyXPMArea(16, 46, 2, 14, 36, 46);
694 } else {
695 copyXPMArea(3, 84, ((ratio) * 22), 11, 18, 47);
696 copyXPMArea(15, 105, (23 - ((ratio) * 22)), 11,
697 (18 + (ratio * 22)), 47);
698 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 48);
699 copyXPMArea(16, 46, 2, 14, 41, 46);
702 fclose(fp);
706 #endif
708 /**************************************************************************/
710 /* Uptime */
711 void DrawUptime(void)
713 int upt, days = 0, hours = 0, mins = 0, old_mins = -1, old_hours = -1;
715 #ifdef __solaris__
716 struct utmp *pUtmp;
717 struct utmp idUtmp;
718 idUtmp.ut_type = BOOT_TIME;
719 setutent();
720 pUtmp = getutid(&idUtmp);
721 upt = (time(0) - pUtmp->ut_time);
722 #else
723 FILE *fp;
724 if ((fp = fopen("/proc/uptime", "r")) != NULL)
725 fscanf(fp, "%d", &upt);
726 fclose(fp);
727 #endif
728 mins = (upt / 60) % 60;
729 hours = (upt / 3600) % 24;
730 days = (upt / 86400);
731 if (old_hours != hours)
732 old_hours = hours;
733 if (old_mins != mins) {
734 int tempy;
735 old_mins = mins;
736 if (days > 9) {
737 copyXPMArea(20, 105, 36, 9, 18, 48);
738 tempy = hours % 10;
739 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 48);
740 tempy = hours / 10;
741 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 48);
742 copyXPMArea(63, 66, 3, 9, 41, 48);
743 tempy = days % 10;
744 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 34, 48);
745 tempy = (days / 10) % 10;
746 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 28, 48);
747 tempy = days / 100;
748 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 22, 48);
749 } else {
750 tempy = mins % 10;
751 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 50, 48);
752 tempy = mins / 10;
753 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 44, 48);
754 copyXPMArea(63, 66, 3, 9, 41, 48);
755 tempy = hours % 10;
756 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 34, 48);
757 tempy = hours / 10;
758 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 28, 48);
759 copyXPMArea(63, 66, 3, 9, 25, 48);
760 tempy = days % 10;
761 copyXPMArea(3 + (tempy * 6), 66, 6, 9, 18, 48);
767 /**************************************************************************/
769 /* Drawing LED's */
770 void DrawLite(int state, int dx, int dy)
772 switch (state) {
773 case B_RED:
774 copyXPMArea(BREDX, BREDY, LITEW, LITEH, dx, dy);
775 break;
776 case B_GREEN:
777 copyXPMArea(BGREENX, BGREENY, LITEW, LITEH, dx, dy);
778 break;
779 default:
780 case B_OFF:
781 copyXPMArea(BOFFX, BOFFY, LITEW, LITEH, dx, dy);
782 break;
787 /* EOF */