瀏覽代碼

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

Followup to #24228
Scott Lahteine 3 年之前
父節點
當前提交
640282b8dc

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

196
  * Never call this from a G-code handler!
196
  * Never call this from a G-code handler!
197
  */
197
  */
198
 void GCodeQueue::enqueue_one_now(const char * const cmd) { while (!enqueue_one(cmd)) idle(); }
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
  * Attempt to enqueue a single G-code command
202
  * Attempt to enqueue a single G-code command
202
  * and return 'true' if successful.
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
   size_t i = 0;
206
   size_t i = 0;
206
-  PGM_P p = FTOP(fgcode);
207
+  PGM_P p = FTOP(fcmd);
207
   char c;
208
   char c;
208
   while ((c = pgm_read_byte(&p[i])) && c != '\n') i++;
209
   while ((c = pgm_read_byte(&p[i])) && c != '\n') i++;
209
   char cmd[i + 1];
210
   char cmd[i + 1];

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

141
    * Enqueue and return only when commands are actually enqueued
141
    * Enqueue and return only when commands are actually enqueued
142
    */
142
    */
143
   static void enqueue_one_now(const char * const cmd);
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
    * Attempt to enqueue a single G-code command
147
    * Attempt to enqueue a single G-code command
147
    * and return 'true' if successful.
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
    * Enqueue with Serial Echo
153
    * Enqueue with Serial Echo

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

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);
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
 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) {
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
 // Draw a positive integer
188
 // Draw a positive integer

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

4307
 }
4307
 }
4308
 
4308
 
4309
 void DWIN_StatusChanged(FSTR_P const fstr) {
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
 #endif // DWIN_CREALITY_LCD
4319
 #endif // DWIN_CREALITY_LCD

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

274
 
274
 
275
       dwin_font.solid = false;
275
       dwin_font.solid = false;
276
       dwin_font.fg = Color_White;
276
       dwin_font.fg = Color_White;
277
-      dwin_string.set("E");
277
+      dwin_string.set('E');
278
       dwin_string.add('1' + extruder);
278
       dwin_string.add('1' + extruder);
279
       dwin_string.add(' ');
279
       dwin_string.add(' ');
280
       dwin_string.add(i16tostr3rj(thermalManager.degHotend(extruder)));
280
       dwin_string.add(i16tostr3rj(thermalManager.degHotend(extruder)));
282
       if (get_blink() || !thermalManager.heater_idle[thermalManager.idle_index_for_id(extruder)].timed_out)
282
       if (get_blink() || !thermalManager.heater_idle[thermalManager.idle_index_for_id(extruder)].timed_out)
283
         dwin_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
283
         dwin_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
284
       else
284
       else
285
-        dwin_string.add(PSTR("    "));
285
+        dwin_string.add(F("    "));
286
 
286
 
287
       lcd_moveto(LCD_WIDTH - dwin_string.length, row);
287
       lcd_moveto(LCD_WIDTH - dwin_string.length, row);
288
       lcd_put_dwin_string();
288
       lcd_put_dwin_string();
540
       lcd_put_u8str(ftostr52(lpos.y));
540
       lcd_put_u8str(ftostr52(lpos.y));
541
 
541
 
542
       // Print plot position
542
       // Print plot position
543
-      dwin_string.set("(");
543
+      dwin_string.set('(');
544
       dwin_string.add(i8tostr3rj(x_plot));
544
       dwin_string.add(i8tostr3rj(x_plot));
545
-      dwin_string.add(",");
545
+      dwin_string.add(',');
546
       dwin_string.add(i8tostr3rj(y_plot));
546
       dwin_string.add(i8tostr3rj(y_plot));
547
-      dwin_string.add(")");
547
+      dwin_string.add(')');
548
       lcd_moveto(
548
       lcd_moveto(
549
         TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
549
         TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
550
         TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 2, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 1)
550
         TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 2, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 1)
556
       if (!isnan(bedlevel.z_values[x_plot][y_plot]))
556
       if (!isnan(bedlevel.z_values[x_plot][y_plot]))
557
         dwin_string.add(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
557
         dwin_string.add(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
558
       else
558
       else
559
-        dwin_string.add(PSTR(" -----"));
559
+        dwin_string.add(F(" -----"));
560
       lcd_moveto(
560
       lcd_moveto(
561
         TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
561
         TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
562
         TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 1, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 2)
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
 
88
 
89
     // For E_TOTAL there may be some characters to cover up
89
     // For E_TOTAL there may be some characters to cover up
90
     if (BOTH(DWIN_MARLINUI_PORTRAIT, LCD_SHOW_E_TOTAL) && axis == X_AXIS)
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
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string()));
93
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string()));
94
 
