diff --git a/src/bigclock.h b/src/bigclock.h index 2de834a..2236d2c 100644 --- a/src/bigclock.h +++ b/src/bigclock.h @@ -109,6 +109,14 @@ uint32_t CLOCK_E[] = { _,_,_,_,_ }; +uint32_t CLOCK_D[] = { + _,_,_,_,_, + _,_,_,_,_, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_ +}; + #endif #undef X @@ -140,6 +148,8 @@ static inline uint32_t* CLOCK_N(char c) return CLOCK_9; case ':': return CLOCK_S; + case '-': + return CLOCK_D; default: return CLOCK_E; } diff --git a/src/config.c b/src/config.c index f7a1c00..50e62cc 100644 --- a/src/config.c +++ b/src/config.c @@ -162,6 +162,7 @@ void config_load(const char *cfg_path) {"asterisk", &config.asterisk, config_handle_char}, {"bg", &config.bg, config_handle_u8}, {"bigclock", &config.bigclock, config_handle_bool}, + {"bigclock_format", &config.bigclock_format, config_handle_str}, {"blank_box", &config.blank_box, config_handle_bool}, {"blank_password", &config.blank_password, config_handle_bool}, {"clock", &config.clock, config_handle_str}, diff --git a/src/config.h b/src/config.h index 6a54f60..376f099 100644 --- a/src/config.h +++ b/src/config.h @@ -66,6 +66,7 @@ struct config char asterisk; uint8_t bg; bool bigclock; + char* bigclock_format; bool blank_box; bool blank_password; char* clock; diff --git a/src/draw.c b/src/draw.c index 0679244..4855a77 100644 --- a/src/draw.c +++ b/src/draw.c @@ -244,14 +244,15 @@ void draw_bigclock(struct term_buf* buf) { return; } - - int xo = buf->width / 2 - (5 * (CLOCK_W + 1)) / 2; + uint32_t bigclocklength = strlen(config.bigclock_format); + + int xo = (buf->width / 2) - bigclocklength * (CLOCK_W+1) / 2; int yo = (buf->height - buf->box_height) / 2 - CLOCK_H - 2; - char* clockstr = time_str("%H:%M", 6); + char* clockstr = time_str(config.bigclock_format, 32); struct tb_cell* clockcell; - for (int i = 0; i < 5; i++) + for (int i = 0; i < bigclocklength; i++) { clockcell = clock_cell(clockstr[i]); alpha_blit(tb_cell_buffer(), xo + i * (CLOCK_W + 1), yo, CLOCK_W, CLOCK_H, clockcell);