浏览代码

🧑‍💻 Apply F() to some LCD / TFT strings

Followup to #24228
Scott Lahteine 3 年前
父节点
当前提交
640282b8dc

+ 3
- 2
Marlin/src/gcode/queue.cpp 查看文件

@@ -196,14 +196,15 @@ bool GCodeQueue::process_injected_command() {
196 196
  * Never call this from a G-code handler!
197 197
  */
198 198
 void GCodeQueue::enqueue_one_now(const char * const cmd) { while (!enqueue_one(cmd)) idle(); }
199
+void GCodeQueue::enqueue_one_now(FSTR_P const fcmd) { while (!enqueue_one(fcmd)) idle(); }
199 200
 
200 201
 /**
201 202
  * Attempt to enqueue a single G-code command
202 203
  * and return 'true' if successful.
203 204
  */
204
-bool GCodeQueue::enqueue_one(FSTR_P const fgcode) {
205
+bool GCodeQueue::enqueue_one(FSTR_P const fcmd) {
205 206
   size_t i = 0;
206
-  PGM_P p = FTOP(fgcode);
207
+  PGM_P p = FTOP(fcmd);
207 208
   char c;
208 209
   while ((c = pgm_read_byte(&p[i])) && c != '\n') i++;
209 210
   char cmd[i + 1];

+ 2
- 1
Marlin/src/gcode/queue.h 查看文件

@@ -141,12 +141,13 @@ public:
141 141
    * Enqueue and return only when commands are actually enqueued
142 142
    */
143 143
   static void enqueue_one_now(const char * const cmd);
144
+  static void enqueue_one_now(FSTR_P const fcmd);
144 145
 
145 146
   /**
146 147
    * Attempt to enqueue a single G-code command
147 148
    * and return 'true' if successful.
148 149
    */
149
-  static bool enqueue_one(FSTR_P const fgcode);
150
+  static bool enqueue_one(FSTR_P const fcmd);
150 151
 
151 152
   /**
152 153
    * Enqueue with Serial Echo

+ 7
- 3
Marlin/src/lcd/e3v2/common/dwin_api.h 查看文件

@@ -176,9 +176,13 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
176 176
 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);
177 177
 
178 178
 inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, FSTR_P const ftitle) {
179
-  char ctitle[strlen_P(FTOP(ftitle)) + 1];
180
-  strcpy_P(ctitle, FTOP(ftitle));
181
-  DWIN_Draw_String(bShow, size, color, bColor, x, y, ctitle);
179
+  #ifdef __AVR__
180
+    char ctitle[strlen_P(FTOP(ftitle)) + 1];
181
+    strcpy_P(ctitle, FTOP(ftitle));
182
+    DWIN_Draw_String(bShow, size, color, bColor, x, y, ctitle);
183
+  #else
184
+    DWIN_Draw_String(bShow, size, color, bColor, x, y, FTOP(ftitle));
185
+  #endif
182 186
 }
183 187
 
184 188
 // Draw a positive integer

+ 7
- 3
Marlin/src/lcd/e3v2/creality/dwin.cpp 查看文件

@@ -4307,9 +4307,13 @@ void DWIN_StatusChanged(const char * const cstr/*=nullptr*/) {
4307 4307
 }
4308 4308
 
4309 4309
 void DWIN_StatusChanged(FSTR_P const fstr) {
4310
-  char str[strlen_P(FTOP(fstr)) + 1];
4311
-  strcpy_P(str, FTOP(fstr));
4312
-  DWIN_StatusChanged(str);
4310
+  #ifdef __AVR__
4311
+    char str[strlen_P(FTOP(fstr)) + 1];
4312
+    strcpy_P(str, FTOP(fstr));
4313
+    DWIN_StatusChanged(str);
4314
+  #else
4315
+    DWIN_StatusChanged(FTOP(fstr));
4316
+  #endif
4313 4317
 }
4314 4318
 
4315 4319
 #endif // DWIN_CREALITY_LCD

+ 6
- 6
Marlin/src/lcd/e3v2/marlinui/ui_common.cpp 查看文件

@@ -274,7 +274,7 @@ void MarlinUI::draw_status_message(const bool blink) {
274 274
 
275 275
       dwin_font.solid = false;
276 276
       dwin_font.fg = Color_White;
277
-      dwin_string.set("E");
277
+      dwin_string.set('E');
278 278
       dwin_string.add('1' + extruder);
279 279
       dwin_string.add(' ');
280 280
       dwin_string.add(i16tostr3rj(thermalManager.degHotend(extruder)));
@@ -282,7 +282,7 @@ void MarlinUI::draw_status_message(const bool blink) {
282 282
       if (get_blink() || !thermalManager.heater_idle[thermalManager.idle_index_for_id(extruder)].timed_out)
283 283
         dwin_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
284 284
       else
285
-        dwin_string.add(PSTR("    "));
285
+        dwin_string.add(F("    "));
286 286
 
287 287
       lcd_moveto(LCD_WIDTH - dwin_string.length, row);
288 288
       lcd_put_dwin_string();
@@ -540,11 +540,11 @@ void MarlinUI::draw_status_message(const bool blink) {
540 540
       lcd_put_u8str(ftostr52(lpos.y));
541 541
 
542 542
       // Print plot position
543
-      dwin_string.set("(");
543
+      dwin_string.set('(');
544 544
       dwin_string.add(i8tostr3rj(x_plot));
545
-      dwin_string.add(",");
545
+      dwin_string.add(',');
546 546
       dwin_string.add(i8tostr3rj(y_plot));
547
-      dwin_string.add(")");
547
+      dwin_string.add(')');
548 548
       lcd_moveto(
549 549
         TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
550 550
         TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 2, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 1)
@@ -556,7 +556,7 @@ void MarlinUI::draw_status_message(const bool blink) {
556 556
       if (!isnan(bedlevel.z_values[x_plot][y_plot]))
557 557
         dwin_string.add(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
558 558
       else
559
-        dwin_string.add(PSTR(" -----"));
559
+        dwin_string.add(F(" -----"));
560 560
       lcd_moveto(
561 561
         TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
562 562
         TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 1, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 2)

+ 10
- 10
Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp 查看文件

@@ -88,7 +88,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
88 88
 
89 89
     // For E_TOTAL there may be some characters to cover up
90 90
     if (BOTH(DWIN_MARLINUI_PORTRAIT, LCD_SHOW_E_TOTAL) && axis == X_AXIS)
91
-      dwin_string.add("   ");
91
+      dwin_string.add(F("   "));
92 92
 
93 93
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string()));
94 94
 
@@ -117,7 +117,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
117 117
 
118 118
     // For E_TOTAL there may be some characters to cover up
119 119
     if (ENABLED(LCD_SHOW_E_TOTAL) && (!ui.did_first_redraw  || ui.old_is_printing != print_job_timer.isRunning()) && axis == X_AXIS)
120
-      dwin_string.add("   ");
120
+      dwin_string.add(F("   "));
121 121
 
122 122
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string()));
123 123
 
@@ -133,7 +133,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
133 133
 
134 134
       if (!ui.did_first_redraw) {
135 135
         // Extra spaces to erase previous value
136
-        dwin_string.set("E         ");
136
+        dwin_string.set(F("E         "));
137 137
         DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string()));
138 138
       }
139 139
 
@@ -146,7 +146,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
146 146
     #else // !DWIN_MARLINUI_PORTRAIT
147 147
 
148 148
       if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) {
149
-        dwin_string.set("E ");
149
+        dwin_string.set(F("E "));
150 150
         DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string()));
