Browse Source

Save some string flash

Scott Lahteine 4 years ago
parent
commit
ca6d00b862

+ 6
- 1
Marlin/src/Marlin.cpp View File

@@ -181,6 +181,11 @@
181 181
   #include "libs/L6470/L6470_Marlin.h"
182 182
 #endif
183 183
 
184
+const char G28_STR[] PROGMEM = "G28",
185
+           M21_STR[] PROGMEM = "M21",
186
+           M23_STR[] PROGMEM = "M23 %s",
187
+           M24_STR[] PROGMEM = "M24";
188
+
184 189
 bool Running = true;
185 190
 
186 191
 // For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
@@ -509,7 +514,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
509 514
       if (ELAPSED(ms, next_home_key_ms)) {
510 515
         next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
511 516
         LCD_MESSAGEPGM(MSG_AUTO_HOME);
512
-        queue.enqueue_now_P(PSTR("G28"));
517
+        queue.enqueue_now_P(G28_STR);
513 518
       }
514 519
     }
515 520
   #endif

+ 2
- 0
Marlin/src/Marlin.h View File

@@ -376,3 +376,5 @@ void protected_pin_err();
376 376
   void event_probe_recover();
377 377
   void event_probe_failure();
378 378
 #endif
379
+
380
+extern const char G28_STR[], M21_STR[], M23_STR[], M24_STR[];

+ 2
- 1
Marlin/src/feature/host_actions.cpp View File

@@ -151,7 +151,8 @@ void host_action(const char * const pstr, const bool eol) {
151 151
       case PROMPT_PAUSE_RESUME:
152 152
         msg = PSTR("LCD_PAUSE_RESUME");
153 153
         #if ENABLED(ADVANCED_PAUSE_FEATURE)
154
-          queue.inject_P(PSTR("M24"));
154
+          extern const char M24_STR[];
155
+          queue.inject_P(M24_STR);
155 156
         #endif
156 157
         break;
157 158
       case PROMPT_INFO:

+ 5
- 4
Marlin/src/feature/power_loss_recovery.cpp View File

@@ -188,8 +188,8 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*=
188 188
       #if EXTRUDERS > 1
189 189
         for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e];
190 190
       #else
191
-        if (parser.volumetric_enabled) info.filament_size = planner.filament_size[active_extruder]; 
192
-      #endif    
191
+        if (parser.volumetric_enabled) info.filament_size = planner.filament_size[active_extruder];
192
+      #endif
193 193
     #endif
194 194
 
195 195
     #if EXTRUDERS
