From c84a2ea0756c4a749cff5aff7aa029e880d1a5c6 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Fri, 18 Oct 2019 20:13:17 -0400 Subject: clock_clear(): New function --- diff --git a/src/clock.c b/src/clock.c index f6ffdcf..a914aa3 100644 --- a/src/clock.c +++ b/src/clock.c @@ -51,8 +51,10 @@ static const uint16_t _clock_font[] = { 075757, /* 8 */ 075717, /* 9 */ 004040, /* : */ + 000000, /* Blank */ }; #define COLON_DIGIT 10 +#define BLANK_DIGIT 11 struct clock { WINDOW *win; @@ -184,6 +186,22 @@ clock_draw(struct clock *clock) _clock_draw_digit(clock, x += SPACING + DIGIT_WIDTH, tm->tm_sec % 10); } +void +clock_clear(struct clock *clock) +{ + int x; + + x = 0; + _clock_draw_digit(clock, x += SPACING , BLANK_DIGIT); + _clock_draw_digit(clock, x += SPACING + DIGIT_WIDTH, BLANK_DIGIT); + _clock_draw_digit(clock, x += SPACING + DIGIT_WIDTH, BLANK_DIGIT); + _clock_draw_digit(clock, x += SPACING + COLON_WIDTH, BLANK_DIGIT); + _clock_draw_digit(clock, x += SPACING + DIGIT_WIDTH, BLANK_DIGIT); + _clock_draw_digit(clock, x += SPACING + DIGIT_WIDTH, BLANK_DIGIT); + _clock_draw_digit(clock, x += SPACING + COLON_WIDTH, BLANK_DIGIT); + _clock_draw_digit(clock, x += SPACING + DIGIT_WIDTH, BLANK_DIGIT); +} + struct clock * clock_destroy(struct clock **clock_p) { diff --git a/src/clock.h b/src/clock.h index 9851ddd..8bd0a24 100644 --- a/src/clock.h +++ b/src/clock.h @@ -38,6 +38,9 @@ clock_size(struct clock *clock); void clock_draw(struct clock *clock); +void +clock_clear(struct clock *clock); + struct clock * clock_destroy(struct clock **clock_p); -- cgit v0.9.1