diff --git a/project/.cproject b/project/.cproject deleted file mode 100644 index 2b2e80a..0000000 --- a/project/.cproject +++ /dev/null @@ -1,225 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/Core/Src/lcd_api.c b/project/Core/Src/lcd_api.c index 4cc900f..fa14340 100644 --- a/project/Core/Src/lcd_api.c +++ b/project/Core/Src/lcd_api.c @@ -38,31 +38,18 @@ void lcd_display_text(const char* text, uint16_t x_pos, uint16_t y_pos, uint32_t BSP_LCD_SetFont(font); if (tot_length > BSP_LCD_GetXSize()) { - uint16_t wrap_idx = (BSP_LCD_GetXSize() - x_pos)/font->Width; - if (isalpha(text[wrap_idx - 1]) && isalpha(text[wrap_idx])) { - x_pos -= (font->Width-2); - char part_one[wrap_idx+2]; - char part_two[(strlen(text) - wrap_idx)+1]; - strncpy(part_one, text, wrap_idx); - part_one[wrap_idx] = '-'; - part_one[wrap_idx+1] = '\00'; - strncpy(part_two, &text[wrap_idx], (strlen(text) - wrap_idx)); - part_two[(strlen(text) - wrap_idx)] = '\00'; - BSP_LCD_DisplayStringAt(x_pos, y_pos, part_one, LEFT_MODE); - y_pos += font->Height; - x_pos = 0; - BSP_LCD_DisplayStringAt(x_pos, y_pos, part_two, LEFT_MODE); - } else { - char part_one[wrap_idx+1]; - char part_two[(strlen(text) - wrap_idx)+1]; - strncpy(part_one, text, wrap_idx); - part_one[wrap_idx] = '\00'; - strncpy(part_two, &text[wrap_idx], (strlen(text) - wrap_idx)); - part_two[(strlen(text) - wrap_idx)] = '\00'; - BSP_LCD_DisplayStringAt(x_pos, y_pos, part_one, LEFT_MODE); - y_pos += font->Height; - x_pos = 0; - BSP_LCD_DisplayStringAt(x_pos, y_pos, part_two, LEFT_MODE); + for (int i = 0; i < strlen(text); i++) { + if ((x_pos) > BSP_LCD_GetXSize() - (font->Width)*2) { + if (isalpha(text[i-1]) && isalpha(text[i])) { + BSP_LCD_DisplayChar(x_pos, y_pos, '-'); + i -= 1; + } + x_pos = 0; + y_pos += font->Height; + } else { + BSP_LCD_DisplayChar(x_pos, y_pos, text[i]); + x_pos += font->Width; + } } } else { BSP_LCD_DisplayStringAt(x_pos, y_pos, text, LEFT_MODE);