94
 
117
 
117
 
118
     // For E_TOTAL there may be some characters to cover up
118
     // For E_TOTAL there may be some characters to cover up
119
     if (ENABLED(LCD_SHOW_E_TOTAL) && (!ui.did_first_redraw  || ui.old_is_printing != print_job_timer.isRunning()) && axis == X_AXIS)
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
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string()));
122
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string()));
123
 
123
 
133
 
133
 
134
       if (!ui.did_first_redraw) {
134
       if (!ui.did_first_redraw) {
135
         // Extra spaces to erase previous value
135
         // Extra spaces to erase previous value
136
-        dwin_string.set("E         ");
136
+        dwin_string.set(F("E         "));
137
         DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string()));
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
     #else // !DWIN_MARLINUI_PORTRAIT
146
     #else // !DWIN_MARLINUI_PORTRAIT
147
 
147
 
148
       if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) {
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
         DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string()));
150
         DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string()));
151
       }
151
       }
152
 
152
 
176
   else {
176
   else {
177
     DWIN_ICON_AnimationControl(0x0000); // disable all icon animations (this is the only one)
177
     DWIN_ICON_AnimationControl(0x0000); // disable all icon animations (this is the only one)
178
     DWIN_ICON_Show(ICON, ICON_Fan0, x + fanx, y);
178
     DWIN_ICON_Show(ICON, ICON_Fan0, x + fanx, y);
179
-    dwin_string.set(PSTR("    "));
179
+    dwin_string.set(F("    "));
180
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string()));
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
   }
289
   }
290
 
290
 
291
   dwin_string.set(value);
291
   dwin_string.set(value);
292
-  dwin_string.add(PSTR("%"));
292
+  dwin_string.add('%');
293
   DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 14, y, S(dwin_string.string()));
293
   DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 14, y, S(dwin_string.string()));
294
 }
294
 }
295
 
295
 
396
     // landscape mode shows both elapsed and remaining (if SHOW_REMAINING_TIME)
396
     // landscape mode shows both elapsed and remaining (if SHOW_REMAINING_TIME)
397
     time = print_job_timer.duration();
397
     time = print_job_timer.duration();
398
     time.toDigital(buffer);
398
     time.toDigital(buffer);
399
-    dwin_string.set(" ");
399
+    dwin_string.set(' ');
400
     dwin_string.add(buffer);
400
     dwin_string.add(buffer);
401
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 230, 170, S(dwin_string.string()));
401
     DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 230, 170, S(dwin_string.string()));
402
 
402
 
405
         time = get_remaining_time();
405
         time = get_remaining_time();
406
         DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(" R "));
406
         DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(" R "));
407
         if (print_job_timer.isPaused() && blink)
407
         if (print_job_timer.isPaused() && blink)
408
-          dwin_string.set("     ");
408
+          dwin_string.set(F("     "));
409
         else {
409
         else {
410
           time.toDigital(buffer);
410
           time.toDigital(buffer);
411
           dwin_string.set(buffer);
411
           dwin_string.set(buffer);
413
         DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string()));
413
         DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string()));
414
       }
414
       }
415
       else if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) {
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
         DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string()));
417
         DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string()));
418
       }
418
       }
419
     #endif
419
     #endif
449
 
449
 
450
       #if ENABLED(SHOW_SD_PERCENT)
450
       #if ENABLED(SHOW_SD_PERCENT)