151 151
       }
152 152
 
@@ -176,7 +176,7 @@ FORCE_INLINE void _draw_fan_status(const uint16_t x, const uint16_t y) {
176 176
   else {
177 177
     DWIN_ICON_AnimationControl(0x0000); // disable all icon animations (this is the only one)
178 178
     DWIN_ICON_Show(ICON, ICON_Fan0, x + fanx, y);
179
-    dwin_string.set(PSTR("    "));
179
+    dwin_string.set(F("    "));
180 180
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string()));
181 181
   }
182 182
 }
@@ -289,7 +289,7 @@ FORCE_INLINE void _draw_feedrate_status(const char *value, uint16_t x, uint16_t
289 289
   }
290 290
 
291 291
   dwin_string.set(value);
292
-  dwin_string.add(PSTR("%"));
292
+  dwin_string.add('%');
293 293
   DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 14, y, S(dwin_string.string()));
294 294
 }
295 295
 
@@ -396,7 +396,7 @@ void MarlinUI::draw_status_screen() {
396 396
     // landscape mode shows both elapsed and remaining (if SHOW_REMAINING_TIME)
397 397
     time = print_job_timer.duration();
398 398
     time.toDigital(buffer);
399
-    dwin_string.set(" ");
399
+    dwin_string.set(' ');
400 400
     dwin_string.add(buffer);
401 401
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 230, 170, S(dwin_string.string()));
402 402
 
@@ -405,7 +405,7 @@ void MarlinUI::draw_status_screen() {
405 405
         time = get_remaining_time();
406 406
         DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(" R "));
407 407
         if (print_job_timer.isPaused() && blink)
408
-          dwin_string.set("     ");
408
+          dwin_string.set(F("     "));
409 409
         else {
410 410
           time.toDigital(buffer);
411 411
           dwin_string.set(buffer);
@@ -413,7 +413,7 @@ void MarlinUI::draw_status_screen() {
413 413
         DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string()));
