Browse Source

Translated DWIN screen titles (#18893)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Slats 5 years ago
parent
commit
1d240ce5a3
No account linked to committer's email address
2 changed files with 116 additions and 39 deletions
  1. 12
    8
      Marlin/src/lcd/dwin/dwin.cpp
  2. 104
    31
      Marlin/src/lcd/dwin/dwin_lcd.cpp

+ 12
- 8
Marlin/src/lcd/dwin/dwin.cpp View File

@@ -379,6 +379,10 @@ inline void Draw_Title(const char * const title) {
379 379
   DWIN_Draw_String(false, false, HEADER_FONT, White, Background_blue, 14, 4, (char*)title);
380 380
 }
381 381
 
382
+inline void Draw_Title(const __FlashStringHelper * title) {
383
+  DWIN_Draw_String(false, false, HEADER_FONT, White, Background_blue, 14, 4, (char*)title);
384
+}
385
+
382 386
 inline void Clear_Menu_Area(void) {
383 387
   DWIN_Draw_Rectangle(1, Background_black,  0,  31, 272,  360);
384 388
 }
@@ -568,7 +572,7 @@ inline void Draw_Prepare_Menu() {
568 572
   }
569 573
   else {
570 574
     #ifdef USE_STRING_HEADINGS
571
-      Draw_Title("Prepare"); // TODO: GET_TEXT_F
575
+      Draw_Title(GET_TEXT_F(MSG_PREPARE));
572 576
     #else
573 577
       DWIN_Frame_AreaCopy(1, 178, 2, 271 - 42, 479 - 464 - 1, 14, 8); // "Prepare"
574 578
     #endif
@@ -611,7 +615,7 @@ inline void Draw_Control_Menu() {
611 615
   }
612 616
   else {
613 617
     #ifdef USE_STRING_HEADINGS
614
-      Draw_Title("Control"); // TODO: GET_TEXT_F
618
+      Draw_Title(GET_TEXT_F(MSG_CONTROL));
615 619
     #else
616 620
       DWIN_Frame_AreaCopy(1, 128, 2, 271 - 95, 479 - 467, 14, 8);
617 621
     #endif
@@ -656,7 +660,7 @@ inline void Draw_Tune_Menu() {
656 660
   }
657 661
   else {
658 662
     #ifdef USE_STRING_HEADINGS
659
-      Draw_Title("Tune"); // TODO: GET_TEXT
663
+      Draw_Title(GET_TEXT_F(MSG_TUNE));
660 664
     #else
661 665
       DWIN_Frame_AreaCopy(1, 94, 2, 271 - 145, 479 - 467, 14, 9);
662 666
     #endif
@@ -730,7 +734,7 @@ inline void Draw_Motion_Menu() {
730 734
   }
731 735
   else {
732 736
     #ifdef USE_STRING_HEADINGS
733
-      Draw_Title("Motion"); // TODO: GET_TEXT_F
737
+      Draw_Title(GET_TEXT_F(MSG_MOTION));
734 738
     #else
735 739
       DWIN_Frame_AreaCopy(1, 144, 16, 271 - 82, 479 - 453, 14, 8);
736 740
     #endif
@@ -947,7 +951,7 @@ void Goto_MainMenu(void) {
947 951
   }
948 952
   else {
949 953
     #ifdef USE_STRING_HEADINGS
950
-      Draw_Title("Home"); // TODO: GET_TEXT
954
+      Draw_Title(GET_TEXT_F(MSG_MAIN));
951 955
     #else
952 956
       DWIN_Frame_AreaCopy(1, 0, 2, 271 - 232, 479 - 467, 14, 9);
953 957
     #endif
@@ -1714,7 +1718,7 @@ inline void Draw_Info_Menu() {
1714 1718
   }
1715 1719
   else {
1716 1720
     #ifdef USE_STRING_HEADINGS
1717
-      Draw_Title("Info"); // TODO: GET_TEXT_F
1721
+      Draw_Title(GET_TEXT_F(MSG_INFO_SCREEN));
1718 1722
     #else
1719 1723
       DWIN_Frame_AreaCopy(1, 190, 16, 271 - 56, 479 - 453, 14, 8);
1720 1724
     #endif
@@ -2091,7 +2095,7 @@ inline void Draw_Move_Menu() {
2091 2095
   }
2092 2096
   else {
2093 2097
     #ifdef USE_STRING_HEADINGS
2094
-      Draw_Title("Move"); // TODO: GET_TEXT_F
2098
+      Draw_Title(GET_TEXT_F(MSG_MOVE_AXIS));
2095 2099
     #else
2096 2100
       DWIN_Frame_AreaCopy(1, 231, 2, 271 - 6, 479 - 467, 14, 8);
2097 2101
     #endif
@@ -2245,7 +2249,7 @@ void Draw_Temperature_Menu() {
2245 2249
   }
2246 2250
   else {
2247 2251
     #ifdef USE_STRING_HEADINGS
2248
-      Draw_Title("Temperature"); // TODO: GET_TEXT_F
2252
+      Draw_Title(GET_TEXT_F(MSG_TEMPERATURE));
2249 2253
     #else
2250 2254
       DWIN_Frame_AreaCopy(1, 56, 16, 271 - 130, 479 - 450 - 1, 14, 8);
2251 2255
     #endif

+ 104
- 31
Marlin/src/lcd/dwin/dwin_lcd.cpp View File

@@ -21,11 +21,11 @@
21 21
  */
22 22
 
23 23
 /********************************************************************************
24
- * @file     dwin_lcd.c
24
+ * @file     dwin_lcd.cpp
25 25
  * @author   LEO / Creality3D
26 26
  * @date     2019/07/18
27 27
  * @version  2.0.1
28
- * @brief    迪文屏控制操作函数
28
+ * @brief    DWIN screen control functions
29 29
  ********************************************************************************/
30 30
 
31 31
 #include "../../inc/MarlinConfigPre.h"
@@ -68,7 +68,15 @@ inline void DWIN_String(size_t &i, char * const string) {
68 68
   i += len;
69 69
 }
70 70
 
71
-/*发送当前BUF中的数据以及包尾数据 len:整包数据长度*/
71
+inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
72
+  if (!string) return;
73
+  const size_t len = strlen_P((PGM_P)string); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
74
+  if (len == 0) return;
75
+  memcpy(&DWIN_SendBuf[i+1], string, len);
76
+  i += len;
77
+}
78
+
79
+// Send the data in the buffer and the packet end
72 80
 inline void DWIN_Send(size_t &i) {
73 81
   ++i;
74 82
   LOOP_L_N(n, i) {  MYSERIAL1.write(DWIN_SendBuf[n]);
@@ -77,8 +85,9 @@ inline void DWIN_Send(size_t &i) {
77 85
                     delayMicroseconds(1); }
78 86
 }
79 87
 
80
-/*----------------------------------------------系统变量函数----------------------------------------------*/
81
-/*握手 1: 握手成功  2: 握手失败*/
88
+/*-------------------------------------- System variable function --------------------------------------*/
89
+
90
+// Handshake (1: Success, 0: Fail)
82 91
 bool DWIN_Handshake(void) {
83 92
   size_t i = 0;
84 93
   DWIN_Byte(i, 0x00);
@@ -105,7 +114,8 @@ bool DWIN_Handshake(void) {
105 114
         && databuf[3] == 'K' );
106 115
 }
107 116
 
108
-/*设定背光亮度 luminance:亮度(0x00~0xFF)*/
117
+// Set the backlight luminance
118
+//  luminance: (0x00-0xFF)
109 119
 void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
110 120
   size_t i = 0;
111 121
   DWIN_Byte(i, 0x30);
@@ -113,7 +123,8 @@ void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
113 123
   DWIN_Send(i);
114 124
 }
115 125
 
116
-/*设定画面显示方向 dir:0,0°; 1,90°; 2,180°; 3,270°*/
126
+// Set screen display direction
127
+//  dir: 0=0°, 1=90°, 2=180°, 3=270°
117 128
 void DWIN_Frame_SetDir(uint8_t dir) {
118 129
   size_t i = 0;
119 130
   DWIN_Byte(i, 0x34);
@@ -123,15 +134,17 @@ void DWIN_Frame_SetDir(uint8_t dir) {
123 134
   DWIN_Send(i);
124 135
 }
125 136
 
126
-/*更新显示*/
137
+// Update display
127 138
 void DWIN_UpdateLCD(void) {
128 139
   size_t i = 0;
129 140
   DWIN_Byte(i, 0x3D);
130 141
   DWIN_Send(i);
131 142
 }
132 143
 
133
-/*----------------------------------------------绘图相关函数----------------------------------------------*/
134
-/*画面清屏 color:清屏颜色*/
144
+/*---------------------------------------- Drawing functions ----------------------------------------*/
145
+
146
+// Clear screen
147
+//  color: Clear screen color
135 148
 void DWIN_Frame_Clear(const uint16_t color) {
136 149
   size_t i = 0;
137 150
   DWIN_Byte(i, 0x01);
@@ -139,7 +152,10 @@ void DWIN_Frame_Clear(const uint16_t color) {
139 152
   DWIN_Send(i);
140 153
 }
141 154
 
142
-/*画面画线 color:线段颜色 xStart:X起始坐标 yStart:Y起始坐标 xEnd:X终止坐标 yEnd:Y终止坐标*/
155
+// Draw a line
156
+//  color: Line segment color
157
+//  xStart/yStart: Start point
158
+//  xEnd/yEnd: End point
143 159
 void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
144 160
   size_t i = 0;
145 161
   DWIN_Byte(i, 0x03);
@@ -151,7 +167,11 @@ void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t x
151 167
   DWIN_Send(i);
152 168
 }
153 169
 
154
-/*画面画矩形 mode:0,外框;1,填充;2,异或填充 color:颜色 xStart/yStart:矩形左上坐标 xEnd/yEnd:矩形右下坐标*/
170
+// Draw a rectangle
171
+//  mode: 0=frame, 1=fill, 2=XOR fill
172
+//  color: Rectangle color
173
+//  xStart/yStart: upper left point
174
+//  xEnd/yEnd: lower right point
155 175
 void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
156 176
                          uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
157 177
   size_t i = 0;
@@ -165,8 +185,14 @@ void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
165 185
   DWIN_Send(i);
166 186
 }
167 187
 
168
-/*画面区域移动 mode:0,环移;1,平移 dir:0,向左移动;1,向右移动;2,向上移动;3,向下移动 dis:移动距离
169
-                color:填充颜色 xStart/yStart:选定区域左上坐标 xEnd/yEnd:选定区域右下坐标*/
188
+//
189
+// Move a screen area
190
+//  mode: 0, circle shift; 1, translation
191
+//  dir: 0=left, 1=right, 2=up, 3=down
192
+//  dis: Distance
193
+//  color: Fill color
194
+//  xStart/yStart: upper left point
195
+//  xEnd/yEnd: bottom right point
170 196
 void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
171 197
                          uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
172 198
   size_t i = 0;
@@ -181,14 +207,21 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
181 207
   DWIN_Send(i);
182 208
 }
183 209
 
184
-/*----------------------------------------------文本相关函数----------------------------------------------*/
185
-/*画面显示字符串 widthAdjust:true,自调整字符宽度;false,不调整字符宽度 bShow:true,显示背景色;false,不显示背景色 size:字号大小
186
-                  color:字符颜色 bColor:背景颜色 x/y:字符串左上坐标 *string:字符串*/
210
+/*---------------------------------------- Text related functions ----------------------------------------*/
211
+
212
+// Draw a string
213
+//  widthAdjust: true=self-adjust character width; false=no adjustment
214
+//  bShow: true=display background color; false=don't display background color
215
+//  size: Font size
216
+//  color: Character color
217
+//  bColor: Background color
218
+//  x/y: Upper-left coordinate of the string
219
+//  *string: The string
187 220
 void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
188 221
                       uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) {
189 222
   size_t i = 0;
190 223
   DWIN_Byte(i, 0x11);
191
-  DWIN_Byte(i, (widthAdjust? 0x80:0x00) | (bShow? 0x40:0x00) | size);
224
+  DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
192 225
   DWIN_Word(i, color);
193 226
   DWIN_Word(i, bColor);
194 227
   DWIN_Word(i, x);
@@ -197,13 +230,34 @@ void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
197 230
   DWIN_Send(i);
198 231
 }
199 232
 
200
-/*画面显示正整数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小
201
-                  color:字符颜色 bColor:背景颜色 iNum:位数 x/y:变量左上坐标 value:整型变量*/
233
+void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
234
+                      uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *string) {
235
+  size_t i = 0;
236
+  DWIN_Byte(i, 0x11);
237
+  DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
238
+  DWIN_Word(i, color);
239
+  DWIN_Word(i, bColor);
240
+  DWIN_Word(i, x);
241
+  DWIN_Word(i, y);
242
+  DWIN_String(i, string);
243
+  DWIN_Send(i);
244
+}
245
+
246
+// Draw a positive integer
247
+//  bShow: true=display background color; false=don't display background color
248
+//  zeroFill: true=zero fill; false=no zero fill
249
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
250
+//  size: Font size
251
+//  color: Character color
252
+//  bColor: Background color
253
+//  iNum: Number of digits
254
+//  x/y: Upper-left coordinate
255
+//  value: Integer value
202 256
 void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
203 257
                           uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
204 258
   size_t i = 0;
205 259
   DWIN_Byte(i, 0x14);
206
-  DWIN_Byte(i, (bShow? 0x80:0x00) | (zeroFill? 0x20:0x00) | (zeroMode? 0x10:0x00) | size);
260
+  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
207 261
   DWIN_Word(i, color);
208 262
   DWIN_Word(i, bColor);
209 263
   DWIN_Byte(i, iNum);
@@ -214,7 +268,7 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t
214 268
     for (char count = 0; count < 8; count++) {
215 269
       DWIN_Byte(i, value);
216 270
       value >>= 8;
217
-      if ((value&0xFF) == 0x00) break;
271
+      if (!(value & 0xFF)) break;
218 272
     }
219 273
   #else
220 274
     // Write a big-endian 64 bit integer
@@ -229,14 +283,23 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t
229 283
   DWIN_Send(i);
230 284
 }
231 285
 
232
-/*画面显示浮点数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小
233
-                  color:字符颜色 bColor:背景颜色 iNum:整数位数 fNum:小数位数 x/y:变量左上坐标 value:浮点数变量*/
286
+// Draw a floating point number
287
+//  bShow: true=display background color; false=don't display background color
288
+//  zeroFill: true=zero fill; false=no zero fill
289
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
290
+//  size: Font size
291
+//  color: Character color
292
+//  bColor: Background color
293
+//  iNum: Number of whole digits
294
+//  fNum: Number of decimal digits
295
+//  x/y: Upper-left point
296
+//  value: Float value
234 297
 void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
235 298
                             uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
236 299
   //uint8_t *fvalue = (uint8_t*)&value;
237 300
   size_t i = 0;
238 301
   DWIN_Byte(i, 0x14);
239
-  DWIN_Byte(i, (bShow? 0x80:0x00) | (zeroFill? 0x20:0x00) | (zeroMode? 0x10:0x00) | size);
302
+  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
240 303
   DWIN_Word(i, color);
241 304
   DWIN_Word(i, bColor);
242 305
   DWIN_Byte(i, iNum);
@@ -253,16 +316,21 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_
253 316
   DWIN_Send(i);
254 317
 }
255 318
 
256
-/*----------------------------------------------图片相关函数----------------------------------------------*/
257
-/*jpg图片显示并缓存在#0虚拟显示区 id:图片ID*/
319
+/*---------------------------------------- Picture related functions ----------------------------------------*/
320
+
321
+// Draw JPG and cached in #0 virtual display area
322
+// id: Picture ID
258 323
 void DWIN_JPG_ShowAndCache(const uint8_t id) {
259 324
   size_t i = 0;
260 325
   DWIN_Word(i, 0x2200);
261 326
   DWIN_Byte(i, id);
262
-  DWIN_Send(i);     //AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
327
+  DWIN_Send(i);     // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
263 328
 }
264 329
 
265
-/*图标显示 libID:图标库ID picID:图标ID x/y:图标左上坐标*/
330
+// Draw an Icon
331
+//  libID: Icon library ID
332
+//  picID: Icon ID
333
+//  x/y: Upper-left point
266 334
 void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
267 335
   NOMORE(x, DWIN_WIDTH - 1);
268 336
   NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
@@ -275,7 +343,8 @@ void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
275 343
   DWIN_Send(i);
276 344
 }
277 345
 
278
-/*jpg图片解压到#1虚拟显示区 id:图片ID*/
346
+// Unzip the JPG picture to virtual display area #1
347
+//  id: picture ID
279 348
 void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
280 349
   size_t i = 0;
281 350
   DWIN_Byte(i, 0x25);
@@ -284,7 +353,11 @@ void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
284 353
   DWIN_Send(i);
285 354
 }
286 355
 
287
-/*从虚拟显示区复制区域至当前画面 cacheID:虚拟区号 xStart/yStart:虚拟区左上坐标 xEnd/yEnd:虚拟区右下坐标 x/y:当前画面粘贴坐标*/
356
+// Copy area from virtual display area to current screen
357
+//  cacheID: virtual area number
358
+//  xStart/yStart: Upper-left of virtual area
359
+//  xEnd/yEnd: Lower-right of virtual area
360
+//  x/y: Screen paste point
288 361
 void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
289 362
                          uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
290 363
   size_t i = 0;

Loading…
Cancel
Save