Bootloader cosmetics

This commit is contained in:
Bertrand Songis
2020-06-13 14:59:13 +02:00
parent 18461a3b28
commit 24cd7611cf
10 changed files with 64 additions and 67 deletions
+11 -7
View File
@@ -149,9 +149,9 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
}
}
#if !defined(BOOT)
void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
{
#if !defined(BOOT)
uint32_t fontsize = FONTSIZE(flags);
unsigned char c_remapped = 0;
@@ -212,6 +212,11 @@ void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
pattern->height = 7;
pattern->data = (c < 0xC0) ? &font_5x7[(c-0x20)*5] : &font_5x7_extra[(c-0xC0)*5];
}
#else
pattern->width = 5;
pattern->height = 7;
pattern->data = &font_5x7[(c-0x20) * 5];
#endif
}
uint8_t getCharWidth(char c, LcdFlags flags)
@@ -220,7 +225,6 @@ uint8_t getCharWidth(char c, LcdFlags flags)
getCharPattern(&pattern, c, flags);
return getPatternWidth(&pattern);
}
#endif
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
{
@@ -240,12 +244,15 @@ void lcdDrawChar(coord_t x, coord_t y, const unsigned char c)
lcdDrawChar(x, y, c, 0);
}
#if !defined(BOOT)
uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags)
{
uint8_t width = 0;
for (int i=0; len==0 || i<len; ++i) {
for (int i = 0; len == 0 || i < len; ++i) {
#if !defined(BOOT)
unsigned char c = (flags & ZCHAR) ? zchar2char(*s) : *s;
#else
unsigned char c = *s;
#endif
if (!c) {
break;
}
@@ -254,7 +261,6 @@ uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags)
}
return width;
}
#endif
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags flags)
{
@@ -264,7 +270,6 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
bool setx = false;
uint8_t width = 0;
#if !defined(BOOT)
if (flags & RIGHT) {
width = getTextWidth(s, len, flags);
x -= width;
@@ -273,7 +278,6 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
width = getTextWidth(s, len, flags);
x -= width / 2;
}
#endif
while (len--) {
#if defined(BOOT)