25
25
26
26
#include " dwin_api.h"
27
27
#include " dwin_set.h"
28
+ #include " dwin_font.h"
28
29
29
30
#include " ../../../inc/MarlinConfig.h"
30
31
@@ -89,6 +90,40 @@ bool DWIN_Handshake() {
89
90
}
90
91
#endif
91
92
93
+ // Get font character width
94
+ uint8_t fontWidth (uint8_t cfont) {
95
+ switch (cfont) {
96
+ case font6x12 : return 6 ;
97
+ case font8x16 : return 8 ;
98
+ case font10x20: return 10 ;
99
+ case font12x24: return 12 ;
100
+ case font14x28: return 14 ;
101
+ case font16x32: return 16 ;
102
+ case font20x40: return 20 ;
103
+ case font24x48: return 24 ;
104
+ case font28x56: return 28 ;
105
+ case font32x64: return 32 ;
106
+ default : return 0 ;
107
+ }
108
+ }
109
+
110
+ // Get font character height
111
+ uint8_t fontHeight (uint8_t cfont) {
112
+ switch (cfont) {
113
+ case font6x12 : return 12 ;
114
+ case font8x16 : return 16 ;
115
+ case font10x20: return 20 ;
116
+ case font12x24: return 24 ;
117
+ case font14x28: return 28 ;
118
+ case font16x32: return 32 ;
119
+ case font20x40: return 40 ;
120
+ case font24x48: return 48 ;
121
+ case font28x56: return 56 ;
122
+ case font32x64: return 64 ;
123
+ default : return 0 ;
124
+ }
125
+ }
126
+
92
127
// Set screen display direction
93
128
// dir: 0=0°, 1=90°, 2=180°, 3=270°
94
129
void DWIN_Frame_SetDir (uint8_t dir) {
@@ -199,6 +234,8 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
199
234
// *string: The string
200
235
// rlimit: To limit the drawn string length
201
236
void DWIN_Draw_String (bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit /* =0xFFFF*/ ) {
237
+ DWIN_Draw_Rectangle (1 , bColor, x, y, x + (fontWidth (size) * strlen_P (string)), y + fontHeight (size));
238
+ DWIN_UpdateLCD ();
202
239
constexpr uint8_t widthAdjust = 0 ;
203
240
size_t i = 0 ;
204
241
DWIN_Byte (i, 0x11 );
@@ -213,6 +250,7 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor,
213
250
DWIN_Word (i, y);
214
251
DWIN_Text (i, string, rlimit );
215
252
DWIN_Send (i);
253
+ DWIN_UpdateLCD ();
216
254
}
217
255
218
256
// Draw a positive integer
@@ -228,6 +266,7 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor,
228
266
void DWIN_Draw_IntValue (uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
229
267
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) {
230
268
size_t i = 0 ;
269
+ DWIN_Draw_Rectangle (1 , bColor, x, y, x + fontWidth (size) * iNum + 1 , y + fontHeight (size));
231
270
DWIN_Byte (i, 0x14 );
232
271
// Bit 7: bshow
233
272
// Bit 6: 1 = signed; 0 = unsigned number;
@@ -258,6 +297,7 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t
258
297
#endif
259
298
260
299
DWIN_Send (i);
300
+ DWIN_UpdateLCD ();
261
301
}
262
302
263
303
// Draw a floating point number
@@ -275,6 +315,7 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_
275
315
uint16_t bColor, uint8_t iNum, uint8_t fNum , uint16_t x, uint16_t y, int32_t value) {
276
316
// uint8_t *fvalue = (uint8_t*)&value;
277
317
size_t i = 0 ;
318
+ DWIN_Draw_Rectangle (1 , bColor, x, y, x + fontWidth (size) * (iNum+fNum +1 ), y + fontHeight (size));
278
319
DWIN_Byte (i, 0x14 );
279
320
DWIN_Byte (i, (bShow * 0x80 ) | (zeroFill * 0x20 ) | (zeroMode * 0x10 ) | size);
280
321
DWIN_Word (i, color);
@@ -291,6 +332,7 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_
291
332
DWIN_Byte(i, fvalue[0]);
292
333
*/
293
334
DWIN_Send (i);
335
+ DWIN_UpdateLCD ();
294
336
}
295
337
296
338
// Draw a floating point number
0 commit comments