Save some string flash

This commit is contained in:
Scott Lahteine 2019-11-01 23:51:25 -05:00
parent 23d21dd81c
commit ca6d00b862
18 changed files with 47 additions and 32 deletions

View file

@ -181,6 +181,11 @@
#include "libs/L6470/L6470_Marlin.h"
#endif
const char G28_STR[] PROGMEM = "G28",
M21_STR[] PROGMEM = "M21",
M23_STR[] PROGMEM = "M23 %s",
M24_STR[] PROGMEM = "M24";
bool Running = true;
// 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)) {
next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
LCD_MESSAGEPGM(MSG_AUTO_HOME);
queue.enqueue_now_P(PSTR("G28"));
queue.enqueue_now_P(G28_STR);
}
}
#endif

View file

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

View file

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

View file

@ -188,8 +188,8 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*=
#if EXTRUDERS > 1
for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e];
#else
if (parser.volumetric_enabled) info.filament_size = planner.filament_size[active_extruder];
#endif
if (parser.volumetric_enabled) info.filament_size = planner.filament_size[active_extruder];
#endif
#endif
#if EXTRUDERS
@ -301,7 +301,7 @@ void PrintJobRecovery::resume() {
#endif
// Recover volumetric extrusion state
#if DISABLED(NO_VOLUMETRICS)
#if DISABLED(NO_VOLUMETRICS)
#if EXTRUDERS > 1
for (int8_t e = 0; e < EXTRUDERS; e++) {
dtostrf(info.filament_size[e], 1, 3, str_1);
@ -437,7 +437,8 @@ void PrintJobRecovery::resume() {
// Resume the SD file from the last position
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);
sprintf_P(cmd, PSTR("M24 S%ld T%ld"), resume_sdpos, info.print_job_elapsed);
gcode.process_subcommands_now(cmd);

View file

@ -108,7 +108,7 @@ void L6470_report_current(L6470 &motor, const uint8_t axis) {
SERIAL_ECHO(temp_buf);
SERIAL_ECHOPGM(" Motor Status: ");
const char * const stat_str;
const char *stat_str;
switch (motor_status) {
default:
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: ");
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_RUN : ", motor.GetParam(L6470_KVAL_RUN));
SERIAL_ECHOPAIR(" KVAL_ACC: ", motor.GetParam(L6470_KVAL_ACC));

View file

@ -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];
// 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));
process_subcommands_now(gcode_string);
sprintf_P(gcode_string, PSTR("G0 %c%s F%s"), axis_char, dtostrf(min, 1, 3, str1), dtostrf(fr_mm_m, 1, 3, str2));
gcode.process_subcommands_now(gcode_string);
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();
}

View file

@ -340,7 +340,10 @@ public:
static void process_subcommands_now_P(PGM_P pgcode);
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)
/**

View file

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

View file

@ -248,7 +248,7 @@ void process_lcd_p_command(const char* command) {
ExtUI::stopPrint();
write_to_lcd_P(PSTR("{SYS:STARTED}"));
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: {
#if ENABLED(SDSUPPORT)
// Print file 000 - a three digit number indicating which

View file

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

View file

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

View file

@ -130,7 +130,7 @@ void menu_advanced_settings();
auto _recalc_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;
}
};

View file

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

View file

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

View file

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

View file

@ -107,7 +107,7 @@ void lcd_z_offset_edit_setup(const float &initial) {
*/
void _lcd_ubl_build_custom_mesh() {
char ubl_lcd_gcode[20];
queue.inject_P(PSTR("G28"));
queue.inject_P(G28_STR);
#if HAS_HEATED_BED
sprintf_P(ubl_lcd_gcode, PSTR("M190 S%i"), custom_bed_temp);
lcd_enqueue_one_now(ubl_lcd_gcode);
@ -195,7 +195,7 @@ void _lcd_ubl_validate_custom_mesh() {
#endif
;
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);
}
@ -519,7 +519,7 @@ void _lcd_ubl_output_map_lcd() {
void _lcd_ubl_output_map_lcd_cmd() {
if (!all_axes_known()) {
set_all_unhomed();
queue.inject_P(PSTR("G28"));
queue.inject_P(G28_STR);
}
ui.goto_screen(_lcd_ubl_map_homing);
}

View file

@ -464,7 +464,7 @@ bool MarlinUI::get_blink() {
#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;
}
@ -1530,7 +1530,7 @@ void MarlinUI::update() {
#if ENABLED(PARK_HEAD_ON_PAUSE)
wait_for_heatup = wait_for_user = false;
#endif
if (IS_SD_PAUSED()) queue.inject_P(PSTR("M24"));
if (IS_SD_PAUSED()) queue.inject_P(M24_STR);
#ifdef ACTION_ON_RESUME
host_action_resume();
#endif

View file

@ -385,10 +385,11 @@ void CardReader::release() {
void CardReader::openAndPrintFile(const char *name) {
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);
queue.enqueue_one_now(cmd);
queue.enqueue_now_P(PSTR("M24"));
queue.enqueue_now_P(M24_STR);
}
void CardReader::startFileprint() {