414 414
       }
415 415
       else if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) {
416
-        dwin_string.set("        ");
416
+        dwin_string.set(F("        "));
417 417
         DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string()));
418 418
       }
419 419
     #endif
@@ -449,7 +449,7 @@ void MarlinUI::draw_status_screen() {
449 449
 
450 450
       #if ENABLED(SHOW_SD_PERCENT)
451 451
         dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))));
452
-        dwin_string.add(PSTR("%"));
452
+        dwin_string.add('%');
453 453
         DWIN_Draw_String(
454 454
           false, font16x32, Percent_Color, Color_Bg_Black,
455 455
           pb_left + (pb_width - dwin_string.length * 16) / 2,

+ 4
- 9
Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp 查看文件

@@ -474,13 +474,8 @@ void DGUSScreenHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr
474 474
 
475 475
 void DGUSScreenHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr) {
476 476
   DEBUG_ECHOLNPGM("HandleMotorLockUnlock");
477
-
478
-  char buf[4];
479 477
   const int16_t lock = swap16(*(uint16_t*)val_ptr);
480
-  strcpy_P(buf, lock ? PSTR("M18") : PSTR("M17"));
481
-
482
-  //DEBUG_ECHOPGM(" ", buf);
483
-  queue.enqueue_one_now(buf);
478
+  queue.enqueue_one_now(lock ? F("M18") : F("M17"));
484 479
 }
485 480
 
486 481
 void DGUSScreenHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) {
@@ -552,23 +547,23 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo
552 547
           #if HAS_HOTEND
553 548
             case VP_PID_AUTOTUNE_E0: // Autotune Extruder 0
554 549
               sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E0);
550
+              queue.enqueue_one_now(buf);
555 551
               break;
556 552
           #endif
557 553
           #if HAS_MULTI_HOTEND
558 554
             case VP_PID_AUTOTUNE_E1:
559 555
               sprintf_P(buf, PSTR("M303 E%d C5 S210 U1"), ExtUI::extruder_t::E1);
556
+              queue.enqueue_one_now(buf);
560 557
               break;
561 558
           #endif
562 559
         #endif
563 560
         #if ENABLED(PIDTEMPBED)
564 561
           case VP_PID_AUTOTUNE_BED:
565
-            strcpy_P(buf, PSTR("M303 E-1 C5 S70 U1"));
562
+            queue.enqueue_one_now(F("M303 E-1 C5 S70 U1"));
566 563
             break;
567 564
         #endif
568 565
     }
569 566
 
570
-    if (buf[0]) queue.enqueue_one_now(buf);
571
-
572 567
     #if ENABLED(DGUS_UI_WAITING)
573 568
       sendinfoscreen(F("PID is autotuning"), F("please wait"), NUL_STR, NUL_STR, true, true, true, true);
574 569
       GotoScreen(DGUSLCD_SCREEN_WAITING);

+ 13
- 9
Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp 查看文件

@@ -32,12 +32,12 @@ using namespace Theme;
32 32
 #define GRID_COLS 2
33 33
 #define GRID_ROWS 9
34 34
 
