Added some hexadecimal display capabilities to aclox ascii clock
authorHarvie <tomas@mudrunka.cz>
Fri, 23 Sep 2011 19:52:59 +0000 (21:52 +0200)
committerHarvie <tomas@mudrunka.cz>
Fri, 23 Sep 2011 19:52:59 +0000 (21:52 +0200)
c/aclox.c

index 5d6f9399c7d73a782311c25cb99214f07b988b0d..8525626f95b6072b541c3b5b0f47cb9b781534f4 100755 (executable)
--- a/c/aclox.c
+++ b/c/aclox.c
 
 //config
 #define HOUR_NUMBERS 1
+#define HOUR_HEXADECIMAL 1
 #define HI_PRECISION 1
 #define SHOW_DIGITS 1
+#define DIGITS_HEXADECIMAL 1
 #define MINUTE_DOTS 1
 #define SMOOTH_MOTION 1
 #define zoom 2
@@ -98,7 +100,11 @@ void render_clock(double h, double m, double s) {
                y = round(r+polar2y(phi,r));
                if(HOUR_NUMBERS) {
                        cifernik[x][y] = '0'+(i%10);
-                       if(i>9) cifernik[x-1][y] = '0'+(i/10);
+                       if(HOUR_HEXADECIMAL) {
+                               sprintf(&cifernik[x][y],"%X",i);
+                       } else {
+                               if(i>9) cifernik[x-1][y] = '0'+(i/10);
+                       }
                } else {
                        cifernik[x][y] = color_number;
                }
@@ -161,7 +167,10 @@ int main(void) {
                        s = cas->tm_sec;
                        top();
                        render_clock(cas->tm_hour,cas->tm_min,cas->tm_sec); //analog
-                       if(SHOW_DIGITS) printf("\r[%.2d:%.2d:%.2d]",cas->tm_hour,cas->tm_min,cas->tm_sec); //digital
+                       if(SHOW_DIGITS || DIGITS_HEXADECIMAL) putchar('\r');
+                       if(SHOW_DIGITS) printf("DEC:[%.2d:%.2d:%.2d]",cas->tm_hour,cas->tm_min,cas->tm_sec); //digital
+                       if(SHOW_DIGITS || DIGITS_HEXADECIMAL) putchar(' ');
+                       if(DIGITS_HEXADECIMAL) printf("HEX:[%.2x:%.2x:%.2x]",cas->tm_hour,cas->tm_min,cas->tm_sec); //digital hexadec
                }
                if(HI_PRECISION) { usleep(100000); }
                else { sleep(1); }
This page took 0.098451 seconds and 4 git commands to generate.