🎨 Apply F() to G-code subcommands

This commit is contained in:
Scott Lahteine
2021-09-25 18:43:52 -05:00
committed by Scott Lahteine
parent 433a27e475
commit 2b9ae0cc33
28 changed files with 136 additions and 134 deletions

View File

@ -92,7 +92,7 @@ void GcodeSuite::G35() {
TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false));
// Home only Z axis when X and Y is trusted, otherwise all axes, if needed before this procedure
if (!all_axes_trusted()) process_subcommands_now_P(PSTR("G28Z"));
if (!all_axes_trusted()) process_subcommands_now(F("G28Z"));
bool err_break = false;

View File

@ -244,7 +244,7 @@ G29_TYPE GcodeSuite::G29() {
// Send 'N' to force homing before G29 (internal only)
if (parser.seen_test('N'))
process_subcommands_now_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));
process_subcommands_now(TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR)));
// Don't allow auto-leveling without homing first
if (homing_needed_error()) G29_RETURN(false);
@ -882,7 +882,7 @@ G29_TYPE GcodeSuite::G29() {
#ifdef Z_PROBE_END_SCRIPT
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
planner.synchronize();
process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT));
process_subcommands_now(F(Z_PROBE_END_SCRIPT));
#endif
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling());

View File

@ -47,7 +47,7 @@ void GcodeSuite::G34() {
TemporaryGlobalEndstopsState unlock_z(false);
#ifdef GANTRY_CALIBRATION_COMMANDS_PRE
gcode.process_subcommands_now_P(PSTR(GANTRY_CALIBRATION_COMMANDS_PRE));
process_subcommands_now(F(GANTRY_CALIBRATION_COMMANDS_PRE));
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Sub Commands Processed");
#endif
@ -148,7 +148,7 @@ void GcodeSuite::G34() {
#ifdef GANTRY_CALIBRATION_COMMANDS_POST
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Running Post Commands");
gcode.process_subcommands_now_P(PSTR(GANTRY_CALIBRATION_COMMANDS_POST));
process_subcommands_now(F(GANTRY_CALIBRATION_COMMANDS_POST));
#endif
SET_SOFT_ENDSTOP_LOOSE(false);

View File

@ -433,7 +433,7 @@ void GcodeSuite::G34() {
// After this operation the z position needs correction
set_axis_never_homed(Z_AXIS);
// Home Z after the alignment procedure
process_subcommands_now_P(PSTR("G28Z"));
process_subcommands_now(F("G28Z"));
#else
// Use the probed height from the last iteration to determine the Z height.
// z_measured_min is used, because all steppers are aligned to z_measured_min.

View File

@ -709,7 +709,7 @@ inline void calibrate_all() {
void GcodeSuite::G425() {
#ifdef CALIBRATION_SCRIPT_PRE
GcodeSuite::process_subcommands_now_P(PSTR(CALIBRATION_SCRIPT_PRE));
process_subcommands_now(F(CALIBRATION_SCRIPT_PRE));
#endif
if (homing_needed_error()) return;
@ -745,7 +745,7 @@ void GcodeSuite::G425() {
SET_SOFT_ENDSTOP_LOOSE(false);
#ifdef CALIBRATION_SCRIPT_POST
GcodeSuite::process_subcommands_now_P(PSTR(CALIBRATION_SCRIPT_POST));
process_subcommands_now(F(CALIBRATION_SCRIPT_POST));
#endif
}

View File

@ -158,7 +158,7 @@ void GcodeSuite::G76() {
return;
}
process_subcommands_now_P(G28_STR);
process_subcommands_now(FPSTR(G28_STR));
}
remember_feedrate_scaling_off();

View File

@ -110,7 +110,7 @@
set_duplication_enabled(false);
#ifdef EVENT_GCODE_IDEX_AFTER_MODECHANGE
gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_IDEX_AFTER_MODECHANGE));
process_subcommands_now(F(EVENT_GCODE_IDEX_AFTER_MODECHANGE));
#endif
}
else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default

View File

@ -138,10 +138,10 @@ void GcodeSuite::M916() {
do {
// turn the motor(s) both directions
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate));
gcode.process_subcommands_now_P(gcode_string);
process_subcommands_now(gcode_string);
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate));
gcode.process_subcommands_now_P(gcode_string);
process_subcommands_now(gcode_string);
// get the status after the motors have stopped
planner.synchronize();
@ -266,10 +266,10 @@ void GcodeSuite::M917() {
DEBUG_ECHOLNPGM(" OCD threshold : ", (OCD_TH_val + 1) * 375);
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate));
gcode.process_subcommands_now_P(gcode_string);
process_subcommands_now(gcode_string);
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate));
gcode.process_subcommands_now_P(gcode_string);
process_subcommands_now(gcode_string);
planner.synchronize();
@ -308,7 +308,7 @@ void GcodeSuite::M917() {
L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
}
DEBUG_ECHOLNPGM(".");
gcode.reset_stepper_timeout(); // keep steppers powered
reset_stepper_timeout(); // keep steppers powered
watchdog_refresh();
safe_delay(5000);
status_composite_temp = 0;
@ -615,10 +615,10 @@ void GcodeSuite::M918() {
DEBUG_ECHOLNPGM("...feedrate = ", current_feedrate);
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(current_feedrate));
gcode.process_subcommands_now_P(gcode_string);
process_subcommands_now(gcode_string);
sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(current_feedrate));
gcode.process_subcommands_now_P(gcode_string);
process_subcommands_now(gcode_string);
planner.synchronize();

View File