35
-void BioPrintingDialogBox::draw_status_message(draw_mode_t what, const char *message) {
35
+void BioPrintingDialogBox::draw_status_message(draw_mode_t what, const char *cmsg) {
36 36
   if (what & BACKGROUND) {
37 37
     CommandProcessor cmd;
38 38
     cmd.cmd(COLOR_RGB(bg_text_enabled))
39 39
        .tag(0);
40
-    draw_text_box(cmd, BTN_POS(1,2), BTN_SIZE(2,2), message, OPT_CENTER, font_large);
40
+    draw_text_box(cmd, BTN_POS(1,2), BTN_SIZE(2,2), cmsg, OPT_CENTER, font_large);
41 41
   }
42 42
 }
43 43
 
@@ -105,26 +105,30 @@ bool BioPrintingDialogBox::onTouchEnd(uint8_t tag) {
105 105
   return true;
106 106
 }
107 107
 
108
-void BioPrintingDialogBox::setStatusMessage(FSTR_P message) {
109
-  char buff[strlen_P(FTOP(message)) + 1];
110
-  strcpy_P(buff, FTOP(message));
111
-  setStatusMessage(buff);
108
+void BioPrintingDialogBox::setStatusMessage(FSTR_P fmsg) {
109
+  #ifdef __AVR__
110
+    char buff[strlen_P(FTOP(fmsg)) + 1];
111
+    strcpy_P(buff, FTOP(fmsg));
112
+    setStatusMessage(buff);
113
+  #else
114
+    setStatusMessage(FTOP(fmsg));
115
+  #endif
112 116
 }
113 117
 
114
-void BioPrintingDialogBox::setStatusMessage(const char *message) {
118
+void BioPrintingDialogBox::setStatusMessage(const char *cmsg) {
115 119
   CommandProcessor cmd;
116 120
   cmd.cmd(CMD_DLSTART)
117 121
      .cmd(CLEAR_COLOR_RGB(bg_color))
118 122
      .cmd(CLEAR(true,true,true));
119 123
 
120
-  draw_status_message(BACKGROUND, message);
124
+  draw_status_message(BACKGROUND, cmsg);
121 125
   draw_progress(BACKGROUND);
122 126
   draw_time_remaining(BACKGROUND);
123 127
   draw_interaction_buttons(BACKGROUND);
124 128
   storeBackground();
125 129
 
126 130
   #if ENABLED(TOUCH_UI_DEBUG)
127
-    SERIAL_ECHO_MSG("New status message: ", message);
131
+    SERIAL_ECHO_MSG("New status message: ", cmsg);
128 132
   #endif
129 133
 
130 134
   if (AT_SCREEN(BioPrintingDialogBox))

+ 3
- 3
Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp 查看文件

@@ -122,7 +122,7 @@ void StatusScreen::draw_temperature(draw_mode_t what) {
122 122
 
123 123
       ui.bounds(POLY(bed_temp), x, y, h, v);
124 124
       cmd.text(x, y, h, v, str);
125
-      #endif
125
+    #endif
126 126
   }
127 127
 }
128 128
 
@@ -354,8 +354,8 @@ bool StatusScreen::onTouchHeld(uint8_t tag) {
354 354
   return false;
355 355
 }
356 356
 
357
-void StatusScreen::setStatusMessage(FSTR_P pstr) {
358
-  BioPrintingDialogBox::setStatusMessage(pstr);
357
+void StatusScreen::setStatusMessage(FSTR_P fstr) {
358
+  BioPrintingDialogBox::setStatusMessage(fstr);
359 359
 }
360 360
 
361 361
 void StatusScreen::setStatusMessage(const char * const str) {

+ 7
- 3
Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp 查看文件

@@ -136,9 +136,13 @@ namespace FTDI {
136 136
   }
137 137
 
138 138
   void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P fstr, uint16_t options, uint8_t font) {
139
-    char str[strlen_P(FTOP(fstr)) + 1];
140
-    strcpy_P(str, FTOP(fstr));
141
-    draw_text_box(cmd, x, y, w, h, (const char*) str, options, font);
139
+    #ifdef __AVR__
140
+      char str[strlen_P(FTOP(fstr)) + 1];
141
+      strcpy_P(str, FTOP(fstr));
142
+      draw_text_box(cmd, x, y, w, h, (const char*) str, options, font);
143
+    #else
144
+      draw_text_box(cmd, x, y, w, h, FTOP(fstr), options, font);
145
+    #endif
142 146
   }
143 147
 } // namespace FTDI
144 148
 

+ 7
- 3
Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp 查看文件

@@ -192,9 +192,13 @@
192 192
   }
193 193
 
194 194
   uint16_t FTDI::get_utf8_text_width(FSTR_P fstr, font_size_t fs) {
195
-    char str[strlen_P(FTOP(fstr)) + 1];
196
-    strcpy_P(str, FTOP(fstr));
197
-    return get_utf8_text_width(str, fs);
195
+    #ifdef __AVR__
196
+      char str[strlen_P(FTOP(fstr)) + 1];
197
+      strcpy_P(str, FTOP(fstr));
198
+      return get_utf8_text_width(str, fs);
199
+    #else
200
+      return get_utf8_text_width(FTOP(fstr), fs);
201
+    #endif
198 202
   }
199 203
 
200 204
    /**

+ 2
- 3
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/dialog_box_base_class.cpp 查看文件

@@ -32,7 +32,7 @@ using namespace Theme;
32 32
 #define GRID_ROWS 8
33 33
 
34 34
 template<typename T>
35
-void DialogBoxBaseClass::drawMessage(T message, int16_t font) {
35
+void DialogBoxBaseClass::drawMessage(T message, const int16_t font) {
36 36
   CommandProcessor cmd;
37 37
   cmd.cmd(CMD_DLSTART)
38 38
      .cmd(CLEAR_COLOR_RGB(bg_color))
@@ -43,8 +43,7 @@ void DialogBoxBaseClass::drawMessage(T message, int16_t font) {
43 43
   cmd.colors(normal_btn);
44 44
 }
45 45
 
46
-template void DialogBoxBaseClass::drawMessage(const char *, int16_t font);
47
-template void DialogBoxBaseClass::drawMessage(FSTR_P, int16_t font);
46
+template void DialogBoxBaseClass::drawMessage(PGM_P const, const int16_t);
48 47
 
49 48
 void DialogBoxBaseClass::drawYesNoButtons(uint8_t default_btn) {
50 49
   CommandProcessor cmd;

+ 5
- 2
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/dialog_box_base_class.h 查看文件

@@ -27,12 +27,15 @@
27 27
 
28 28
 class DialogBoxBaseClass : public BaseScreen {
29 29
   protected:
30
-    template<typename T> static void drawMessage(T, int16_t font = 0);
30
+    template<typename T> static void drawMessage(T, const int16_t font=0);
31
+    static void drawMessage(FSTR_P const fstr, const int16_t font=0) { drawMessage(FTOP(fstr), font); }
32
+
31 33
     template<typename T> static void drawButton(T);
32 34
     static void drawYesNoButtons(uint8_t default_btn = 0);
33 35
     static void drawOkayButton();
34 36
 
35
-    static void onRedraw(draw_mode_t) {};
37
+    static void onRedraw(draw_mode_t) {}
38
+
36 39
   public:
37 40
     static bool onTouchEnd(uint8_t tag);
38 41
     static void onIdle();

+ 8
- 4
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp 查看文件

@@ -332,10 +332,14 @@ void StatusScreen::draw_status_message(draw_mode_t what, const char *message) {
332 332
   }
333 333
 }
334 334
 
335
-void StatusScreen::setStatusMessage(FSTR_P message) {
336
-  char buff[strlen_P(FTOP(message)) + 1];
337
-  strcpy_P(buff, FTOP(message));
338
-  setStatusMessage((const char *) buff);
335
+void StatusScreen::setStatusMessage(FSTR_P fmsg) {
336
+  #ifdef __AVR__
337
+    char buff[strlen_P(FTOP(fmsg)) + 1];
338
+    strcpy_P(buff, FTOP(fmsg));
339
+    setStatusMessage((const char *)buff);
340
+  #else
341
+    setStatusMessage(FTOP(fmsg));
342
+  #endif
339 343
 }
340 344
 
341 345
 void StatusScreen::setStatusMessage(const char *message) {

+ 10
- 6
Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp 查看文件

@@ -711,12 +711,16 @@ void disp_assets_update() {
711 711
 }
712 712
 
713 713
 void disp_assets_update_progress(FSTR_P const fmsg) {
714
-  static constexpr int buflen = 30;
715
-  char buf[buflen];
716
-  memset(buf, ' ', buflen);
717
-  strncpy_P(buf, FTOP(fmsg), buflen - 1);
718
-  buf[buflen - 1] = '\0';
719
-  disp_string(100, 165, buf, 0xFFFF, 0x0000);
714
+  #ifdef __AVR__
715
+    static constexpr int buflen = 30;
716
+    char buf[buflen];
717
+    memset(buf, ' ', buflen);
718
+    strncpy_P(buf, FTOP(fmsg), buflen - 1);
719
+    buf[buflen - 1] = '\0';
720
+    disp_string(100, 165, buf, 0xFFFF, 0x0000);
721
+  #else
722
+    disp_string(100, 165, FTOP(fmsg), 0xFFFF, 0x0000);
723
+  #endif
720 724
 }
721 725
 
722 726
 #if BOTH(MKS_TEST, SDSUPPORT)

+ 14
- 6
Marlin/src/lcd/extui/ui_api.cpp 查看文件

@@ -1112,15 +1112,23 @@ namespace ExtUI {
1112 1112
 
1113 1113
   // Simplest approach is to make an SRAM copy
1114 1114
   void onUserConfirmRequired(FSTR_P const fstr) {
1115
-    char msg[strlen_P(FTOP(fstr)) + 1];
1116
-    strcpy_P(msg, FTOP(fstr));
1117
-    onUserConfirmRequired(msg);
1115
+    #ifdef __AVR__
1116
+      char msg[strlen_P(FTOP(fstr)) + 1];
1117
+      strcpy_P(msg, FTOP(fstr));
1118
+      onUserConfirmRequired(msg);
1119
+    #else
1120
+      onUserConfirmRequired(FTOP(fstr));
1121
+    #endif
1118 1122
   }
1119 1123
 
1120 1124
   void onStatusChanged(FSTR_P const fstr) {
1121
-    char msg[strlen_P(FTOP(fstr)) + 1];
1122
-    strcpy_P(msg, FTOP(fstr));
1123
-    onStatusChanged(msg);
1125
+    #ifdef __AVR__
1126
+      char msg[strlen_P(FTOP(fstr)) + 1];
1127
+      strcpy_P(msg, FTOP(fstr));
1128
+      onStatusChanged(msg);
1129
+    #else
1130
+      onStatusChanged(FTOP(fstr));
1131
+    #endif
1124 1132
   }
1125 1133
 
1126 1134
   FileList::FileList() { refresh(); }

+ 8
- 4
Marlin/src/lcd/menu/menu.h 查看文件

@@ -113,11 +113,15 @@ class MenuItem_confirm : public MenuItemBase {
113 113
     static void select_screen(
114 114
       FSTR_P const yes, FSTR_P const no,
115 115
       selectFunc_t yesFunc, selectFunc_t noFunc,
116
-      FSTR_P const pref, FSTR_P const string, FSTR_P const suff=nullptr
116
+      FSTR_P const pref, FSTR_P const fstr, FSTR_P const suff=nullptr
117 117
     ) {
118
-      char str[strlen_P(FTOP(string)) + 1];
119
-      strcpy_P(str, FTOP(string));
120
-      select_screen(yes, no, yesFunc, noFunc, pref, str, suff);
118
+      #ifdef __AVR__
119
+        char str[strlen_P(FTOP(fstr)) + 1];
120
+        strcpy_P(str, FTOP(fstr));
121
+        select_screen(yes, no, yesFunc, noFunc, pref, str, suff);
122
+      #else
123
+        select_screen(yes, no, yesFunc, noFunc, pref, FTOP(fstr), suff);
124
+      #endif
121 125
     }
122 126
     // Shortcut for prompt with "NO"/ "YES" labels
123 127
     FORCE_INLINE static void confirm_screen(selectFunc_t yesFunc, selectFunc_t noFunc, FSTR_P const pref, const char * const string=nullptr, FSTR_P const suff=nullptr) {

+ 18
- 10
Marlin/src/lcd/tft/ui_1024x600.cpp 查看文件

@@ -271,19 +271,25 @@ void MarlinUI::draw_status_screen() {
271 271
   else {
272 272
     tft.add_text(200, 3, COLOR_AXIS_HOMED , "X");
273 273
     const bool nhx = axis_should_home(X_AXIS);
274
-    tft_string.set(blink && nhx ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
274
+    if (blink && nhx)
275
+      tft_string.set('?');
276
+    else
277
+      tft_string.set(ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
275 278
     tft.add_text(300 - tft_string.width(), 3, nhx ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
276 279
 
277 280
     tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y");
278 281
     const bool nhy = axis_should_home(Y_AXIS);
279
-    tft_string.set(blink && nhy ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
282
+    if (blink && nhy)
283
+      tft_string.set('?');
284
+    else
285
+      tft_string.set(ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
280 286
     tft.add_text(600 - tft_string.width(), 3, nhy ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
281 287
   }
282 288
   tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z");
283 289
   uint16_t offset = 32;
284 290
   const bool nhz = axis_should_home(Z_AXIS);
285 291
   if (blink && nhz)
286
-    tft_string.set("?");
292
+    tft_string.set('?');
287 293
   else {
288 294
     const float z = LOGICAL_Z_POSITION(current_position.z);
289 295
     tft_string.set(ftostr52sp((int16_t)z));
@@ -479,7 +485,7 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con
479 485
     tft_string.add(' ');
480 486
     tft_string.add(i16tostr3rj(thermalManager.wholeDegHotend(extruder)));
481 487
     tft_string.add(LCD_STR_DEGREE);
482
-    tft_string.add(" / ");
488
+    tft_string.add(F(" / "));
483 489
     tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
484 490
     tft_string.add(LCD_STR_DEGREE);
485 491
     tft_string.trim();
@@ -607,19 +613,19 @@ static void quick_feedback() {
607 613
 #define CUR_STEP_VALUE_WIDTH 104
608 614
 static void drawCurStepValue() {
609 615
   tft_string.set(ftostr52sp(motionAxisState.currentStepSize));
610
-  tft_string.add("mm");
616
+  tft_string.add(F("mm"));
611 617
   tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT);
612 618
   tft.set_background(COLOR_BACKGROUND);
613 619
   tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string);
614 620
 }
615 621
 
616 622
 static void drawCurZSelection() {
617
-  tft_string.set("Z");
623
+  tft_string.set('Z');
618 624
   tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34);
619 625
   tft.set_background(COLOR_BACKGROUND);
620 626
   tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
621 627
   tft.queue.sync();
622
-  tft_string.set("Offset");
628
+  tft_string.set(F("Offset"));
623 629
   tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
624 630
   tft.set_background(COLOR_BACKGROUND);
625 631
   if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
@@ -630,17 +636,19 @@ static void drawCurZSelection() {
630 636
 static void drawCurESelection() {
631 637
   tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
632 638
   tft.set_background(COLOR_BACKGROUND);
633
-  tft_string.set("E");
639
+  tft_string.set('E');
634 640
   tft.add_text(0, 0, E_BTN_COLOR , tft_string);
635 641
   tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
636 642
 }
637 643
 
638
-static void drawMessage(const char *msg) {
644
+static void drawMessage(PGM_P const msg) {
639 645
   tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34);
640 646
   tft.set_background(COLOR_BACKGROUND);
641 647
   tft.add_text(0, 0, COLOR_YELLOW, msg);
642 648
 }
643 649
 
650
+static void drawMessage(FSTR_P const fmsg) { drawMessage(FTOP(fmsg)); }
651
+
644 652
 static void drawAxisValue(const AxisEnum axis) {
645 653
   const float value = (
646 654
     TERN_(HAS_BED_PROBE, axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? probe.offset.z :)
@@ -666,7 +674,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
666 674
 
667 675
   #if ENABLED(PREVENT_COLD_EXTRUSION)
668 676
     if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) {
669
-      drawMessage("Too cold");
677
+      drawMessage(F("Too cold"));
670 678
       return;
671 679
     }
672 680
   #endif

+ 13
- 11
Marlin/src/lcd/tft/ui_320x240.cpp 查看文件

@@ -282,7 +282,7 @@ void MarlinUI::draw_status_screen() {
282 282
   const bool nhz = axis_should_home(Z_AXIS);
283 283
   uint16_t offset = 25;
284 284
   if (blink && nhz)
285
-    tft_string.set("?");
285
+    tft_string.set('?');
286 286
   else {
287 287
     const float z = LOGICAL_Z_POSITION(current_position.z);
288 288
     tft_string.set(ftostr52sp((int16_t)z));
@@ -461,7 +461,7 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con
461 461
     tft_string.add(' ');
462 462
     tft_string.add(i16tostr3rj(thermalManager.wholeDegHotend(extruder)));
463 463
     tft_string.add(LCD_STR_DEGREE);
464
-    tft_string.add(" / ");
464
+    tft_string.add(F(" / "));
465 465
     tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
466 466
     tft_string.add(LCD_STR_DEGREE);
467 467
     tft_string.trim();
@@ -593,19 +593,19 @@ static void drawCurStepValue() {
593 593
   tft.set_background(COLOR_BACKGROUND);
594 594
   tft.add_text(CUR_STEP_VALUE_WIDTH - tft_string.width(), 0, COLOR_AXIS_HOMED, tft_string);
595 595
   tft.queue.sync();
596
-  tft_string.set("mm");
596
+  tft_string.set(F("mm"));
597 597
   tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y + 20, CUR_STEP_VALUE_WIDTH, 20);
598 598
   tft.set_background(COLOR_BACKGROUND);
599 599
   tft.add_text(CUR_STEP_VALUE_WIDTH - tft_string.width(), 0, COLOR_AXIS_HOMED, tft_string);
600 600
 }
601 601
 
602 602
 static void drawCurZSelection() {
603
-  tft_string.set("Z");
603
+  tft_string.set('Z');
604 604
   tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 20);
605 605
   tft.set_background(COLOR_BACKGROUND);
606 606
   tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
607 607
   tft.queue.sync();
608
-  tft_string.set("Offset");
608
+  tft_string.set(F("Offset"));
609 609
   tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 20);
610 610
   tft.set_background(COLOR_BACKGROUND);
611 611
   if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
@@ -616,7 +616,7 @@ static void drawCurZSelection() {
616 616
 static void drawCurESelection() {
617 617
   tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
618 618
   tft.set_background(COLOR_BACKGROUND);
619
-  tft_string.set("E");
619
+  tft_string.set('E');
620 620
   tft.add_text(0, 0, E_BTN_COLOR , tft_string);
621 621
   tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
622 622
 }
@@ -627,6 +627,8 @@ static void drawMessage(PGM_P const msg) {
627 627
   tft.add_text(0, 0, COLOR_YELLOW, msg);
628 628
 }
629 629
 
630
+static void drawMessage(FSTR_P const fmsg) { drawMessage(FTOP(fmsg)); }
631
+
630 632
 static void drawAxisValue(const AxisEnum axis) {
631 633
   const float value = (
632 634
     TERN_(HAS_BED_PROBE, axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? probe.offset.z :)
@@ -652,7 +654,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
652 654
 
653 655
   #if ENABLED(PREVENT_COLD_EXTRUSION)
654 656
     if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) {
655
-      drawMessage(PSTR("Too cold"));
657
+      drawMessage(F("Too cold"));
656 658
       return;
657 659
     }
658 660
   #endif
@@ -679,18 +681,18 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
679 681
         drawAxisValue(axis);
680 682
       }
681 683
       else {
682
-        drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
684
+        drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS));
683 685
       }
684 686
     #elif HAS_BED_PROBE
685 687
       // only change probe.offset.z
686 688
       probe.offset.z += diff;
687 689
       if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) {
688 690
         current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN;
689
-        drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
691
+        drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS));
690 692
       }
691 693
       else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) {
692 694
         current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX;
693
-        drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
695
+        drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS));
694 696
       }
695 697
       else {
696 698
         drawMessage(NUL_STR); // clear the error
@@ -752,7 +754,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); }
752 754
 
753 755
   static void do_home() {
754 756
     quick_feedback();
755
-    drawMessage(GET_TEXT(MSG_LEVEL_BED_HOMING));
757
+    drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING));
756 758
     queue.inject_P(G28_STR);
757 759
     // Disable touch until home is done
758 760
     TERN_(HAS_TFT_XPT2046, touch.disable());

+ 13
- 11
Marlin/src/lcd/tft/ui_480x320.cpp 查看文件

@@ -283,7 +283,7 @@ void MarlinUI::draw_status_screen() {
283 283
   uint16_t offset = 32;
284 284
   const bool nhz = axis_should_home(Z_AXIS);
285 285
   if (blink && nhz)
286
-    tft_string.set("?");
286
+    tft_string.set('?');
287 287
   else {
288 288
     const float z = LOGICAL_Z_POSITION(current_position.z);
289 289
     tft_string.set(ftostr52sp((int16_t)z));
@@ -466,7 +466,7 @@ void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, con
466 466
     tft_string.add(' ');
467 467
     tft_string.add(i16tostr3rj(thermalManager.wholeDegHotend(extruder)));
468 468
     tft_string.add(LCD_STR_DEGREE);
469
-    tft_string.add(" / ");
469
+    tft_string.add(F(" / "));
470 470
     tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
471 471
     tft_string.add(LCD_STR_DEGREE);
472 472
     tft_string.trim();
@@ -594,19 +594,19 @@ static void quick_feedback() {
594 594
 #define CUR_STEP_VALUE_WIDTH 104
595 595
 static void drawCurStepValue() {
596 596
   tft_string.set(ftostr52sp(motionAxisState.currentStepSize));
597
-  tft_string.add("mm");
597
+  tft_string.add(F("mm"));
598 598
   tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT);
599 599
   tft.set_background(COLOR_BACKGROUND);
600 600
   tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string);
601 601
 }
602 602
 
603 603
 static void drawCurZSelection() {
604
-  tft_string.set("Z");
604
+  tft_string.set('Z');
605 605
   tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34);
606 606
   tft.set_background(COLOR_BACKGROUND);
607 607
   tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
608 608
   tft.queue.sync();
609
-  tft_string.set("Offset");
609
+  tft_string.set(F("Offset"));
610 610
   tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
611 611
   tft.set_background(COLOR_BACKGROUND);
612 612
   if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
@@ -617,7 +617,7 @@ static void drawCurZSelection() {
617 617
 static void drawCurESelection() {
618 618
   tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
619 619
   tft.set_background(COLOR_BACKGROUND);
620
-  tft_string.set("E");
620
+  tft_string.set('E');
621 621
   tft.add_text(0, 0, E_BTN_COLOR , tft_string);
622 622
   tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
623 623
 }
@@ -628,6 +628,8 @@ static void drawMessage(PGM_P const msg) {
628 628
   tft.add_text(0, 0, COLOR_YELLOW, msg);
629 629
 }
630 630
 
631
+static void drawMessage(FSTR_P const fmsg) { drawMessage(FTOP(fmsg)); }
632
+
631 633
 static void drawAxisValue(const AxisEnum axis) {
632 634
   const float value = (
633 635
     TERN_(HAS_BED_PROBE, axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? probe.offset.z :)
@@ -653,7 +655,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
653 655
 
654 656
   #if ENABLED(PREVENT_COLD_EXTRUSION)
655 657
     if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) {
656
-      drawMessage(PSTR("Too cold"));
658
+      drawMessage(F("Too cold"));
657 659
       return;
658 660
     }
659 661
   #endif
@@ -680,18 +682,18 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
680 682
         drawAxisValue(axis);
681 683
       }
682 684
       else {
683
-        drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
685
+        drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS));
684 686
       }
685 687
     #elif HAS_BED_PROBE
686 688
       // only change probe.offset.z
687 689
       probe.offset.z += diff;
688 690
       if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) {
689 691
         current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN;
690
-        drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
692
+        drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS));
691 693
       }
692 694
       else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) {
693 695
         current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX;
694
-        drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
696
+        drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS));
695 697
       }
696 698
       else {
697 699
         drawMessage(NUL_STR); // clear the error
@@ -753,7 +755,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); }
753 755
 
754 756
   static void do_home() {
755 757
     quick_feedback();
756
-    drawMessage(GET_TEXT(MSG_LEVEL_BED_HOMING));
758
+    drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING));
757 759
     queue.inject_P(G28_STR);
758 760
     // Disable touch until home is done
759 761
     TERN_(HAS_TFT_XPT2046, touch.disable());

正在加载...
取消
保存