Browse Source

Save some string flash

Scott Lahteine 5 years ago
parent
commit
ca6d00b862

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

181
   #include "libs/L6470/L6470_Marlin.h"
181
   #include "libs/L6470/L6470_Marlin.h"
182
 #endif
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
 bool Running = true;
189
 bool Running = true;
185
 
190
 
186
 // For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
191
 // For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
509
       if (ELAPSED(ms, next_home_key_ms)) {
514
       if (ELAPSED(ms, next_home_key_ms)) {
510
         next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
515
         next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
511
         LCD_MESSAGEPGM(MSG_AUTO_HOME);
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
   #endif
520
   #endif

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

376
   void event_probe_recover();
376
   void event_probe_recover();
377
   void event_probe_failure();
377
   void event_probe_failure();
378
 #endif
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
       case PROMPT_PAUSE_RESUME:
151
       case PROMPT_PAUSE_RESUME:
152
         msg = PSTR("LCD_PAUSE_RESUME");
152
         msg = PSTR("LCD_PAUSE_RESUME");
153
         #if ENABLED(ADVANCED_PAUSE_FEATURE)
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
         #endif
156
         #endif
156
         break;
157
         break;
157
       case PROMPT_INFO:
158
       case PROMPT_INFO:

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

188
       #if EXTRUDERS > 1
188
       #if EXTRUDERS > 1
189
         for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e];
189
         for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e];
190
       #else
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
     #endif
193
     #endif
194
 
194
 
195
     #if EXTRUDERS
195
     #if EXTRUDERS
301
   #endif
301
   #endif
302
 
302
 
303
   // Recover volumetric extrusion state
303
   // Recover volumetric extrusion state
304
-  #if DISABLED(NO_VOLUMETRICS)    
304
+  #if DISABLED(NO_VOLUMETRICS)
305
     #if EXTRUDERS > 1
305
     #if EXTRUDERS > 1