@ -50,7 +50,7 @@ void GcodeSuite::G12() {
#ifdef WIPE_SEQUENCE_COMMANDS
if (!parser.seen_any()) {
gcode.process_subcommands_now_P(PSTR(WIPE_SEQUENCE_COMMANDS));
process_subcommands_now(F(WIPE_SEQUENCE_COMMANDS));
return;
}
#endif

View File

@ -243,7 +243,7 @@ void GcodeSuite::dwell(millis_t time) {
host_action(PSTR(ACTION_ON_G29_RECOVER));
#endif
#ifdef G29_RECOVER_COMMANDS
process_subcommands_now_P(PSTR(G29_RECOVER_COMMANDS));
process_subcommands_now(F(G29_RECOVER_COMMANDS));
#endif
}
@ -256,7 +256,7 @@ void GcodeSuite::dwell(millis_t time) {
host_action(PSTR(ACTION_ON_G29_FAILURE));
#endif
#ifdef G29_FAILURE_COMMANDS
process_subcommands_now_P(PSTR(G29_FAILURE_COMMANDS));
process_subcommands_now(F(G29_FAILURE_COMMANDS));
#endif
#if ENABLED(G29_HALT_ON_FAILURE)
#ifdef ACTION_ON_CANCEL
@ -286,7 +286,7 @@ void GcodeSuite::dwell(millis_t time) {
TERN_(HOST_PROMPT_SUPPORT, host_action_prompt_end());
#ifdef G29_SUCCESS_COMMANDS
process_subcommands_now_P(PSTR(G29_SUCCESS_COMMANDS));
process_subcommands_now(F(G29_SUCCESS_COMMANDS));
#endif
}
@ -1101,7 +1101,8 @@ void GcodeSuite::process_next_command() {
* G-code "macros" to be called from within other G-code handlers.
*/
void GcodeSuite::process_subcommands_now_P(PGM_P pgcode) {
void GcodeSuite::process_subcommands_now(FSTR_P fgcode) {
PGM_P pgcode = FTOP(fgcode);
char * const saved_cmd = parser.command_ptr; // Save the parser state
for (;;) {
PGM_P const delim = strchr_P(pgcode, '\n'); // Get address of next newline

View File

@ -397,11 +397,11 @@ public:
static void process_next_command();
// Execute G-code in-place, preserving current G-code parameters
static void process_subcommands_now_P(PGM_P pgcode);
static void process_subcommands_now(FSTR_P fgcode);
static void process_subcommands_now(char * gcode);
static inline void home_all_axes(const bool keep_leveling=false) {
process_subcommands_now_P(keep_leveling ? G28_STR : TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));
process_subcommands_now(keep_leveling ? FPSTR(G28_STR) : TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR)));
}
#if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE)

View File

@ -403,7 +403,7 @@ void GcodeSuite::G2_G3(const bool clockwise) {
else {
#if ENABLED(CNC_WORKSPACE_PLANES)
char achar, bchar;
switch (gcode.workspace_plane) {
switch (workspace_plane) {
default:
case GcodeSuite::PLANE_XY: achar = 'I'; bchar = 'J'; break;
case GcodeSuite::PLANE_YZ: achar = 'J'; bchar = 'K'; break;

View File

@ -693,8 +693,8 @@ void GCodeQueue::advance() {
void GCodeQueue::report_buffer_statistics() {
SERIAL_ECHOLNPGM("D576"
" P:", planner.moves_free(), " ", -queue.planner_buffer_underruns, " (", queue.max_planner_buffer_empty_duration, ")"
" B:", BUFSIZE - ring_buffer.length, " ", -queue.command_buffer_underruns, " (", queue.max_command_buffer_empty_duration, ")"
" P:", planner.moves_free(), " ", -planner_buffer_underruns, " (", max_planner_buffer_empty_duration, ")"
" B:", BUFSIZE - ring_buffer.length, " ", -command_buffer_underruns, " (", max_command_buffer_empty_duration, ")"
);
command_buffer_underruns = planner_buffer_underruns = 0;
max_command_buffer_empty_duration = max_planner_buffer_empty_duration = 0;
@ -717,8 +717,8 @@ void GCodeQueue::advance() {
NOLESS(max_planner_buffer_empty_duration, planner_buffer_empty_duration); // if it's longer than the currently tracked max duration, replace it
}
if (queue.auto_buffer_report_interval && ELAPSED(ms, queue.next_buffer_report_ms)) {
queue.next_buffer_report_ms = ms + 1000UL * queue.auto_buffer_report_interval;
if (auto_buffer_report_interval && ELAPSED(ms, next_buffer_report_ms)) {
next_buffer_report_ms = ms + 1000UL * auto_buffer_report_interval;
PORT_REDIRECT(SERIAL_BOTH);
report_buffer_statistics();
PORT_RESTORE();

View File

@ -78,10 +78,10 @@ void GcodeSuite::M1001() {
// Report total print time
const bool long_print = print_job_timer.duration() > 60;
if (long_print) gcode.process_subcommands_now_P(PSTR("M31"));
if (long_print) process_subcommands_now(F("M31"));
// Stop the print job timer
gcode.process_subcommands_now_P(PSTR("M77"));
process_subcommands_now(F("M77"));
// Set the progress bar "done" state
TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done());
@ -105,7 +105,7 @@ void GcodeSuite::M1001() {
// Inject SD_FINISHED_RELEASECOMMAND, if any
#ifdef SD_FINISHED_RELEASECOMMAND
gcode.process_subcommands_now_P(PSTR(SD_FINISHED_RELEASECOMMAND));
process_subcommands_now(F(SD_FINISHED_RELEASECOMMAND));
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished());