add centered text

text_rendering
Eggert Jung 4 years ago
parent 908ecfc1d7
commit 8057e659a3

@ -184,6 +184,22 @@ void put_line(uint8_t line, char *str, uint8_t spacing, uint8_t size){
pos++; pos++;
} }
} }
void put_line_center(uint8_t line, char *str, uint8_t spacing, uint8_t size){
uint8_t pos = 0;
uint8_t txt_length = 0;
while(str[pos] != 0){
txt_length += (check_chr_width(font[str[pos]-0x20]) + 1 + spacing)*size;
pos++;
}
pos=0;
uint8_t disp_pos = 65-(txt_length/2);
while(str[pos] != 0){
put_chr(line, disp_pos, font[str[pos]-0x20], size);
disp_pos += (check_chr_width(font[str[pos]-0x20]) + 1 + spacing)*size;
pos++; pos++;
} }
} }
@ -202,8 +218,7 @@ void app_main(void)
{ {
printf("Hello world!\n"); printf("Hello world!\n");
put_line(0, "429 Amalienplatz"); put_line(2, "429 Amalienplatz", 1, 1);
put_line(1, "0123abcd");
gpio_config_t io_conf; gpio_config_t io_conf;
//disable interrupt //disable interrupt

Loading…
Cancel
Save