Optimize some G-code strings

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

View File

@ -38,7 +38,7 @@
#include "../../feature/probe_temp_comp.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)
#include "../../module/printcounter.h"
@ -168,7 +168,7 @@ void GcodeSuite::G76() {
return;
}
process_subcommands_now_P(PSTR("G28"));
process_subcommands_now_P(G28_STR);
}
remember_feedrate_scaling_off();

View File

@ -2332,7 +2332,7 @@ void HMI_Prepare() {
case PREPARE_CASE_HOME: // Homing
checkkey = Last_Prepare;
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();
break;
#if HAS_ZOFFSET_ITEM

View File

@ -623,7 +623,7 @@ namespace Anycubic {
case 'X': injectCommands_P(PSTR("G28X")); break;
case 'Y': injectCommands_P(PSTR("G28Y")); break;
case 'Z': injectCommands_P(PSTR("G28Z")); break;
case 'C': injectCommands_P(PSTR("G28")); break;
case 'C': injectCommands_P(G28_STR); 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 ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) {
if (!isPositionKnown())
injectCommands_P(PSTR("G28")); // home
injectCommands_P(G28_STR); // home
if (isPositionKnown()) {
#if ACDEBUG(AC_INFO)
@ -746,7 +746,7 @@ namespace Anycubic {
if (isPrinting())
SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling
else {
injectCommands_P(isMachineHomed() ? PSTR("G29") : PSTR("G28\nG29"));
injectCommands_P(PSTR("G28O\nG29"));
printer_state = AC_printer_probing;
SendtoTFTLN(AC_msg_start_probing);
}

View File

@ -105,7 +105,7 @@
#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_enable_leveling PSTR("M420 S1 V1")
#define AC_cmnd_enable_leveling PSTR("M420SV")
#define AC_cmnd_power_loss_recovery PSTR("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position
namespace Anycubic {

View File

@ -28,7 +28,7 @@
#include "../../../../libs/numtostr.h"
#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"
// command sending macro's with debugging capability
@ -765,7 +765,7 @@ void AnycubicTFTClass::GetCommandFromTFT() {
ExtUI::injectCommands_P(PSTR("G28Z"));
}
else if (CodeSeen('C')) {
ExtUI::injectCommands_P(PSTR("G28"));
ExtUI::injectCommands_P(G28_STR);
}
}
break;

View File

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

View File

@ -29,6 +29,8 @@
#include "../../../../gcode/queue.h"
#include "../../../../inc/MarlinConfig.h"
extern const char G28_STR[];
extern lv_group_t *g;
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;
switch (obj->mks_obj_id) {
case ID_M_POINT1:
case ID_M_POINT1 ... ID_M_POINT5:
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
uiCfg.leveling_first_time = false;
queue.inject_P(G28_STR);
}
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[0][0], (int)gCfgItems.levelingPos[0][1]);
queue.enqueue_one_now(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"));
const int ind = obj->mks_obj_id - ID_M_POINT1;
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.inject(public_buf_l);
}
break;
case ID_MANUAL_RETURN: