Save some string flash

2.0.x
Scott Lahteine 5 years ago
parent 23d21dd81c
commit ca6d00b862

@ -181,6 +181,11 @@
#include "libs/L6470/L6470_Marlin.h" #include "libs/L6470/L6470_Marlin.h"
#endif #endif
const char G28_STR[] PROGMEM = "G28",
M21_STR[] PROGMEM = "M21",
M23_STR[] PROGMEM = "M23 %s",
M24_STR[] PROGMEM = "M24";
bool Running = true; bool Running = true;
// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop // 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*/) {
if (ELAPSED(ms, next_home_key_ms)) { if (ELAPSED(ms, next_home_key_ms)) {
next_home_key_ms = ms + HOME_DEBOUNCE_DELAY; next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
LCD_MESSAGEPGM(MSG_AUTO_HOME); LCD_MESSAGEPGM(MSG_AUTO_HOME);
queue.enqueue_now_P(PSTR("G28")); queue.enqueue_now_P(G28_STR);
} }
} }
#endif #endif

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

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

@ -437,7 +437,8 @@ void PrintJobRecovery::resume() {
// Resume the SD file from the last position // Resume the SD file from the last position
char *fn = info.sd_filename; char *fn = info.sd_filename;
sprintf_P(cmd, PSTR("M23 %s"), fn); extern const char M23_STR[];
sprintf_P(cmd, M23_STR, fn);
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);
sprintf_P(cmd, PSTR("M24 S%ld T%ld"), resume_sdpos, info.print_job_elapsed); sprintf_P(cmd, PSTR("M24 S%ld T%ld"), resume_sdpos, info.print_job_elapsed);
gcode.process_subcommands_now(cmd); gcode.process_subcommands_now(cmd);

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

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

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

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

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

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

