add centered text
This commit is contained in:
@@ -184,6 +184,22 @@ void put_line(uint8_t line, char *str, uint8_t spacing, uint8_t size){
|
||||
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++;
|
||||
}
|
||||
}
|
||||
@@ -202,8 +218,7 @@ void app_main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
|
||||
put_line(0, "429 Amalienplatz");
|
||||
put_line(1, "0123abcd");
|
||||
put_line(2, "429 Amalienplatz", 1, 1);
|
||||
|
||||
gpio_config_t io_conf;
|
||||
//disable interrupt
|
||||
|
||||
Reference in New Issue
Block a user