asmon: Bump to version 0.72.
[dockapps.git] / asmon / asmon / asmon.c
blobae33e134783172c447358b357446aae840231723
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)
42 /* Evil globals I haven't removed yet */
43 long last_pageins=0, last_pageouts=0;
44 long last_swapins=0, last_swapouts=0;
45 //double old;
46 static int has_kern26 = 0;
48 #ifdef EXEC_ON_CLICK
49 char Command[256]="";
50 #endif
52 /* functions */
53 void DrawUptime(void);
54 void usage(void);
55 void printversion(void);
56 void asmon_routine(int Xpid, int allmem);
57 void DrawLite(int state, int dx, int dy);
58 void DrawCPU(void);
59 void DrawLoad(void);
60 #ifdef __solaris__
61 float DrawMemSwap(void);
62 extern int getLoad(float *);
63 extern int getSwap(unsigned long *, unsigned long *);
64 extern int getMem(unsigned long *, unsigned long *);
65 extern int getCPU(unsigned long *, unsigned long *,
66 unsigned long *, unsigned long *,
67 unsigned long *, unsigned long *,
68 unsigned long *, unsigned long *);
69 #else
70 void DrawXmem(int Xpid, float total);
71 float DrawMemSwap(float total, int allmem);
72 #endif
74 int main(int argc, char *argv[])
76 FILE *fp;
77 int i;
78 int allmem=1;
79 int Xpid=1;
80 char *ProgName;
81 struct utsname name;
82 int kernMajor, kernMinor, kernRev;
84 ProgName = argv[0];
86 if (strlen(ProgName) >= 5)
87 ProgName += (strlen(ProgName) - 5);
89 for (i=1; i<argc; i++) {
90 char *arg = argv[i];
91 if (*arg=='-') {
92 switch (arg[1]) {
93 case 'd' :
94 if (strcmp(arg+1, "display")) {
95 usage();
96 exit(1);
98 break;
99 #ifdef EXEC_ON_CLICK
100 case 'e' :
101 if ( argv[++i] ) {
102 strncpy( Command, argv[i], 253);
103 strcat( Command, " &");
104 } else {
105 usage();
106 exit(0);
108 break;
109 #endif
110 case 'v' :
111 printversion();
112 exit(0);
113 break;
114 case 'u' :
115 #ifdef __solaris__
116 fprintf(stderr, "X Server memory stats unavailable for Solaris.\n");
117 exit(0);
118 #endif
119 Xpid=0;
120 break;
121 default:
122 usage();
123 exit(0);
124 break;
128 #ifndef __solaris__
129 if ( Xpid != 0) {
130 if ( (fp = fopen("/var/run/server.0.pid", "r")) != NULL)
132 fscanf(fp, " %d", &Xpid);
133 fclose(fp);
134 } else {
135 if ( (fp = fopen("/tmp/.X0-lock", "r")) != NULL)
137 fscanf(fp, " %d", &Xpid);
138 fclose(fp);
139 } else {
140 Xpid=0;
144 #endif
145 /* Open 64x64 window */
146 openXwindow(argc, argv, asmon_master_xpm, asmon_mask_bits, asmon_mask_width, asmon_mask_height);
148 if( uname( &name ) != -1 )
150 if( strcmp( name.sysname, "Linux" ) == 0 )
152 sscanf(name.release, "%d.%d.%d", &kernMajor, &kernMinor,
153 &kernRev);
154 if(( kernMajor == 2 ) && ( kernMinor == 6 ))
155 has_kern26 = 1;
158 else
160 fprintf(stderr, "Can't find system name\n");
161 exit(1);
164 asmon_routine(Xpid, allmem);
165 return(0);
168 /**************************************************************************/
170 void usage(void) {
171 fprintf(stderr, "\nasmon %s - by Brad Hall (bkh@rio.vg)\n\t\toriginally based on Timecop's wmcpu\n\n", ASMON_VERSION);
172 fprintf(stderr, "The top bar: left is the CPU usage, right is the load average\n");
173 fprintf(stderr, "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");
174 fprintf(stderr, "The lower bar: the left swap usage and the number of megs swappedd avg\n");
175 fprintf(stderr, "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");
176 fprintf(stderr, "\t-display <display name>\n");
177 fprintf(stderr, "\t-h\tthis screen\n");
178 fprintf(stderr, "\t-v\tprint the version number\n");
179 #ifndef __solaris__
180 fprintf(stderr, "\t-u\tforce asmon to show uptime, rather than X mem use\n");
181 #endif
182 #ifdef EXEC_ON_CLICK
183 fprintf(stderr, "\t-e cmd\texecute 'cmd' on mouse click\n");
184 #endif
185 fprintf(stderr, "\n");
188 /**************************************************************************/
190 void printversion(void)
192 fprintf(stderr, "asmon %s\n", ASMON_VERSION);
195 /**************************************************************************/
197 void asmon_routine(int Xpid, int allmem)
199 int xpm_X=0, xpm_Y=0, count=0;
200 XEvent Event;
201 float total=0.0;
203 while(1)
205 DrawCPU();
206 DrawLoad();
208 /* Only run every 15 iterations */
209 if ( count == 0 || count == 15)
210 #ifdef __solaris__
211 total=DrawMemSwap();
212 #else
213 total=DrawMemSwap(total, allmem);
214 #endif
216 #ifdef __solaris__
217 DrawUptime();
218 #else
219 /* X mem or Uptime? */
220 if (Xpid == 0)
222 DrawUptime();
223 } else {
224 if (count == 5)
225 DrawXmem(Xpid, total);
227 #endif
229 /* Redraw Windows */
230 RedrawWindowXY(xpm_X, xpm_Y);
231 while (XPending(display))
233 XNextEvent(display, &Event);
234 switch (Event.type)
236 #ifdef EXEC_ON_CLICK
237 case ButtonPress:
238 #if 0
239 fprintf(stderr,"system(%s)\n",Command);
240 #endif
241 if (Command[ 0 ]) system(Command);
242 break;
243 #endif
244 case Expose:
245 RedrawWindowXY(xpm_X, xpm_Y);
246 break;
247 case DestroyNotify:
248 XCloseDisplay(display);
249 exit(0);
250 break;
253 count++;
254 if (count > 30)
255 count = 0;
256 usleep(150000);
261 /**************************************************************************/
263 #ifdef __solaris__
265 /* CPU Usage Meter */
266 void DrawCPU
268 void
271 unsigned long cpuIdle, cpuUser, cpuKern, cpuWait;
272 unsigned long pageIn, pageOut, swapIn, swapOut;
274 /* remember the statistics read last time */
275 static float cpustat[4] = {0.0, 0.0, 0.0, 0.0};
276 float fields[4] = {0.0, 0.0, 0.0, 0.0};
277 float cputotal = 0.0;
279 getCPU(&cpuIdle, &cpuUser, &cpuKern, &cpuWait,
280 &pageIn, &pageOut, &swapIn, &swapOut);
282 // Calculate CPU stuff
283 fields[0] = ((float)cpuIdle - cpustat[0]);
284 cpustat[0] = (float)cpuIdle;
285 cputotal += fields[0];
287 fields[1] = ((float)cpuUser - cpustat[1]);
288 cpustat[1] = (float)cpuUser;
289 cputotal += fields[1];
291 fields[2] = ((float)cpuKern - cpustat[2]);
292 cpustat[2] = (float)cpuKern;
293 cputotal += fields[2];
295 fields[3] = ((float)cpuWait - cpustat[3]);
296 cpustat[3] = (float)cpuWait;
297 cputotal += fields[3];
299 // CPU Bar
300 if(cputotal > 0)
302 cputotal = ((cputotal - (fields[0] + fields[2])) * 1.55);
303 if (cputotal > 26) cputotal = 26;
304 copyXPMArea(3, 84, cputotal, 9, 5, 5);
305 copyXPMArea(15, 105, (27 - cputotal), 9, (5 + cputotal), 5);
306 copyXPMArea(16, 46, 2, 14, 32, 2);
309 // Page In/Out
310 if (pageIn > last_pageins) DrawLite(B_RED, 5, 48);
311 else DrawLite(B_OFF, 5, 48);
313 if (pageOut > last_pageouts) DrawLite(B_RED, 10, 48);
314 else DrawLite(B_OFF, 10, 48);
316 last_pageins = pageIn;
317 last_pageouts = pageOut;
319 // Swap In/Out
320 if (swapIn > last_swapins) DrawLite(B_RED, 5, 53);
321 else DrawLite(B_OFF, 5, 53);
323 if (swapOut > last_swapouts) DrawLite(B_RED, 10, 53);
324 else DrawLite(B_OFF, 10, 53);
326 last_swapins = swapIn;
327 last_swapouts = swapOut;
330 #else
332 /* CPU Usage Meter */
333 void DrawCPU(void)
335 FILE *fp;
336 static double cpustat[7]; /* remember the statistics read last time */
337 //double fields[7], info[7], cputotal=0.0,idlee=0.0;
338 double fields[7], info[7], cputotal=0.0;
339 long pageins=0, pageouts=0, swapins=0, swapouts=0 ;
340 char buf[128];
341 int i;
343 if( (fp = fopen("/proc/stat", "r")) != NULL)
345 if( has_kern26 > 0 )
347 // CPU data
348 fscanf(fp, "cpu %lf %lf %lf %lf %lf %lf %lf", info, info+1,
349 info+2, info+3, info+4, info+5, info+6);
351 fclose(fp);
353 if( (fp = fopen("/proc/vmstat", "r")) != NULL)
355 // gather data for LED's
356 while( fgets(buf, 127, fp) )
358 if (strstr(buf, "pgpgin"))
359 sscanf(buf, "pgpgin %ld", &pageins);
361 if (strstr(buf, "pgpgout"))
362 sscanf(buf, "pgpgout %ld", &pageouts);
364 if (strstr(buf, "pswpin"))
365 sscanf(buf, "pswpin %ld", &swapins);
367 if (strstr(buf, "pswpout"))
368 sscanf(buf, "pswpout %ld", &swapouts);
370 fclose(fp);
372 } else {
373 // CPU data
374 fscanf(fp, "cpu %lf %lf %lf %lf", info, info+1, info+2,
375 info+3);
377 // gather data for LED's
378 while( fgets(buf, 127, fp) )
380 if (strstr(buf, "page"))
381 sscanf(buf, "page %ld %ld", &pageins, &pageouts);
383 if (strstr(buf, "swap"))
384 sscanf(buf, "swap %ld %ld", &swapins, &swapouts);
386 fclose(fp);
389 // Calculate CPU stuff
390 if( has_kern26 > 0 )
392 for(i = 0; i < 7; i++)
394 fields[i] = info[i] - cpustat[i];
395 cputotal += fields[i];
396 cpustat[i] = info[i];
398 } else {
399 for(i = 0; i < 4; i++)
401 fields[i] = info[i] - cpustat[i];
402 cputotal += fields[i];
403 cpustat[i] = info[i];
406 //idlee=info[3]-old;
408 //old=info[3];
410 // CPU Bar
412 //cputotal = 100 * l1 ;
413 //cputotal=(100-(idlee*100/16))*26/100;
414 if(cputotal > 0)
416 cputotal = (cputotal-(fields[3]+fields[4]))*1.55;
417 if ( cputotal > 26 ) cputotal = 26;
418 copyXPMArea(3,84,cputotal,9,5,5);
419 copyXPMArea(15,105,(27-cputotal),9,(5+cputotal),5);
420 copyXPMArea(16,46,2,14,32,2);
423 // Page In/Out
424 if (pageins > last_pageins)
426 DrawLite(B_RED, 5, 48);
427 } else {
428 DrawLite(B_OFF, 5, 48);
431 if (pageouts > last_pageouts)
433 DrawLite(B_RED, 10, 48);
434 } else {
435 DrawLite(B_OFF, 10, 48);
437 last_pageins = pageins;
438 last_pageouts = pageouts;
440 // Swap In/Out
441 if (swapins > last_swapins)
443 DrawLite(B_RED, 5, 53);
444 } else {
445 DrawLite(B_OFF, 5, 53);
448 if (swapouts > last_swapouts)
450 DrawLite(B_RED, 10, 53);
451 } else {
452 DrawLite(B_OFF, 10, 53);
454 last_swapins = swapins;
455 last_swapouts = swapouts;
459 #endif
461 /**************************************************************************/
463 /* Load Average */
464 void DrawLoad(void)
466 int tempy, tempa;
467 static float oldv = -1.0;
468 float ftmp;
470 #ifdef __solaris__
471 if (getLoad(&ftmp) != -1)
473 #else
474 FILE *fp;
475 if( (fp = fopen("/proc/loadavg", "r")) != NULL)
477 fscanf(fp, "%f", &ftmp);
478 fclose(fp);
479 #endif
480 if(oldv != ftmp)
482 oldv = ftmp;
483 tempa=(ftmp+0.005)*100;
484 tempy=tempa%10;
485 copyXPMArea(3+(tempy*6),66,6,9,50,5);
486 tempy=tempa/10;
487 tempy=tempy%10;
488 copyXPMArea(3+(tempy*6),66,6,9,44,5);
489 copyXPMArea(65,66,3,9,41,5);
490 tempy=tempa/100;
491 if ( tempy > 9 )
493 tempy=(tempy-10);
494 copyXPMArea(3+(tempy*6),95,6,9,34,5);
495 } else {
496 copyXPMArea(3+(tempy*6),66,6,9,34,5);
502 /**************************************************************************/
504 #ifdef __solaris__
506 /* Mem/Swap Meter */
507 float DrawMemSwap
509 void
512 unsigned long memMax, memFree, swapMax, swapFree;
513 unsigned long MEMmem, MEMswap;
514 float memUsed, swapUsed;
515 int tempy, tempa;
517 getMem(&memMax, &memFree);
518 memUsed = (float)(memMax - memFree);
520 getSwap(&swapMax, &swapFree);
521 swapUsed = (float)(swapMax - swapFree);
523 /* MEM Meter */
524 if (memMax == 0)
525 MEMmem = 0;
526 else
528 if (((float)memMax / 1048576) >= 1)
529 MEMmem = ((memUsed * 31) / (float)memMax);
530 else
531 MEMmem = ((memUsed * 36) / (float)memMax);
534 // refresh
535 copyXPMArea(4, 115, 55, 11, 4, 18);
537 // Bar
538 copyXPMArea(3, 75, MEMmem, 9, 5, 19);
539 copyXPMArea(15, 105, (36 - MEMmem), 9, (5 + MEMmem), 19);
540 // Numbers
541 tempa = (memUsed / 1048576);
542 tempy = (tempa % 10);
543 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 50, 19);
544 tempy = ((tempa / 10) % 10);
545 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 44, 19);
546 tempy = ((tempa / 100) % 10);
547 if (tempy != 0)
549 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 38, 19);
550 copyXPMArea(16, 46, 2, 14, 35, 16);
552 else
554 copyXPMArea(16, 46, 2, 14, 41, 16);
557 // refresh
558 copyXPMArea(4, 115, 55, 11, 4, 32);
560 /* SWAP Meter */
561 if (swapMax == 0)
562 MEMswap = 0;
563 else
565 if (((float)swapMax / 1048576) >= 1)
566 MEMswap = ((swapUsed * 31) / (float)swapMax);
567 else
568 MEMswap = ((swapUsed * 36) / (float)swapMax);
570 // Bar
571 copyXPMArea(3, 75, MEMswap, 9, 5, 33);
572 copyXPMArea(15, 105, (36 - MEMswap), 9, (5 + MEMswap), 33);
573 // Numbers
574 tempa = (swapUsed / 1048576);
575 tempy = (tempa % 10);
576 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 50, 33);
577 tempy = ((tempa / 10) % 10);
578 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 44, 33);
579 tempy = ((tempa / 100) % 10);
580 if (tempy != 0)
582 copyXPMArea((3 + (tempy * 6)), 66, 6, 9, 38, 33);
583 copyXPMArea(16, 46, 2, 14, 42, 16);
585 else
587 copyXPMArea(16, 46, 2, 14, 41, 30);
590 return (float)memMax;
593 #else
595 /* Mem/Swap Meter */
596 float DrawMemSwap(float total, int allmem)
598 FILE *fp;
599 if( (fp = fopen("/proc/meminfo", "r")) != NULL)
601 static float stotal=0.0, sshared=0.0, sbuffers=0.0, scached=0.0;
602 char junk[128];
603 float used, freeM, shared, buffers, cached, swaptotal,
604 swapused, swapfreeM;
605 unsigned long MEMshar,MEMbuff, MEMswap;
606 int tempy, tempa;
608 if( has_kern26 > 0 )
610 float scratch;
612 while(!feof(fp))
614 fgets(junk, 120, fp);
615 if (strstr(junk, "MemTotal"))
617 sscanf(junk, "MemTotal: %f kB", &scratch);
618 total = scratch * 1024;
620 if (strstr(junk, "MemFree"))
622 sscanf(junk, "MemFree: %f kB", &scratch);
623 freeM = scratch * 1024;
624 used = total - freeM;
626 if (strstr(junk, "Buffers"))
628 sscanf(junk, "Buffers: %f kB", &scratch);
629 buffers = scratch * 1024;
631 if (strstr(junk, "Cached"))
633 sscanf(junk, "Cached: %f kB", &scratch);
634 cached = scratch * 1024;
636 if (strstr(junk, "SwapTotal"))
638 sscanf(junk, "SwapTotal: %f kB", &scratch);
639 swaptotal = scratch * 1024;
641 if (strstr(junk, "SwapFree"))
643 sscanf(junk, "SwapFree: %f kB", &scratch);
644 swapfreeM = scratch * 1024;
645 swapused = swaptotal - swapfreeM;
648 } else {
649 fgets(junk, 80, fp);
650 fscanf(fp, "Mem: %f %f %f %f %f %f\nSwap: %f %f %f", &total,
651 &used, &freeM, &shared, &buffers, &cached,
652 &swaptotal, &swapused, &swapfreeM);
654 fclose(fp);
656 /* All mem areas */
657 if(stotal != total || sshared != shared || sbuffers != buffers || scached != cached)
659 stotal = total; sshared = shared; sbuffers = buffers; scached = cached;
660 if ( (total/101048576) >= 1)
662 MEMshar=((used-buffers-cached)/total)*27;
663 MEMbuff=(buffers/total)*27;
664 } else {
665 MEMshar=((used-buffers-cached)/total)*33;
666 MEMbuff=(buffers/total)*33;
668 // refresh
669 copyXPMArea(4, 115, 55, 11, 4, 18);
670 // Bar
671 if ( (total/101048576) >= 1)
673 copyXPMArea(3,75,((used/total)*28),9,5,19);
674 } else {
675 copyXPMArea(3,75,((used/total)*34),9,5,19);
677 // Separators
678 copyXPMArea(15,105,1,9,5+MEMshar,19);
679 copyXPMArea(15,105,1,9,7+MEMshar+MEMbuff,19);
680 copyXPMArea(15,105,(36-(used/total)*34),9,(5+(used/total)*34),19);
681 // Numbers
682 tempa=used/1048576;
683 tempy=tempa%10;
684 copyXPMArea(3+(tempy*6),66,6,9,50,19);
685 tempy=(tempa/10)%10;
686 copyXPMArea(3+(tempy*6),66,6,9,44,19);
687 tempy=(tempa/100)%10;
688 if ( (total/101048576) >= 1) {
689 copyXPMArea(3+(tempy*6),66,6,9,38,19);
690 copyXPMArea(16,46,2,14,35,16);
691 } else {
692 copyXPMArea(16,46,2,14,41,16);
695 /* SWAP Meter */
696 if ( swaptotal == 0 ) MEMswap = 0;
697 else {
698 if ( (total/101048576) >= 1)
699 MEMswap=(swapused*31)/swaptotal;
700 else MEMswap=(swapused*36)/swaptotal;
702 // refresh
703 copyXPMArea(4, 115, 55, 11, 4, 32);
704 // Bar
705 copyXPMArea(3,75,MEMswap,9,5,33);
706 copyXPMArea(15,105,(36-(MEMswap)),9,5+MEMswap,33);
707 // Numbers
708 tempa=swapused/1048576;
709 tempy=tempa%10;
710 copyXPMArea(3+(tempy*6),66,6,9,50,33);
711 tempy=(tempa/10)%10;
712 copyXPMArea(3+(tempy*6),66,6,9,44,33);
713 tempy=tempa/100;
714 if ( tempy != 0 ) {
715 copyXPMArea(3+(tempy*6),66,6,9,38,33);
716 copyXPMArea(16,46,2,14,35,30);
717 } else {
718 copyXPMArea(16,46,2,14,41,30);
721 return(total);
724 #endif
726 /**************************************************************************/
728 #ifndef __solaris__
730 /* X Mem Usage */
731 void DrawXmem(int Xpid, float total)
733 FILE *fp;
734 char buf[128], XFileName[256];
735 float ratio;
736 long old_Xsize=-1, Xsize=0;
738 sprintf(XFileName, "/proc/%d/status", Xpid);
740 if ((fp = fopen(XFileName, "r")) != NULL)
742 while( fgets(buf, 127, fp) )
744 if (strstr(buf, "VmSize"))
745 sscanf(buf, "VmSize: %ld", &Xsize);
747 if(old_Xsize!=Xsize)
749 int tempy, tempa, tempb;
750 old_Xsize=Xsize;
751 ratio=Xsize/(total/1024);
752 if ( Xsize > (total/1024) ) Xsize=total/1024;
753 Xsize=Xsize/1024;
754 tempy=Xsize%10;
755 copyXPMArea(3+(tempy*6),66,6,9,50,48);
756 tempa=Xsize/10;
757 tempy=tempa%10;
758 tempb=Xsize/100;
759 if ( Xsize > 100 )
761 copyXPMArea(3,84,((ratio)*17),11,18,47);
762 copyXPMArea(15,105,(23-((ratio)*17)),11,(18+(ratio*22)),47);
763 copyXPMArea(3+(tempy*6),66,6,9,44,48);
764 copyXPMArea(3+(tempb*6),66,6,9,38,48);
765 copyXPMArea(16,46,2,14,36,46);
766 } else {
767 copyXPMArea(3,84,((ratio)*22),11,18,47);
768 copyXPMArea(15,105,(23-((ratio)*22)),11,(18+(ratio*22)),47);
769 copyXPMArea(3+(tempy*6),66,6,9,44,48);
770 copyXPMArea(16,46,2,14,41,46);
773 fclose(fp);
777 #endif
779 /**************************************************************************/
781 /* Uptime */
782 void DrawUptime(void)
784 int upt, days=0,hours=0,mins=0, old_mins=-1,old_hours=-1;
786 #ifdef __solaris__
787 struct utmp * pUtmp;
788 struct utmp idUtmp;
789 idUtmp.ut_type = BOOT_TIME;
790 setutent();
791 pUtmp = getutid(&idUtmp);
792 upt = (time(0) - pUtmp->ut_time);
793 #else
794 FILE *fp;
795 if( (fp = fopen("/proc/uptime", "r")) != NULL)
796 fscanf(fp, "%d",&upt);
797 fclose(fp);
798 #endif
799 mins=(upt/60)%60;
800 hours=(upt/3600)%24;
801 days=(upt/86400);
802 if(old_hours!=hours)
803 old_hours=hours;
804 if(old_mins!=mins)
806 int tempy;
807 old_mins=mins;
808 if ( days > 9 )
810 copyXPMArea(20,105,36,9,18,48);
811 tempy=hours%10;
812 copyXPMArea(3+(tempy*6),66,6,9,50,48);
813 tempy=hours/10;
814 copyXPMArea(3+(tempy*6),66,6,9,44,48);
815 copyXPMArea(63,66,3,9,41,48);
816 tempy=days%10;
817 copyXPMArea(3+(tempy*6),66,6,9,34,48);
818 tempy=(days/10)%10;
819 copyXPMArea(3+(tempy*6),66,6,9,28,48);
820 tempy=days/100;
821 copyXPMArea(3+(tempy*6),66,6,9,22,48);
822 } else {
823 tempy=mins%10;
824 copyXPMArea(3+(tempy*6),66,6,9,50,48);
825 tempy=mins/10;
826 copyXPMArea(3+(tempy*6),66,6,9,44,48);
827 copyXPMArea(63,66,3,9,41,48);
828 tempy=hours%10;
829 copyXPMArea(3+(tempy*6),66,6,9,34,48);
830 tempy=hours/10;
831 copyXPMArea(3+(tempy*6),66,6,9,28,48);
832 copyXPMArea(63,66,3,9,25,48);
833 tempy=days%10;
834 copyXPMArea(3+(tempy*6),66,6,9,18,48);
840 /**************************************************************************/
842 /* Drawing LED's */
843 void DrawLite(int state, int dx, int dy)
845 switch(state)
847 case B_RED:
848 copyXPMArea(BREDX, BREDY, LITEW, LITEH, dx, dy);
849 break;
850 case B_GREEN:
851 copyXPMArea(BGREENX, BGREENY, LITEW, LITEH, dx, dy);
852 break;
853 default:
854 case B_OFF:
855 copyXPMArea(BOFFX, BOFFY, LITEW, LITEH, dx, dy);
856 break;
861 /* EOF */