451
         dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))));
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
         DWIN_Draw_String(
453
         DWIN_Draw_String(
454
           false, font16x32, Percent_Color, Color_Bg_Black,
454
           false, font16x32, Percent_Color, Color_Bg_Black,
455
           pb_left + (pb_width - dwin_string.length * 16) / 2,
455
           pb_left + (pb_width - dwin_string.length * 16) / 2,

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

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

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

32
 #define GRID_COLS 2
32
 #define GRID_COLS 2
33
 #define GRID_ROWS 9
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
   if (what & BACKGROUND) {
36
   if (what & BACKGROUND) {
37
     CommandProcessor cmd;
37
     CommandProcessor cmd;
38
     cmd.cmd(COLOR_RGB(bg_text_enabled))
38
     cmd.cmd(COLOR_RGB(bg_text_enabled))
39
        .tag(0);
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
   return true;
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
   CommandProcessor cmd;
119
   CommandProcessor cmd;
116
   cmd.cmd(CMD_DLSTART)
120
   cmd.cmd(CMD_DLSTART)
117
      .cmd(CLEAR_COLOR_RGB(bg_color))
121
      .cmd(CLEAR_COLOR_RGB(bg_color))
118
      .cmd(CLEAR(true,true,true));
122
      .cmd(CLEAR(true,true,true));
119
 
123
 
120
-  draw_status_message(BACKGROUND, message);
124
+  draw_status_message(BACKGROUND, cmsg);
121
   draw_progress(BACKGROUND);
125
   draw_progress(BACKGROUND);
122
   draw_time_remaining(BACKGROUND);
126
   draw_time_remaining(BACKGROUND);
123
   draw_interaction_buttons(BACKGROUND);
127
   draw_interaction_buttons(BACKGROUND);
124
   storeBackground();
128
   storeBackground();
125
 
129
 
126
   #if ENABLED(TOUCH_UI_DEBUG)
130
   #if ENABLED(TOUCH_UI_DEBUG)
127
-    SERIAL_ECHO_MSG("New status message: ", message);
131
+    SERIAL_ECHO_MSG("New status message: ", cmsg);
128
   #endif
132
   #endif
129
 
133
 
130
   if (AT_SCREEN(BioPrintingDialogBox))
134
   if (AT_SCREEN(BioPrintingDialogBox))

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

122
 
122
 
123
       ui.bounds(POLY(bed_temp), x, y, h, v);
123
       ui.bounds(POLY(bed_temp), x, y, h, v);
124
       cmd.text(x, y, h, v, str);
124
       cmd.text(x, y, h, v, str);
125
-      #endif
125
+    #endif
126
   }
126
   }
127
 }
127
 }
128
 
128
 
354
   return false;
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
 void StatusScreen::setStatusMessage(const char * const str) {
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
   }
136
   }
137
 
137
 
138
   void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P fstr, uint16_t options, uint8_t font) {
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
 } // namespace FTDI
147
 } // namespace FTDI
144
 
148
 

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

192
   }
192
   }
193
 
193
 
194
   uint16_t FTDI::get_utf8_text_width(FSTR_P fstr, font_size_t fs) {
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
 #define GRID_ROWS 8
32
 #define GRID_ROWS 8
33
 
33
 
34
 template<typename T>
34
 template<typename T>
35
-void DialogBoxBaseClass::drawMessage(T message, int16_t font) {
35
+void DialogBoxBaseClass::drawMessage(T message, const int16_t font) {
36
   CommandProcessor cmd;
36
   CommandProcessor cmd;
37
   cmd.cmd(CMD_DLSTART)
37
   cmd.cmd(CMD_DLSTART)
38
      .cmd(CLEAR_COLOR_RGB(bg_color))
38
      .cmd(CLEAR_COLOR_RGB(bg_color))
43
   cmd.colors(normal_btn);
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
 void DialogBoxBaseClass::drawYesNoButtons(uint8_t default_btn) {
48
 void DialogBoxBaseClass::drawYesNoButtons(uint8_t default_btn) {
50
   CommandProcessor cmd;
49
   CommandProcessor cmd;

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

27
 
27
 
28
 class DialogBoxBaseClass : public BaseScreen {
28
 class DialogBoxBaseClass : public BaseScreen {
29
   protected:
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
     template<typename T> static void drawButton(T);
33
     template<typename T> static void drawButton(T);
32
     static void drawYesNoButtons(uint8_t default_btn = 0);
34
     static void drawYesNoButtons(uint8_t default_btn = 0);
33
     static void drawOkayButton();
35
     static void drawOkayButton();
34
 
36
 
35
-    static void onRedraw(draw_mode_t) {};
37
+    static void onRedraw(draw_mode_t) {}
38
+
36
   public:
39
   public:
37
     static bool onTouchEnd(uint8_t tag);
40
     static bool onTouchEnd(uint8_t tag);
38
     static void onIdle();
41
     static void onIdle();

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

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
 void StatusScreen::setStatusMessage(const char *message) {
345
 void StatusScreen::setStatusMessage(const char *message) {

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

711
 }
711
 }
712
 
712
 
713
 void disp_assets_update_progress(FSTR_P const fmsg) {
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
 #if BOTH(MKS_TEST, SDSUPPORT)
726
 #if BOTH(MKS_TEST, SDSUPPORT)

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

1112
 
1112
 
1113
   // Simplest approach is to make an SRAM copy
1113
   // Simplest approach is to make an SRAM copy
1114
   void onUserConfirmRequired(FSTR_P const fstr) {
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
   void onStatusChanged(FSTR_P const fstr) {
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
   FileList::FileList() { refresh(); }
1134
   FileList::FileList() { refresh(); }

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

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

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

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

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

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

Loading…
取消
儲存