diff --git a/01_git/astime_x.c b/01_git/astime_x.c index 5e4a1209e2bd30eb097b4110905b3383fcdae69a..5331baf416f9b32454f39c60ce9ef8bbe004ad4e 100644 --- a/01_git/astime_x.c +++ b/01_git/astime_x.c @@ -9,6 +9,7 @@ * This software is distributed under GPL. For details see LICENSE file. */ +#define DEBUG #include <stdio.h> #include <stdlib.h> @@ -119,16 +120,33 @@ void draw_sunriset(Display *dpy, size = CIV_SUNSIZE; civil_twilight(local_time->tm_year, local_time->tm_mon, local_time->tm_mday, lat, lon, &start, &end); +#ifdef DEBUG + printf("Buergerliche Daemmerung beginnt um %d Uhr", + start); + printf(" und endet um %d Uhr.\n", + end); +#endif } else if (type == 1) { size = NAUT_SUNSIZE; nautical_twilight(local_time->tm_year, local_time->tm_mon, local_time->tm_mday, lat, lon, &start, &end); +#ifdef DEBUG + printf("Nautische Daemmerung beginnt um %d Uhr", + start); + printf(" und endet um %d Uhr.\n", + end); +#endif } else { size = ASTRO_SUNSIZE; astronomical_twilight(local_time->tm_year, local_time->tm_mon, local_time->tm_mday, lat, lon, &start, &end); +#ifdef DEBUG + printf("Astronomische Daemmerung beginnt um %d Uhr", + start); + printf(" und endet um %d Uhr.\n", + end); +#endif } - /*color = WhitePixel(dpy, DefaultScreen(dpy));*/ gc = XCreateGC(dpy, win, 0, NULL); XSetForeground(dpy, gc, color); x = center.x - (watch_size.x * size); @@ -143,7 +161,10 @@ void draw_sunriset(Display *dpy, angle2 = (int) round(end * 15.0); angle2 -= (angle1 + 360) % 360; #ifdef DEBUG - printf("angle1 = %d, angle2 = %d, tm_isdst = %d, start = %lf, end = %lf\n", angle1, angle2, local_time->tm_isdst, start, end); + printf("angle1 = %d, angle2 = %d, tm_isdst = %d, start = %lf, end = %lf\n", + angle1, angle2, local_time->tm_isdst, start, end); + printf("%d:%d:%d Uhr\n", + local_time->tm_hour, local_time->tm_min, local_time->tm_sec); #endif XFillArc(mainDisplay, win, gc, x, x, width, height, (360 - angle1 + 90) * 64, -angle2 * 64); } @@ -300,15 +321,15 @@ void draw_window(Window win) ); #endif if (state.twentyfour) { -#define CIVIL_DAWN 0 -#define NAUT_DAWN 1 -#define ASTRO_DAWN 2 +#define CIVIL_TWILIGHT 0 +#define NAUT_TWILIGHT 1 +#define ASTRO_TWILIGHT 2 draw_sunriset(mainDisplay, win, loc_time, - 49.6972222, 11.05, pix[4], ASTRO_DAWN); + 49.6972222, 11.05, pix[4], ASTRO_TWILIGHT); draw_sunriset(mainDisplay, win, loc_time, - 49.6972222, 11.05, pix[6], NAUT_DAWN); + 49.6972222, 11.05, pix[6], NAUT_TWILIGHT); draw_sunriset(mainDisplay, win, loc_time, - 49.6972222, 11.05, pix[3], CIVIL_DAWN); + 49.6972222, 11.05, pix[3], CIVIL_TWILIGHT); } /* draw filled polygonal hands */ for (i = 2; i >= 0; i--) { @@ -487,28 +508,9 @@ void calculate_hands() #ifdef DEBUG if (i == 0) { - double start, end; - int start_hour, start_min, start_sec, end_hour, end_min, end_sec; - - /* printf("%d hour = %d %d -> %d %d, xrate = %f, yrate = %f\n", + printf("%d hour = %d %d -> %d %d, xrate = %f, yrate = %f\n", loc_time->tm_hour, lines[2].x1, lines[2].y1, - lines[2].x2, lines[2].y2, xrate[2], yrate[2]); */ - civil_twilight(loc_time->tm_year, loc_time->tm_mon, - loc_time->tm_mday, 11.05, 49.6972222, &start, &end); - start_hour = (int) start; - end_hour = (int) end; - start -= start_hour; - end -= end_hour; - start_min = (int) (start * 60); - end_min = (int) (end * 60); - start -= ((double) start_min) / 60.0; - end -= ((double) end_min) / 60.0; - start_sec = (int) (start * 360); - end_sec = (int) (end * 360); - printf("Buergerliche Daemmerung beginnt um %d:%d:%d Uhr", - start_hour, start_min, start_sec); - printf("und endet um %d:%d:%d Uhr.\n", - end_hour, end_min, end_sec); + lines[2].x2, lines[2].y2, xrate[2], yrate[2]); } #endif