added big clock formatting

This commit is contained in:
catdotjs 2023-12-18 15:22:00 +02:00
parent 4ee2b3ecc7
commit ff0be009ad
4 changed files with 17 additions and 4 deletions

View File

@ -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;
}

View File

@ -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},

View File

@ -66,6 +66,7 @@ struct config
char asterisk;
uint8_t bg;
bool bigclock;
char* bigclock_format;
bool blank_box;
bool blank_password;
char* clock;

View File

@ -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);