|
@@ -264,7 +264,8 @@ static void ST7735_WriteChar(uint16_t x, uint16_t y, char ch, FontDef font, uint
|
|
|
void ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, uint16_t color, uint16_t bgcolor) {
|
|
|
ST7735_Select();
|
|
|
|
|
|
- while (*str) {
|
|
|
+ char ch = *str;
|
|
|
+ while (ch) {
|
|
|
if (x + font.width >= ST7735_WIDTH) {
|
|
|
x = 0;
|
|
|
y += font.height;
|
|
@@ -272,16 +273,37 @@ void ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, u
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (*str == ' ') {
|
|
|
+ if (ch == ' ') {
|
|
|
// skip spaces in the beginning of the new line
|
|
|
str ++;
|
|
|
+ ch = *str;
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- ST7735_WriteChar(x, y, *str, font, color, bgcolor);
|
|
|
+#ifdef USE_UTF8
|
|
|
+ if (ch >= 0xC0) {
|
|
|
+ switch (ch) {
|
|
|
+ case 0xD0: {
|
|
|
+ str ++;
|
|
|
+ ch = *str;
|
|
|
+ if (ch == 0x81) { ch = 0xA8; break; }
|
|
|
+ if (ch >= 0x90 && ch <= 0xBF) ch += 0x2F;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0xD1: {
|
|
|
+ str ++;
|
|
|
+ ch = *str;
|
|
|
+ if (ch == 0x91) { ch = 0xB8; break; }
|
|
|
+ if (ch >= 0x7E && ch <= 0x8F) ch += 0x6F;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif /* USE_UTF8 */
|
|
|
+ ST7735_WriteChar(x, y, ch, font, color, bgcolor);
|
|
|
x += font.width;
|
|
|
str ++;
|
|
|
+ ch = *str;
|
|
|
}
|
|
|
|
|
|
ST7735_Unselect();
|
|
@@ -380,7 +402,7 @@ void ST7735_FillRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16
|
|
|
|
|
|
ST7735_Unselect();
|
|
|
}
|
|
|
-#ifdef USER_MALLOC
|
|
|
+#ifdef USE_MALLOC
|
|
|
void ST7735_FillRectangleFast(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) {
|
|
|
// clipping
|
|
|
if ((x >= ST7735_WIDTH) || (y >= ST7735_HEIGHT)) {
|
|
@@ -398,7 +420,8 @@ void ST7735_FillRectangleFast(uint16_t x, uint16_t y, uint16_t w, uint16_t h, ui
|
|
|
|
|
|
// Prepare whole line in a single buffer
|
|
|
uint8_t pixel[] = {color >> 8, color & 0xFF};
|
|
|
- uint8_t *line = malloc(w * sizeof(pixel));
|
|
|
+// uint8_t *line = malloc(w * sizeof(pixel));
|
|
|
+ uint8_t *line = chHeapAlloc(NULL, w * sizeof(pixel));
|
|
|
for (x = 0; x < w; ++x) {
|
|
|
memcpy(line + x * sizeof(pixel), pixel, sizeof(pixel));
|
|
|
}
|