@@ -301,7 +301,7 @@ void PrintJobRecovery::resume() {
301 301
   #endif
302 302
 
303 303
   // Recover volumetric extrusion state
304
-  #if DISABLED(NO_VOLUMETRICS)    
304
+  #if DISABLED(NO_VOLUMETRICS)
305 305
     #if EXTRUDERS > 1
306 306
       for (int8_t e = 0; e < EXTRUDERS; e++) {
307 307
         dtostrf(info.filament_size[e], 1, 3, str_1);
@@ -437,7 +437,8 @@ void PrintJobRecovery::resume() {
437 437
 
438 438
   // Resume the SD file from the last position
439 439
   char *fn = info.sd_filename;
440
-  sprintf_P(cmd, PSTR("M23 %s"), fn);
440
+  extern const char M23_STR[];
441
+  sprintf_P(cmd, M23_STR, fn);
441 442
   gcode.process_subcommands_now(cmd);
442 443
   sprintf_P(cmd, PSTR("M24 S%ld T%ld"), resume_sdpos, info.print_job_elapsed);
443 444
   gcode.process_subcommands_now(cmd);

+ 2
- 2
Marlin/src/gcode/feature/L6470/M906.cpp View File

@@ -108,7 +108,7 @@ void L6470_report_current(L6470 &motor, const uint8_t axis) {
108 108
   SERIAL_ECHO(temp_buf);
109 109
 
110 110
   SERIAL_ECHOPGM("   Motor Status: ");
111
-  const char * const stat_str;
111
+  const char *stat_str;
112 112
   switch (motor_status) {
113 113
     default:
114 114
     case 0: stat_str = PSTR("stopped"); break;
@@ -124,7 +124,7 @@ void L6470_report_current(L6470 &motor, const uint8_t axis) {
124 124
   SERIAL_ECHOPGM("   Vs_compensation: ");
125 125
   serialprintPGM((motor.GetParam(L6470_CONFIG) & CONFIG_EN_VSCOMP) ? PSTR("ENABLED ") : PSTR("DISABLED"));
126 126
 
127
-  SERIAL_ECHOLNPGM("   Compensation coefficient: ", dtostrf(comp_coef * 0.01f, 7, 2, numstr));
127
+  SERIAL_ECHOLNPAIR("   Compensation coefficient: ", dtostrf(comp_coef * 0.01f, 7, 2, numstr));
128 128
   SERIAL_ECHOPAIR("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD));
129 129
   SERIAL_ECHOPAIR("   KVAL_RUN : ", motor.GetParam(L6470_KVAL_RUN));
130 130
   SERIAL_ECHOPAIR("   KVAL_ACC: ", motor.GetParam(L6470_KVAL_ACC));

+ 3
- 3
Marlin/src/gcode/feature/L6470/M916-918.cpp View File

@@ -36,11 +36,11 @@ static void jiggle_axis(const char axis_char, const float &min, const float &max
36 36
   char gcode_string[30], str1[11], str2[11];
37 37
 
38 38
   // Turn the motor(s) both directions
39
-  sprintf_P(gcode_string, PSTR("G0 %c%s F%s"), axis_char, dtostrf(min, 1, 3, str1), dtostrf(rate, 1, 3, str2));
40
-  process_subcommands_now(gcode_string);
39
+  sprintf_P(gcode_string, PSTR("G0 %c%s F%s"), axis_char, dtostrf(min, 1, 3, str1), dtostrf(fr_mm_m, 1, 3, str2));
40
+  gcode.process_subcommands_now(gcode_string);
41 41
 
42 42
   sprintf_P(gcode_string, PSTR("G0 %c%s F%s"), axis_char, dtostrf(max, 1, 3, str1), str2);
43
-  process_subcommands_now(gcode_string);
43
+  gcode.process_subcommands_now(gcode_string);
44 44
 
45 45
   planner.synchronize();
46 46
 }

+ 4
- 1
Marlin/src/gcode/gcode.h View File

@@ -340,7 +340,10 @@ public:
340 340
   static void process_subcommands_now_P(PGM_P pgcode);
341 341
   static void process_subcommands_now(char * gcode);
342 342
 
343
-  static inline void home_all_axes() { process_subcommands_now_P(PSTR("G28")); }
343
+  static inline void home_all_axes() {
344
+    extern const char G28_STR[];
345
+    process_subcommands_now_P(G28_STR);
346
+  }
344 347
 
345 348
   #if ENABLED(HOST_KEEPALIVE_FEATURE)
346 349
     /**

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/stress_test_screen.cpp View File

@@ -121,7 +121,7 @@ void StressTestScreen::onIdle() {
121 121
 
122 122
   if (!commandsInQueue()) {
123 123
       if (!isPositionKnown()) {
124
-        injectCommands_P(PSTR("G28"));
124
+        injectCommands_P(G28_STR);
125 125
       } else {
126 126
         injectCommands_P(PSTR(
127 127
           "G0 X100 Y100 Z100 F6000\n"

+ 1
- 1
Marlin/src/lcd/extui_malyan_lcd.cpp View File

@@ -248,7 +248,7 @@ void process_lcd_p_command(const char* command) {
248 248
         ExtUI::stopPrint();
249 249
         write_to_lcd_P(PSTR("{SYS:STARTED}"));
250 250
         break;
251
-    case 'H': queue.enqueue_now_P(PSTR("G28")); break; // Home all axes
251
+    case 'H': queue.enqueue_now_P(G28_STR); break; // Home all axes
252 252
     default: {
253 253
       #if ENABLED(SDSUPPORT)
254 254
         // Print file 000 - a three digit number indicating which

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_corners.cpp View File

@@ -118,7 +118,7 @@ void _lcd_level_bed_corners() {
118 118
   ui.defer_status_screen();
119 119
   if (!all_axes_known()) {
120 120
     set_all_unhomed();
121
-    queue.inject_P(PSTR("G28"));
121
+    queue.inject_P(G28_STR);
122 122
   }
123 123
 
124 124
   // Disable leveling so the planner won't mess with us

+ 2
- 2
Marlin/src/lcd/menu/menu_bed_leveling.cpp View File

@@ -195,7 +195,7 @@
195 195
     ui.defer_status_screen();
196 196
     set_all_unhomed();
197 197
     ui.goto_screen(_lcd_level_bed_homing);
198
-    queue.inject_P(PSTR("G28"));
198
+    queue.inject_P(G28_STR);
199 199
   }
200 200
 
201 201
 #endif // PROBE_MANUALLY || MESH_BED_LEVELING
@@ -241,7 +241,7 @@ void menu_bed_leveling() {
241 241
 
242 242
   // Auto Home if not using manual probing
243 243
   #if NONE(PROBE_MANUALLY, MESH_BED_LEVELING)
244
-    if (!is_homed) GCODES_ITEM(MSG_AUTO_HOME, PSTR("G28"));
244
+    if (!is_homed) GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
245 245
   #endif
246 246
 
247 247
   // Level Bed

+ 1
- 1
Marlin/src/lcd/menu/menu_configuration.cpp View File

@@ -130,7 +130,7 @@ void menu_advanced_settings();
130 130
 
131 131
     auto _recalc_offsets = []{
132 132
       if (active_extruder && all_axes_known()) {  // For the 2nd extruder re-home so the next tool-change gets the new offsets.
133
-        queue.inject_P(PSTR("G28")); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
133
+        queue.inject_P(G28_STR); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
134 134
         active_extruder = 0;
135 135
       }
136 136
     };

+ 1
- 1
Marlin/src/lcd/menu/menu_delta_calibrate.cpp View File

@@ -79,7 +79,7 @@ void _man_probe_pt(const xy_pos_t &xy) {
79 79
   }
80 80
 
81 81
   void _lcd_delta_calibrate_home() {
82
-    queue.inject_P(PSTR("G28"));
82
+    queue.inject_P(G28_STR);
83 83
     ui.goto_screen(_lcd_calibrate_homing);
84 84
   }
85 85
 

+ 6
- 4
Marlin/src/lcd/menu/menu_main.cpp View File

@@ -95,6 +95,8 @@ void menu_configuration();
95 95
   #endif
96 96
 #endif
97 97
 
98
+extern const char M21_STR[];
99
+
98 100
 void menu_main() {
99 101
   START_MENU();
100 102
   BACK_ITEM(MSG_WATCH);
@@ -129,7 +131,7 @@ void menu_main() {
129 131
           SUBMENU(MSG_MEDIA_MENU, menu_media);
130 132
           MENU_ITEM(gcode,
131 133
             #if PIN_EXISTS(SD_DETECT)
132
-              MSG_CHANGE_MEDIA, PSTR("M21")
134
+              MSG_CHANGE_MEDIA, M21_STR
133 135
             #else
134 136
               MSG_RELEASE_MEDIA, PSTR("M22")
135 137
             #endif
@@ -140,7 +142,7 @@ void menu_main() {
140 142
         #if PIN_EXISTS(SD_DETECT)
141 143
           ACTION_ITEM(MSG_NO_MEDIA, nullptr);
142 144
         #else
143
-          GCODES_ITEM(MSG_INIT_MEDIA, PSTR("M21"));
145
+          GCODES_ITEM(MSG_INIT_MEDIA, M21_STR);
144 146
           ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
145 147
         #endif
146 148
       }
@@ -218,7 +220,7 @@ void menu_main() {
218 220
       if (!card_open) {
219 221
         MENU_ITEM(gcode,
220 222
           #if PIN_EXISTS(SD_DETECT)
221
-            MSG_CHANGE_MEDIA, PSTR("M21")
223
+            MSG_CHANGE_MEDIA, M21_STR
222 224
           #else
223 225
             MSG_RELEASE_MEDIA, PSTR("M22")
224 226
           #endif
@@ -230,7 +232,7 @@ void menu_main() {
230 232
       #if PIN_EXISTS(SD_DETECT)
231 233
         ACTION_ITEM(MSG_NO_MEDIA, nullptr);
232 234
       #else
233
-        GCODES_ITEM(MSG_INIT_MEDIA, PSTR("M21"));
235
+        GCODES_ITEM(MSG_INIT_MEDIA, M21_STR);
234 236
         ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
235 237
       #endif
236 238
     }

+ 2
- 2
Marlin/src/lcd/menu/menu_motion.cpp View File

@@ -303,7 +303,7 @@ void menu_move() {
303 303
     SUBMENU(MSG_MOVE_Z, []{ _menu_move_distance(Z_AXIS, lcd_move_z); });
304 304
   }
305 305
   else
306
-    GCODES_ITEM(MSG_AUTO_HOME, PSTR("G28"));
306
+    GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
307 307
 
308 308
   #if ANY(SWITCHING_EXTRUDER, SWITCHING_NOZZLE, MAGNETIC_SWITCHING_TOOLHEAD)
309 309
 
@@ -409,7 +409,7 @@ void menu_motion() {
409 409
   //
410 410
   // Auto Home
411 411
   //
412
-  GCODES_ITEM(MSG_AUTO_HOME, PSTR("G28"));
412
+  GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
413 413
   #if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU)
414 414
     GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28 X"));
415 415
     GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28 Y"));

+ 3
- 3
Marlin/src/lcd/menu/menu_ubl.cpp View File

@@ -107,7 +107,7 @@ void lcd_z_offset_edit_setup(const float &initial) {
107 107
  */
108 108
 void _lcd_ubl_build_custom_mesh() {
109 109
   char ubl_lcd_gcode[20];
110
-  queue.inject_P(PSTR("G28"));
110
+  queue.inject_P(G28_STR);
111 111
   #if HAS_HEATED_BED
112 112
     sprintf_P(ubl_lcd_gcode, PSTR("M190 S%i"), custom_bed_temp);
113 113
     lcd_enqueue_one_now(ubl_lcd_gcode);
@@ -195,7 +195,7 @@ void _lcd_ubl_validate_custom_mesh() {
195 195
     #endif
196 196
   ;
197 197
   sprintf_P(ubl_lcd_gcode, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
198
-  lcd_enqueue_one_now_P(PSTR("G28"));
198
+  lcd_enqueue_one_now_P(G28_STR);
199 199
   lcd_enqueue_one_now(ubl_lcd_gcode);
200 200
 }
201 201
 
@@ -519,7 +519,7 @@ void _lcd_ubl_output_map_lcd() {
519 519
 void _lcd_ubl_output_map_lcd_cmd() {
520 520
   if (!all_axes_known()) {
521 521
     set_all_unhomed();
522
-    queue.inject_P(PSTR("G28"));
522
+    queue.inject_P(G28_STR);
523 523
   }
524 524
   ui.goto_screen(_lcd_ubl_map_homing);
525 525
 }

+ 2
- 2
Marlin/src/lcd/ultralcd.cpp View File

@@ -464,7 +464,7 @@ bool MarlinUI::get_blink() {
464 464
 
465 465
         #endif // HAS_LCD_MENU
466 466
 
467
-        if (!homed && RRK(EN_KEYPAD_F1)) queue.inject_P(PSTR("G28"));
467
+        if (!homed && RRK(EN_KEYPAD_F1)) queue.inject_P(G28_STR);
468 468
         return true;
469 469
       }
470 470
 
@@ -1530,7 +1530,7 @@ void MarlinUI::update() {
1530 1530
     #if ENABLED(PARK_HEAD_ON_PAUSE)
1531 1531
       wait_for_heatup = wait_for_user = false;
1532 1532
     #endif
1533
-    if (IS_SD_PAUSED()) queue.inject_P(PSTR("M24"));
1533
+    if (IS_SD_PAUSED()) queue.inject_P(M24_STR);
1534 1534
     #ifdef ACTION_ON_RESUME
1535 1535
       host_action_resume();
1536 1536
     #endif

+ 3
- 2
Marlin/src/sd/cardreader.cpp View File

@@ -385,10 +385,11 @@ void CardReader::release() {
385 385
 
386 386
 void CardReader::openAndPrintFile(const char *name) {
387 387
   char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null
388
-  sprintf_P(cmd, PSTR("M23 %s"), name);
388
+  extern const char M23_STR[];
389
+  sprintf_P(cmd, M23_STR, name);
389 390
   for (char *c = &cmd[4]; *c; c++) *c = tolower(*c);
390 391
   queue.enqueue_one_now(cmd);
391
-  queue.enqueue_now_P(PSTR("M24"));
392
+  queue.enqueue_now_P(M24_STR);
392 393
 }
393 394
 
394 395
 void CardReader::startFileprint() {

Loading…
Cancel
Save