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
+12 -8
View File
@@ -116,7 +116,6 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
}
}
#if !defined(BOOT)
struct PatternData
{
uint8_t width;
@@ -143,10 +142,11 @@ uint8_t getPatternWidth(const PatternData * pattern)
void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
{
#if !defined(BOOT)
uint32_t fontsize = FONTSIZE(flags);
unsigned char c_remapped = 0;
if (fontsize == DBLSIZE || (flags&BOLD)) {
if (fontsize == DBLSIZE || (flags & BOLD)) {
// To save space only some DBLSIZE and BOLD chars are available
// c has to be remapped. All non existing chars mapped to 0 (space)
if (c>=',' && c<=':')
@@ -203,6 +203,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)
@@ -211,7 +216,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)
{
@@ -288,12 +292,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;
}
@@ -302,7 +309,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)
{
@@ -311,7 +317,6 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
const uint8_t orig_len = len;
uint32_t fontsize = FONTSIZE(flags);
#if !defined(BOOT)
uint8_t width = 0;
if (flags & RIGHT) {
width = getTextWidth(s, len, flags);
@@ -321,7 +326,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
bool setx = false;
while (len--) {