|
@@ -37,9 +37,9 @@
|
37
|
37
|
#include "dwin_lcd.h"
|
38
|
38
|
#include <string.h> // for memset
|
39
|
39
|
|
40
|
|
-// Make sure DWIN_SendBuf is large enough to hold the largest
|
41
|
|
-// printed string plus the draw command and tail.
|
42
|
|
-uint8_t DWIN_SendBuf[11 + 24] = { 0xAA };
|
|
40
|
+// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
|
|
41
|
+// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
|
|
42
|
+uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
|
43
|
43
|
uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
|
44
|
44
|
uint8_t databuf[26] = { 0 };
|
45
|
45
|
uint8_t receivedType;
|
|
@@ -63,7 +63,7 @@ inline void DWIN_Long(size_t &i, const uint32_t lval) {
|
63
|
63
|
}
|
64
|
64
|
|
65
|
65
|
inline void DWIN_String(size_t &i, char * const string) {
|
66
|
|
- const size_t len = strlen(string);
|
|
66
|
+ const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, strlen(string));
|
67
|
67
|
memcpy(&DWIN_SendBuf[i+1], string, len);
|
68
|
68
|
i += len;
|
69
|
69
|
}
|