legacy: fix types for characted data

pull/620/head
Pavol Rusnak 5 years ago
parent b07b9b1d09
commit 145b098f0e
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -9,8 +9,8 @@ const uint8_t *const font_data[2][128] = {
},
};
int fontCharWidth(int font, char c) { return font_data[font][c & 0x7f][0]; }
int fontCharWidth(int font, uint8_t c) { return font_data[font][c & 0x7f][0]; }
const uint8_t *fontCharData(int font, char c) {
const uint8_t *fontCharData(int font, uint8_t c) {
return font_data[font][c & 0x7f] + 1;
}

@ -10,7 +10,7 @@
extern const uint8_t *const font_data[2][128];
int fontCharWidth(int font, char c);
const uint8_t *fontCharData(int font, char c);
int fontCharWidth(int font, uint8_t c);
const uint8_t *fontCharData(int font, uint8_t c);
#endif

@ -247,8 +247,8 @@ void oledDrawChar(int x, int y, char c, int font) {
}
int zoom = (font & FONT_DOUBLE) ? 2 : 1;
int char_width = fontCharWidth(font & 0x7f, c);
const uint8_t *char_data = fontCharData(font & 0x7f, c);
int char_width = fontCharWidth(font & 0x7f, (uint8_t)c);
const uint8_t *char_data = fontCharData(font & 0x7f, (uint8_t)c);
if (x <= -char_width) {
return;
@ -268,9 +268,11 @@ void oledDrawChar(int x, int y, char c, int font) {
}
}
char oledConvertChar(const char c) {
static uint8_t convert_char(const char a) {
static char last_was_utf8 = 0;
uint8_t c = a;
// non-printable ASCII character
if (c < ' ') {
last_was_utf8 = 0;
@ -307,7 +309,7 @@ int oledStringWidth(const char *text, int font) {
int space = (font & FONT_DOUBLE) ? 2 : 1;
int l = 0;
for (; *text; text++) {
char c = oledConvertChar(*text);
uint8_t c = convert_char(*text);
if (c) {
l += fontCharWidth(font & 0x7f, c) + space;
}
@ -320,7 +322,7 @@ void oledDrawString(int x, int y, const char *text, int font) {
int l = 0;
int space = (font & FONT_DOUBLE) ? 2 : 1;
for (; *text; text++) {
char c = oledConvertChar(*text);
uint8_t c = convert_char(*text);
if (c) {
oledDrawChar(x + l, y, c, font);
l += fontCharWidth(font & 0x7f, c) + space;

Loading…
Cancel
Save