306
       for (int8_t e = 0; e < EXTRUDERS; e++) {
306
       for (int8_t e = 0; e < EXTRUDERS; e++) {
307
         dtostrf(info.filament_size[e], 1, 3, str_1);
307
         dtostrf(info.filament_size[e], 1, 3, str_1);
437
 
437
 
438
   // Resume the SD file from the last position
438
   // Resume the SD file from the last position
439
   char *fn = info.sd_filename;
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
   gcode.process_subcommands_now(cmd);
442
   gcode.process_subcommands_now(cmd);
442
   sprintf_P(cmd, PSTR("M24 S%ld T%ld"), resume_sdpos, info.print_job_elapsed);
443
   sprintf_P(cmd, PSTR("M24 S%ld T%ld"), resume_sdpos, info.print_job_elapsed);
443
   gcode.process_subcommands_now(cmd);
444
   gcode.process_subcommands_now(cmd);

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

108
   SERIAL_ECHO(temp_buf);
108
   SERIAL_ECHO(temp_buf);
109
 
109
 
110
   SERIAL_ECHOPGM("   Motor Status: ");
110
   SERIAL_ECHOPGM("   Motor Status: ");
111
-  const char * const stat_str;
111
+  const char *stat_str;
112
   switch (motor_status) {
112
   switch (motor_status) {
113
     default:
113
     default:
114
     case 0: stat_str = PSTR("stopped"); break;
114
     case 0: stat_str = PSTR("stopped"); break;
124
   SERIAL_ECHOPGM("   Vs_compensation: ");
124
   SERIAL_ECHOPGM("   Vs_compensation: ");
125
   serialprintPGM((motor.GetParam(L6470_CONFIG) & CONFIG_EN_VSCOMP) ? PSTR("ENABLED ") : PSTR("DISABLED"));
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
   SERIAL_ECHOPAIR("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD));
128
   SERIAL_ECHOPAIR("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD));
129
   SERIAL_ECHOPAIR("   KVAL_RUN : ", motor.GetParam(L6470_KVAL_RUN));
129
   SERIAL_ECHOPAIR("   KVAL_RUN : ", motor.GetParam(L6470_KVAL_RUN));
130
   SERIAL_ECHOPAIR("   KVAL_ACC: ", motor.GetParam(L6470_KVAL_ACC));
130
   SERIAL_ECHOPAIR("   KVAL_ACC: ", motor.GetParam(L6470_KVAL_ACC));

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

36
   char gcode_string[30], str1[11], str2[11];
36
   char gcode_string[30], str1[11], str2[11];
37
 
37
 
38
   // Turn the motor(s) both directions
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
   sprintf_P(gcode_string, PSTR("G0 %c%s F%s"), axis_char, dtostrf(max, 1, 3, str1), str2);
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
   planner.synchronize();
45
   planner.synchronize();
46
 }
46
 }

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

340
   static void process_subcommands_now_P(PGM_P pgcode);
340
   static void process_subcommands_now_P(PGM_P pgcode);
341
   static void process_subcommands_now(char * gcode);
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
   #if ENABLED(HOST_KEEPALIVE_FEATURE)
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
 
121
 
122
   if (!commandsInQueue()) {
122
   if (!commandsInQueue()) {
123
       if (!isPositionKnown()) {
123
       if (!isPositionKnown()) {
124
-        injectCommands_P(PSTR("G28"));
124
+        injectCommands_P(G28_STR);
125
       } else {
125
       } else {
126
         injectCommands_P(PSTR(
126
         injectCommands_P(PSTR(
127
           "G0 X100 Y100 Z100 F6000\n"
127
           "G0 X100 Y100 Z100 F6000\n"

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

248
         ExtUI::stopPrint();
248
         ExtUI::stopPrint();
249
         write_to_lcd_P(PSTR("{SYS:STARTED}"));
249
         write_to_lcd_P(PSTR("{SYS:STARTED}"));
250
         break;
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
     default: {
252
     default: {
253
       #if ENABLED(SDSUPPORT)
253
       #if ENABLED(SDSUPPORT)
254
         // Print file 000 - a three digit number indicating which
254
         // Print file 000 - a three digit number indicating which

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

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

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

195
     ui.defer_status_screen();
195
     ui.defer_status_screen();
196
     set_all_unhomed();
196
     set_all_unhomed();
197
     ui.goto_screen(_lcd_level_bed_homing);
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
 #endif // PROBE_MANUALLY || MESH_BED_LEVELING
201
 #endif // PROBE_MANUALLY || MESH_BED_LEVELING
241
 
241
 
242
   // Auto Home if not using manual probing
242
   // Auto Home if not using manual probing
243
   #if NONE(PROBE_MANUALLY, MESH_BED_LEVELING)
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
   #endif
245
   #endif
246
 
246
 
247
   // Level Bed
247
   // Level Bed

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

130
 
130
 
131
     auto _recalc_offsets = []{
131
     auto _recalc_offsets = []{
132
       if (active_extruder && all_axes_known()) {  // For the 2nd extruder re-home so the next tool-change gets the new offsets.
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
         active_extruder = 0;
134
         active_extruder = 0;
135
       }
135
       }
136
     };
136
     };

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

79
   }
79
   }
80
 
80
 
81
   void _lcd_delta_calibrate_home() {
81
   void _lcd_delta_calibrate_home() {
82
-    queue.inject_P(PSTR("G28"));
82
+    queue.inject_P(G28_STR);
83
     ui.goto_screen(_lcd_calibrate_homing);
83
     ui.goto_screen(_lcd_calibrate_homing);
84
   }
84
   }
85
 
85
 

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

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

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

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

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

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

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

464
 
464
 
465
         #endif // HAS_LCD_MENU
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
         return true;
468
         return true;
469
       }
469
       }
470
 
470
 
1530
     #if ENABLED(PARK_HEAD_ON_PAUSE)
1530
     #if ENABLED(PARK_HEAD_ON_PAUSE)
1531
       wait_for_heatup = wait_for_user = false;
1531
       wait_for_heatup = wait_for_user = false;
1532
     #endif
1532
     #endif
1533
-    if (IS_SD_PAUSED()) queue.inject_P(PSTR("M24"));
1533
+    if (IS_SD_PAUSED()) queue.inject_P(M24_STR);
1534
     #ifdef ACTION_ON_RESUME
1534
     #ifdef ACTION_ON_RESUME
1535
       host_action_resume();
1535
       host_action_resume();
1536
     #endif
1536
     #endif

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

385
 
385
 
386
 void CardReader::openAndPrintFile(const char *name) {
386
 void CardReader::openAndPrintFile(const char *name) {
387
   char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null
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
   for (char *c = &cmd[4]; *c; c++) *c = tolower(*c);
390
   for (char *c = &cmd[4]; *c; c++) *c = tolower(*c);
390
   queue.enqueue_one_now(cmd);
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
 void CardReader::startFileprint() {
395
 void CardReader::startFileprint() {

Loading…
Cancel
Save