Optimize G-code flag parameters (#21849)
This commit is contained in:
committed by
Scott Lahteine
parent
770edea577
commit
6a1e78e614
@ -648,12 +648,12 @@ void GcodeSuite::G26() {
|
||||
#if HAS_LCD_MENU
|
||||
g26_repeats = parser.intval('R', GRID_MAX_POINTS + 1);
|
||||
#else
|
||||
if (!parser.seen('R')) {
|
||||
if (parser.seen('R'))
|
||||
g26_repeats = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1;
|
||||
else {
|
||||
SERIAL_ECHOLNPGM("?(R)epeat must be specified when not using an LCD.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
g26_repeats = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1;
|
||||
#endif
|
||||
if (g26_repeats < 1) {
|
||||
SERIAL_ECHOLNPGM("?(R)epeat value not plausible; must be at least 1.");
|
||||
@ -671,7 +671,7 @@ void GcodeSuite::G26() {
|
||||
/**
|
||||
* Wait until all parameters are verified before altering the state!
|
||||
*/
|
||||
set_bed_leveling_enabled(!parser.seen('D'));
|
||||
set_bed_leveling_enabled(!parser.seen_test('D'));
|
||||
|
||||
do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES);
|
||||
|
||||
|
@ -133,7 +133,7 @@ void GcodeSuite::M420() {
|
||||
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
||||
|
||||
const bool seenV = parser.seen('V');
|
||||
const bool seenV = parser.seen_test('V');
|
||||
|
||||
#if HAS_MESH
|
||||
|
||||
|
@ -223,7 +223,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
|
||||
reset_stepper_timeout();
|
||||
|
||||
const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen('Q');
|
||||
const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen_test('Q');
|
||||
|
||||
// G29 Q is also available if debugging
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
@ -235,7 +235,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false);
|
||||
#endif
|
||||
|
||||
const bool seenA = TERN0(PROBE_MANUALLY, parser.seen('A')),
|
||||
const bool seenA = TERN0(PROBE_MANUALLY, parser.seen_test('A')),
|
||||
no_action = seenA || seenQ,
|
||||
faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
|
||||
|
||||
@ -245,7 +245,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
}
|
||||
|
||||
// Send 'N' to force homing before G29 (internal only)
|
||||
if (parser.seen('N'))
|
||||
if (parser.seen_test('N'))
|
||||
process_subcommands_now_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
|
||||
|
||||
// Don't allow auto-leveling without homing first
|
||||
@ -275,7 +275,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
||||
const bool seen_w = parser.seen('W');
|
||||
const bool seen_w = parser.seen_test('W');
|
||||
if (seen_w) {
|
||||
if (!leveling_is_valid()) {
|
||||
SERIAL_ERROR_MSG("No bilinear grid");
|
||||
@ -308,7 +308,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
if (abl.reenable) report_current_position();
|
||||
}
|
||||
G29_RETURN(false);
|
||||
} // parser.seen('W')
|
||||
} // parser.seen_test('W')
|
||||
|
||||
#else
|
||||
|
||||
@ -317,7 +317,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
#endif
|
||||
|
||||
// Jettison bed leveling data
|
||||
if (!seen_w && parser.seen('J')) {
|
||||
if (!seen_w && parser.seen_test('J')) {
|
||||
reset_bed_level();
|
||||
G29_RETURN(false);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void GcodeSuite::G29() {
|
||||
mbl.reset();
|
||||
mbl_probe_index = 0;
|
||||
if (!ui.wait_for_move) {
|
||||
queue.inject_P(parser.seen('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2"));
|
||||
queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2"));
|
||||
return;
|
||||
}
|
||||
state = MeshNext;
|
||||
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* unified.cpp - Unified Bed Leveling
|
||||
* M421.cpp - Unified Bed Leveling
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
@ -39,31 +39,34 @@
|
||||
* M421: Set a single Mesh Bed Leveling Z coordinate
|
||||
*
|
||||
* Usage:
|
||||
* M421 I<xindex> J<yindex> Z<linear>
|
||||
* M421 I<xindex> J<yindex> Q<offset>
|
||||
* M421 I<xindex> J<yindex> N
|
||||
* M421 C Z<linear>
|
||||
* M421 C Q<offset>
|
||||
* M421 I<xindex> J<yindex> Z<linear> : Set the Mesh Point IJ to the Z value
|
||||
* M421 I<xindex> J<yindex> Q<offset> : Add the Q value to the Mesh Point IJ
|
||||
* M421 I<xindex> J<yindex> N : Set the Mesh Point IJ to NAN (not set)
|
||||
* M421 C Z<linear> : Set the closest Mesh Point to the Z value
|
||||
* M421 C Q<offset> : Add the Q value to the closest Mesh Point
|
||||
*/
|
||||
void GcodeSuite::M421() {
|
||||
xy_int8_t ij = { int8_t(parser.intval('I', -1)), int8_t(parser.intval('J', -1)) };
|
||||
const bool hasI = ij.x >= 0,
|
||||
hasJ = ij.y >= 0,
|
||||
hasC = parser.seen('C'),
|
||||
hasN = parser.seen('N'),
|
||||
hasC = parser.seen_test('C'),
|
||||
hasN = parser.seen_test('N'),
|
||||
hasZ = parser.seen('Z'),
|
||||
hasQ = !hasZ && parser.seen('Q');
|
||||
|
||||
if (hasC) ij = ubl.find_closest_mesh_point_of_type(CLOSEST, current_position);
|
||||
|
||||
// Test for bad parameter combinations
|
||||
if (int(hasC) + int(hasI && hasJ) != 1 || !(hasZ || hasQ || hasN))
|
||||
SERIAL_ERROR_MSG(STR_ERR_M421_PARAMETERS);
|
||||
|
||||
// Test for I J out of range
|
||||
else if (!WITHIN(ij.x, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(ij.y, 0, GRID_MAX_POINTS_Y - 1))
|
||||
SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
|
||||
else {
|
||||
float &zval = ubl.z_values[ij.x][ij.y];
|
||||
zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0);
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));
|
||||
float &zval = ubl.z_values[ij.x][ij.y]; // Altering this Mesh Point
|
||||
zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0); // N=NAN, Z=NEWVAL, or Q=ADDVAL
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval)); // Ping ExtUI in case it's showing the mesh
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user