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--) {
+2 -2
View File
@@ -44,7 +44,7 @@ typedef uint8_t display_t;
#define BLINK 0x01
#define INVERS 0x02
#if defined(BOLD_FONT)
#define BOLD 0x40
#define BOLD 0x40u
#else
#define BOLD 0x00
#endif
@@ -55,7 +55,7 @@ typedef uint8_t display_t;
#define FIXEDWIDTH 0x10
/* no 0x80 here because of "GV"1 which is aligned LEFT */
/* no 0x10 here because of "MODEL"01 which uses LEADING0 */
#define ZCHAR 0x80
#define ZCHAR 0x80u
/* lcdDrawNumber additional flags */
#define LEADING0 0x10
+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)