void display_clock(int x, int y, uint32_t tm) { int hh, mm, ss, ms; hh = (int) tm / 3600000; mm = (int) (tm % 3600000) / 60000; ss = (int) (tm % 60000) / 1000; ms = (int) tm % 1000; draw_digit(x, y, hh / 10, GFX_COLOR_RED, GFX_COLOR_BLACK); x += DISP_WIDTH + SEG_THICK/2; draw_digit(x, y, hh % 10, GFX_COLOR_RED, GFX_COLOR_BLACK); x += DISP_WIDTH + SEG_THICK/2; draw_colon(x, y, GFX_COLOR_RED, GFX_COLOR_BLACK); x += SEG_THICK + SEG_THICK/2;; draw_digit(x, y, mm / 10, GFX_COLOR_RED, GFX_COLOR_BLACK); x += DISP_WIDTH + SEG_THICK/2; draw_digit(x, y, mm % 10, GFX_COLOR_RED, GFX_COLOR_BLACK); x += DISP_WIDTH + SEG_THICK/2; draw_colon(x, y, GFX_COLOR_RED, GFX_COLOR_BLACK); x += SEG_THICK + SEG_THICK/2;; draw_digit(x, y, ss / 10, GFX_COLOR_RED, GFX_COLOR_BLACK); x += DISP_WIDTH + SEG_THICK/2; draw_digit(x, y, ss % 10, GFX_COLOR_RED, GFX_COLOR_BLACK); x += DISP_WIDTH + SEG_THICK/2; draw_dp(x, y, GFX_COLOR_RED, GFX_COLOR_BLACK); x += SEG_THICK + SEG_THICK/2; draw_digit(x, y, ms / 100, GFX_COLOR_RED, GFX_COLOR_BLACK); x += DISP_WIDTH + SEG_THICK/2; draw_digit(x, y, ms / 10, GFX_COLOR_RED, GFX_COLOR_BLACK); x += DISP_WIDTH + SEG_THICK/2; draw_digit(x, y, ms, GFX_COLOR_RED, GFX_COLOR_BLACK); }
/* draw callback for our custom widget */ static void clock_widget_draw( sgui_widget* super ) { clock_widget* this = (clock_widget*)super; int x, y; x = super->area.left; y = super->area.top; draw_segment_digit( super->canvas, this->hour / 10, x, y, 10 ); draw_segment_digit( super->canvas, this->hour % 10, x+16, y, 10 ); draw_colon( super->canvas, x+33, y, 10 ); draw_segment_digit( super->canvas, this->minute / 10, x+37, y, 10 ); draw_segment_digit( super->canvas, this->minute % 10, x+56, y, 10 ); draw_colon( super->canvas, x+73, y, 10 ); draw_segment_digit( super->canvas, this->second / 10, x+77, y, 10 ); draw_segment_digit( super->canvas, this->second % 10, x+93, y, 10 ); }
/* * And this is where we will generate our digits * when we copy them with the DMA2D device we can * use the color lookup table to set the values. * in this case we'll use 0, 1, and 2 for background * foreground, and outline color. * * While the digits are kerned in the display they are * drawn here with a box that is DISP_WIDTH + SKEW_MAX * pixels wide, but DISP_HEIGHT pixels high. */ void generate_digits(void) { uint32_t i; gfx_init(digit_draw_pixel, DIGIT_FB_WIDTH, DIGIT_FB_HEIGHT, GFX_FONT_LARGE); /* Cleared to zero (background) */ for (i = 0; i < sizeof(digit_fb); i++) { digit_fb[i] = 0; } for (i = 0; i < 10; i++) { draw_digit(i * (DISP_WIDTH + SKEW_MAX), 0, i, 1, 2); } draw_colon(10 * (DISP_WIDTH + SKEW_MAX), 0, 1, 2); draw_dp(10 * (DISP_WIDTH + SKEW_MAX) + SEG_THICK + SKEW_MAX, 0, 1, 2); /* now the digit_fb memory has the 10 digits 0-9, : and . in it */ }
static void draw_flappers (ModeInfo *mi, Bool text_p) { splitflap_configuration *bp = &bps[MI_SCREEN(mi)]; int x, y; int running = 0; for (y = 0; y < grid_height; y++) for (x = 0; x < grid_width; x++) { int i = (grid_height - y - 1) * grid_width + x; flapper *f = &bp->flappers[i]; GLfloat xx = x; GLfloat yy = y; if (bp->clock_p) { if (x >= 2) xx += COLON_WIDTH; if (x >= 4) xx += COLON_WIDTH; if (x >= 6) xx += COLON_WIDTH; } xx *= 2.01; yy *= 1.98; glPushMatrix(); glTranslatef (xx, yy, 0); mi->polygon_count += draw_flapper (mi, f, text_p); if (text_p && bp->clock_p && (x == 2 || x == 4)) mi->polygon_count += draw_colon (mi); glPopMatrix(); if (text_p) { tick_flapper (mi, f); if (f->current_index != f->target_index) running++; } } if (text_p && !running) { if (bp->clock_p) fill_targets (mi); else if (bp->linger) { bp->linger--; if (!bp->linger) fill_targets (mi); } else { /* Base of 1 second, plus 1 second for every 25 characters. Also multiply by speed? */ bp->linger = 30; if (!bp->first_time_p) bp->linger += (grid_width * grid_height * 1.2); bp->first_time_p = False; } } }