Optimize some G-code strings

This commit is contained in:
Scott Lahteine 2021-01-16 20:43:24 -06:00
parent e351ea2ee8
commit aabd40a7a2
11 changed files with 42 additions and 88 deletions

View File

@ -38,7 +38,7 @@
#include "../../feature/probe_temp_comp.h" #include "../../feature/probe_temp_comp.h"
#include "../../lcd/marlinui.h" #include "../../lcd/marlinui.h"
#include "../../MarlinCore.h" // for wait_for_heatup and idle() #include "../../MarlinCore.h" // for wait_for_heatup, idle(), G28_STR
#if ENABLED(PRINTJOB_TIMER_AUTOSTART) #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
#include "../../module/printcounter.h" #include "../../module/printcounter.h"
@ -168,7 +168,7 @@ void GcodeSuite::G76() {
return; return;
} }
process_subcommands_now_P(PSTR("G28")); process_subcommands_now_P(G28_STR);
} }
remember_feedrate_scaling_off(); remember_feedrate_scaling_off();

View File

@ -2332,7 +2332,7 @@ void HMI_Prepare() {
case PREPARE_CASE_HOME: // Homing case PREPARE_CASE_HOME: // Homing
checkkey = Last_Prepare; checkkey = Last_Prepare;
index_prepare = MROWS; index_prepare = MROWS;
queue.inject_P(PSTR("G28")); // G28 will set home_flag queue.inject_P(G28_STR); // G28 will set home_flag
Popup_Window_Home(); Popup_Window_Home();
break; break;
#if HAS_ZOFFSET_ITEM #if HAS_ZOFFSET_ITEM

View File

@ -620,10 +620,10 @@ namespace Anycubic {
case 21: // A21 Home Axis A21 X case 21: // A21 Home Axis A21 X
if (!isPrinting()) { if (!isPrinting()) {
switch ((char)panel_command[4]) { switch ((char)panel_command[4]) {
case 'X': injectCommands_P(PSTR("G28 X")); break; case 'X': injectCommands_P(PSTR("G28X")); break;
case 'Y': injectCommands_P(PSTR("G28 Y")); break; case 'Y': injectCommands_P(PSTR("G28Y")); break;
case 'Z': injectCommands_P(PSTR("G28 Z")); break; case 'Z': injectCommands_P(PSTR("G28Z")); break;
case 'C': injectCommands_P(PSTR("G28")); break; case 'C': injectCommands_P(G28_STR); break;
} }
} }
break; break;
@ -718,7 +718,7 @@ namespace Anycubic {
// If the same meshpoint is selected twice in a row, move the head to that ready for adjustment // If the same meshpoint is selected twice in a row, move the head to that ready for adjustment
if ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) { if ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) {
if (!isPositionKnown()) if (!isPositionKnown())
injectCommands_P(PSTR("G28")); // home injectCommands_P(G28_STR); // home
if (isPositionKnown()) { if (isPositionKnown()) {
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
@ -746,7 +746,7 @@ namespace Anycubic {
if (isPrinting()) if (isPrinting())
SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling
else { else {
injectCommands_P(isMachineHomed() ? PSTR("G29") : PSTR("G28\nG29")); injectCommands_P(PSTR("G28O\nG29"));
printer_state = AC_printer_probing; printer_state = AC_printer_probing;
SendtoTFTLN(AC_msg_start_probing); SendtoTFTLN(AC_msg_start_probing);
} }

View File

@ -105,8 +105,8 @@
#define AC_cmnd_manual_load_filament PSTR("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster #define AC_cmnd_manual_load_filament PSTR("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster
#define AC_cmnd_manual_unload_filament PSTR("M83\nG1 E-50 F1200\nM82") #define AC_cmnd_manual_unload_filament PSTR("M83\nG1 E-50 F1200\nM82")
#define AC_cmnd_enable_leveling PSTR("M420 S1 V1") #define AC_cmnd_enable_leveling PSTR("M420SV")
#define AC_cmnd_power_loss_recovery PSTR("G28 X Y R5\nG28 Z") // Lift, home X and Y then home Z when in 'safe' position #define AC_cmnd_power_loss_recovery PSTR("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position
namespace Anycubic { namespace Anycubic {
enum heater_state_t : uint8_t { enum heater_state_t : uint8_t {

View File

@ -28,7 +28,7 @@
#include "../../../../libs/numtostr.h" #include "../../../../libs/numtostr.h"
#include "../../../../module/motion.h" // for A20 read printing speed feedrate_percentage #include "../../../../module/motion.h" // for A20 read printing speed feedrate_percentage
#include "../../../../MarlinCore.h" // for quickstop_stepper and disable_steppers #include "../../../../MarlinCore.h" // for quickstop_stepper, disable_steppers, G28_STR
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
// command sending macro's with debugging capability // command sending macro's with debugging capability
@ -274,12 +274,12 @@ void AnycubicTFTClass::HandleSpecialMenu() {
case '6': // "<06SMeshLvl>" case '6': // "<06SMeshLvl>"
SERIAL_ECHOLNPGM("Special Menu: Start Mesh Leveling"); SERIAL_ECHOLNPGM("Special Menu: Start Mesh Leveling");
ExtUI::injectCommands_P(PSTR("G29 S1")); ExtUI::injectCommands_P(PSTR("G29S1"));
break; break;
case '7': // "<07MeshNPnt>" case '7': // "<07MeshNPnt>"
SERIAL_ECHOLNPGM("Special Menu: Next Mesh Point"); SERIAL_ECHOLNPGM("Special Menu: Next Mesh Point");
ExtUI::injectCommands_P(PSTR("G29 S2")); ExtUI::injectCommands_P(PSTR("G29S2"));
break; break;
case '8': // "<08HtEndPID>" case '8': // "<08HtEndPID>"
@ -758,14 +758,14 @@ void AnycubicTFTClass::GetCommandFromTFT() {
if (!ExtUI::isPrinting() && !ExtUI::isPrintingFromMediaPaused()) { if (!ExtUI::isPrinting() && !ExtUI::isPrintingFromMediaPaused()) {
if (CodeSeen('X') || CodeSeen('Y') || CodeSeen('Z')) { if (CodeSeen('X') || CodeSeen('Y') || CodeSeen('Z')) {
if (CodeSeen('X')) if (CodeSeen('X'))
ExtUI::injectCommands_P(PSTR("G28 X")); ExtUI::injectCommands_P(PSTR("G28X"));
if (CodeSeen('Y')) if (CodeSeen('Y'))
ExtUI::injectCommands_P(PSTR("G28 Y")); ExtUI::injectCommands_P(PSTR("G28Y"));
if (CodeSeen('Z')) if (CodeSeen('Z'))
ExtUI::injectCommands_P(PSTR("G28 Z")); ExtUI::injectCommands_P(PSTR("G28Z"));
} }
else if (CodeSeen('C')) { else if (CodeSeen('C')) {
ExtUI::injectCommands_P(PSTR("G28")); ExtUI::injectCommands_P(G28_STR);
} }
} }
break; break;

View File

@ -319,7 +319,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) {
case 9: GOTO_SCREEN(FilesScreen); break; case 9: GOTO_SCREEN(FilesScreen); break;
case 10: GOTO_SCREEN(MainMenu); break; case 10: GOTO_SCREEN(MainMenu); break;
case 13: GOTO_SCREEN(BioConfirmHomeE); break; case 13: GOTO_SCREEN(BioConfirmHomeE); break;
case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28 Z")); break; case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break;
case 15: GOTO_SCREEN(TemperatureScreen); break; case 15: GOTO_SCREEN(TemperatureScreen); break;
case 16: fine_motion = !fine_motion; break; case 16: fine_motion = !fine_motion; break;
default: return false; default: return false;

View File

@ -94,9 +94,9 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) {
case 14: UI_DECREMENT_AXIS(E3); screen_data.MoveAxis.e_rel[3] -= increment; break; case 14: UI_DECREMENT_AXIS(E3); screen_data.MoveAxis.e_rel[3] -= increment; break;
case 15: UI_INCREMENT_AXIS(E3); screen_data.MoveAxis.e_rel[3] += increment; break; case 15: UI_INCREMENT_AXIS(E3); screen_data.MoveAxis.e_rel[3] += increment; break;
#endif #endif
case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28 X")); break; case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28X")); break;
case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28 Y")); break; case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28Y")); break;
case 22: SpinnerDialogBox::enqueueAndWait_P(F("G28 Z")); break; case 22: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break;
case 23: SpinnerDialogBox::enqueueAndWait_P(F("G28")); break; case 23: SpinnerDialogBox::enqueueAndWait_P(F("G28")); break;
default: default:
return false; return false;

View File

@ -31,6 +31,8 @@
#include "../../../../gcode/queue.h" #include "../../../../gcode/queue.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern const char G28_STR[];
extern lv_group_t *g; extern lv_group_t *g;
static lv_obj_t *scr; static lv_obj_t *scr;
@ -48,22 +50,22 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return; if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_H_ALL: case ID_H_ALL:
queue.inject_P(PSTR("G28")); queue.inject_P(G28_STR);
break; break;
case ID_H_X: case ID_H_X:
queue.inject_P(PSTR("G28 X0")); queue.inject_P(PSTR("G28X"));
break; break;
case ID_H_Y: case ID_H_Y:
queue.inject_P(PSTR("G28 Y0")); queue.inject_P(PSTR("G28Y"));
break; break;
case ID_H_Z: case ID_H_Z:
queue.inject_P(PSTR("G28 Z0")); queue.inject_P(PSTR("G28Z"));
break; break;
case ID_H_OFF_ALL: case ID_H_OFF_ALL:
queue.inject_P(PSTR("M84")); queue.inject_P(PSTR("M84"));
break; break;
case ID_H_OFF_XY: case ID_H_OFF_XY:
queue.inject_P(PSTR("M84 X Y")); queue.inject_P(PSTR("M84XY"));
break; break;
case ID_H_RETURN: case ID_H_RETURN:
clear_cur_ui(); clear_cur_ui();

View File

@ -29,6 +29,8 @@
#include "../../../../gcode/queue.h" #include "../../../../gcode/queue.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern const char G28_STR[];
extern lv_group_t *g; extern lv_group_t *g;
static lv_obj_t *scr; static lv_obj_t *scr;
@ -45,65 +47,15 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return; if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_M_POINT1: case ID_M_POINT1 ... ID_M_POINT5:
if (queue.length == 0) { if (queue.length == 0) {
if (uiCfg.leveling_first_time) { if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28")); uiCfg.leveling_first_time = false;
uiCfg.leveling_first_time = 0; queue.inject_P(G28_STR);
} }
queue.enqueue_now_P(PSTR("G1 Z10")); const int ind = obj->mks_obj_id - ID_M_POINT1;
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[0][0], (int)gCfgItems.levelingPos[0][1]); sprintf_P(public_buf_l, PSTR("G1 Z10\nG1 X%d Y%d\nG1 Z0"), (int)gCfgItems.levelingPos[ind][0], (int)gCfgItems.levelingPos[ind][1]);
queue.enqueue_one_now(public_buf_l); queue.inject(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
}
break;
case ID_M_POINT2:
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
}
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[1][0], (int)gCfgItems.levelingPos[1][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
}
break;
case ID_M_POINT3:
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
}
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[2][0], (int)gCfgItems.levelingPos[2][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
}
break;
case ID_M_POINT4:
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
}
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[3][0], (int)gCfgItems.levelingPos[3][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
}
break;
case ID_M_POINT5:
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
}
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[4][0], (int)gCfgItems.levelingPos[4][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
break; break;
case ID_MANUAL_RETURN: case ID_MANUAL_RETURN:

View File

@ -103,9 +103,9 @@
ui.wait_for_move = true; ui.wait_for_move = true;
ui.goto_screen(_lcd_level_bed_done); ui.goto_screen(_lcd_level_bed_done);
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
queue.inject_P(PSTR("G29 S2")); queue.inject_P(PSTR("G29S2"));
#elif ENABLED(PROBE_MANUALLY) #elif ENABLED(PROBE_MANUALLY)
queue.inject_P(PSTR("G29 V1")); queue.inject_P(PSTR("G29V1"));
#endif #endif
} }
else else
@ -155,9 +155,9 @@
// G29 Records Z, moves, and signals when it pauses // G29 Records Z, moves, and signals when it pauses
ui.wait_for_move = true; ui.wait_for_move = true;
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
queue.inject_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1")); queue.inject_P(manual_probe_index ? PSTR("G29S2") : PSTR("G29S1"));
#elif ENABLED(PROBE_MANUALLY) #elif ENABLED(PROBE_MANUALLY)
queue.inject_P(PSTR("G29 V1")); queue.inject_P(PSTR("G29V1"));
#endif #endif
} }

View File

@ -402,7 +402,7 @@ void menu_motion() {
#endif #endif
#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
GCODES_ITEM(MSG_M48_TEST, PSTR("G28 O\nM48 P10")); GCODES_ITEM(MSG_M48_TEST, PSTR("G28O\nM48 P10"));
#endif #endif
// //