@ -195,7 +195,7 @@
ui.defer_status_screen(); ui.defer_status_screen();
set_all_unhomed(); set_all_unhomed();
ui.goto_screen(_lcd_level_bed_homing); ui.goto_screen(_lcd_level_bed_homing);
queue.inject_P(PSTR("G28")); queue.inject_P(G28_STR);
} }
#endif // PROBE_MANUALLY || MESH_BED_LEVELING #endif // PROBE_MANUALLY || MESH_BED_LEVELING
@ -241,7 +241,7 @@ void menu_bed_leveling() {
// Auto Home if not using manual probing // Auto Home if not using manual probing
#if NONE(PROBE_MANUALLY, MESH_BED_LEVELING) #if NONE(PROBE_MANUALLY, MESH_BED_LEVELING)
if (!is_homed) GCODES_ITEM(MSG_AUTO_HOME, PSTR("G28")); if (!is_homed) GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
#endif #endif
// Level Bed // Level Bed

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

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

@ -95,6 +95,8 @@ void menu_configuration();
#endif #endif
#endif #endif
extern const char M21_STR[];
void menu_main() { void menu_main() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_WATCH); BACK_ITEM(MSG_WATCH);
@ -129,7 +131,7 @@ void menu_main() {
SUBMENU(MSG_MEDIA_MENU, menu_media); SUBMENU(MSG_MEDIA_MENU, menu_media);
MENU_ITEM(gcode, MENU_ITEM(gcode,
#if PIN_EXISTS(SD_DETECT) #if PIN_EXISTS(SD_DETECT)
MSG_CHANGE_MEDIA, PSTR("M21") MSG_CHANGE_MEDIA, M21_STR
#else #else
MSG_RELEASE_MEDIA, PSTR("M22") MSG_RELEASE_MEDIA, PSTR("M22")
#endif #endif
@ -140,7 +142,7 @@ void menu_main() {
#if PIN_EXISTS(SD_DETECT) #if PIN_EXISTS(SD_DETECT)
ACTION_ITEM(MSG_NO_MEDIA, nullptr); ACTION_ITEM(MSG_NO_MEDIA, nullptr);
#else #else
GCODES_ITEM(MSG_INIT_MEDIA, PSTR("M21")); GCODES_ITEM(MSG_INIT_MEDIA, M21_STR);
ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr); ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
#endif #endif
} }
@ -218,7 +220,7 @@ void menu_main() {
if (!card_open) { if (!card_open) {
MENU_ITEM(gcode, MENU_ITEM(gcode,
#if PIN_EXISTS(SD_DETECT) #if PIN_EXISTS(SD_DETECT)
MSG_CHANGE_MEDIA, PSTR("M21") MSG_CHANGE_MEDIA, M21_STR
#else #else
MSG_RELEASE_MEDIA, PSTR("M22") MSG_RELEASE_MEDIA, PSTR("M22")
#endif #endif
@ -230,7 +232,7 @@ void menu_main() {
#if PIN_EXISTS(SD_DETECT) #if PIN_EXISTS(SD_DETECT)
ACTION_ITEM(MSG_NO_MEDIA, nullptr); ACTION_ITEM(MSG_NO_MEDIA, nullptr);
#else #else
GCODES_ITEM(MSG_INIT_MEDIA, PSTR("M21")); GCODES_ITEM(MSG_INIT_MEDIA, M21_STR);
ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr); ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
#endif #endif
} }

@ -303,7 +303,7 @@ void menu_move() {
SUBMENU(MSG_MOVE_Z, []{ _menu_move_distance(Z_AXIS, lcd_move_z); }); SUBMENU(MSG_MOVE_Z, []{ _menu_move_distance(Z_AXIS, lcd_move_z); });
} }
else else
GCODES_ITEM(MSG_AUTO_HOME, PSTR("G28")); GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
#if ANY(SWITCHING_EXTRUDER, SWITCHING_NOZZLE, MAGNETIC_SWITCHING_TOOLHEAD) #if ANY(SWITCHING_EXTRUDER, SWITCHING_NOZZLE, MAGNETIC_SWITCHING_TOOLHEAD)
@ -409,7 +409,7 @@ void menu_motion() {
// //
// Auto Home // Auto Home
// //
GCODES_ITEM(MSG_AUTO_HOME, PSTR("G28")); GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
#if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU) #if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU)
GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28 X")); GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28 X"));
GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28 Y")); GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28 Y"));

@ -107,7 +107,7 @@ void lcd_z_offset_edit_setup(const float &initial) {
*/ */
void _lcd_ubl_build_custom_mesh() { void _lcd_ubl_build_custom_mesh() {
char ubl_lcd_gcode[20]; char ubl_lcd_gcode[20];
queue.inject_P(PSTR("G28")); queue.inject_P(G28_STR);
#if HAS_HEATED_BED #if HAS_HEATED_BED
sprintf_P(ubl_lcd_gcode, PSTR("M190 S%i"), custom_bed_temp); sprintf_P(ubl_lcd_gcode, PSTR("M190 S%i"), custom_bed_temp);
lcd_enqueue_one_now(ubl_lcd_gcode); lcd_enqueue_one_now(ubl_lcd_gcode);
@ -195,7 +195,7 @@ void _lcd_ubl_validate_custom_mesh() {
#endif #endif
; ;
sprintf_P(ubl_lcd_gcode, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp); sprintf_P(ubl_lcd_gcode, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
lcd_enqueue_one_now_P(PSTR("G28")); lcd_enqueue_one_now_P(G28_STR);
lcd_enqueue_one_now(ubl_lcd_gcode); lcd_enqueue_one_now(ubl_lcd_gcode);
} }
@ -519,7 +519,7 @@ void _lcd_ubl_output_map_lcd() {
void _lcd_ubl_output_map_lcd_cmd() { void _lcd_ubl_output_map_lcd_cmd() {
if (!all_axes_known()) { if (!all_axes_known()) {
set_all_unhomed(); set_all_unhomed();
queue.inject_P(PSTR("G28")); queue.inject_P(G28_STR);
} }
ui.goto_screen(_lcd_ubl_map_homing); ui.goto_screen(_lcd_ubl_map_homing);
} }

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

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

Loading…
Cancel
Save