🩹 Fix some parameters w/out values (#24051)

This commit is contained in:
DerAndere 2022-04-18 06:03:39 +02:00 committed by Scott Lahteine
parent 2bf6573098
commit 1ffc4ba861
17 changed files with 39 additions and 51 deletions

View file

@ -78,6 +78,7 @@ public:
constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; } constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; }
const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME); const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME);
const xyze_char_t iaxis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', 'I', 'J', 'K');
#if LINEAR_AXES <= XYZ #if LINEAR_AXES <= XYZ
#define AXIS_CHAR(A) ((char)('X' + A)) #define AXIS_CHAR(A) ((char)('X' + A))

View file

@ -45,7 +45,7 @@
DEBUG_SECTION(log_M666, "M666", DEBUGGING(LEVELING)); DEBUG_SECTION(log_M666, "M666", DEBUGGING(LEVELING));
bool is_err = false, is_set = false; bool is_err = false, is_set = false;
LOOP_LINEAR_AXES(i) { LOOP_LINEAR_AXES(i) {
if (parser.seen(AXIS_CHAR(i))) { if (parser.seenval(AXIS_CHAR(i))) {
is_set = true; is_set = true;
const float v = parser.value_linear_units(); const float v = parser.value_linear_units();
if (v > 0) if (v > 0)

View file

@ -47,8 +47,8 @@ void GcodeSuite::M281() {
return; return;
} }
#endif #endif
if (parser.seen('L')) servo_angles[servo_index][0] = parser.value_int(); if (parser.seenval('L')) servo_angles[servo_index][0] = parser.value_int();
if (parser.seen('U')) servo_angles[servo_index][1] = parser.value_int(); if (parser.seenval('U')) servo_angles[servo_index][1] = parser.value_int();
} }
else else
SERIAL_ERROR_MSG("Servo ", servo_index, " out of range"); SERIAL_ERROR_MSG("Servo ", servo_index, " out of range");

View file

@ -36,9 +36,9 @@
*/ */
void GcodeSuite::M304() { void GcodeSuite::M304() {
if (!parser.seen("PID")) return M304_report(); if (!parser.seen("PID")) return M304_report();
if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float(); if (parser.seenval('P')) thermalManager.temp_bed.pid.Kp = parser.value_float();
if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float()); if (parser.seenval('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float());
if (parser.seen('D')) thermalManager.temp_bed.pid.Kd = scalePID_d(parser.value_float()); if (parser.seenval('D')) thermalManager.temp_bed.pid.Kd = scalePID_d(parser.value_float());
} }
void GcodeSuite::M304_report(const bool forReplay/*=true*/) { void GcodeSuite::M304_report(const bool forReplay/*=true*/) {

View file

@ -52,19 +52,19 @@ void GcodeSuite::M305() {
if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0)) if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0))
SERIAL_ECHO_MSG("!Invalid index. (0 <= P <= ", USER_THERMISTORS - 1, ")"); SERIAL_ECHO_MSG("!Invalid index. (0 <= P <= ", USER_THERMISTORS - 1, ")");
else if (do_set) { else if (do_set) {
if (parser.seen('R')) // Pullup resistor value if (parser.seenval('R')) // Pullup resistor value
if (!thermalManager.set_pull_up_res(t_index, parser.value_float())) if (!thermalManager.set_pull_up_res(t_index, parser.value_float()))
SERIAL_ECHO_MSG("!Invalid series resistance. (0 < R < 1000000)"); SERIAL_ECHO_MSG("!Invalid series resistance. (0 < R < 1000000)");
if (parser.seen('T')) // Resistance at 25C if (parser.seenval('T')) // Resistance at 25C
if (!thermalManager.set_res25(t_index, parser.value_float())) if (!thermalManager.set_res25(t_index, parser.value_float()))
SERIAL_ECHO_MSG("!Invalid 25C resistance. (0 < T < 10000000)"); SERIAL_ECHO_MSG("!Invalid 25C resistance. (0 < T < 10000000)");
if (parser.seen('B')) // Beta value if (parser.seenval('B')) // Beta value
if (!thermalManager.set_beta(t_index, parser.value_float())) if (!thermalManager.set_beta(t_index, parser.value_float()))
SERIAL_ECHO_MSG("!Invalid beta. (0 < B < 1000000)"); SERIAL_ECHO_MSG("!Invalid beta. (0 < B < 1000000)");
if (parser.seen('C')) // Steinhart-Hart C coefficient if (parser.seenval('C')) // Steinhart-Hart C coefficient
if (!thermalManager.set_sh_coeff(t_index, parser.value_float())) if (!thermalManager.set_sh_coeff(t_index, parser.value_float()))
SERIAL_ECHO_MSG("!Invalid Steinhart-Hart C coeff. (-0.01 < C < +0.01)"); SERIAL_ECHO_MSG("!Invalid Steinhart-Hart C coeff. (-0.01 < C < +0.01)");
} // If not setting then report parameters } // If not setting then report parameters

View file

@ -125,14 +125,8 @@ void GcodeSuite::M17() {
stepper.enable_e_steppers(); stepper.enable_e_steppers();
} }
#endif #endif
LINEAR_AXIS_CODE( LOOP_LINEAR_AXES(a)
if (parser.seen_test('X')) stepper.enable_axis(X_AXIS), if (parser.seen_test(AXIS_CHAR(a))) stepper.enable_axis((AxisEnum)a);
if (parser.seen_test('Y')) stepper.enable_axis(Y_AXIS),
if (parser.seen_test('Z')) stepper.enable_axis(Z_AXIS),
if (parser.seen_test(AXIS4_NAME)) stepper.enable_axis(I_AXIS),
if (parser.seen_test(AXIS5_NAME)) stepper.enable_axis(J_AXIS),
if (parser.seen_test(AXIS6_NAME)) stepper.enable_axis(K_AXIS)
);
} }
} }
else { else {
@ -238,14 +232,8 @@ void GcodeSuite::M18_M84() {
stepper.disable_e_steppers(); stepper.disable_e_steppers();
} }
#endif #endif
LINEAR_AXIS_CODE( LOOP_LINEAR_AXES(a)
if (parser.seen_test('X')) stepper.disable_axis(X_AXIS), if (parser.seen_test(AXIS_CHAR(a))) stepper.disable_axis((AxisEnum)a);
if (parser.seen_test('Y')) stepper.disable_axis(Y_AXIS),
if (parser.seen_test('Z')) stepper.disable_axis(Z_AXIS),
if (parser.seen_test(AXIS4_NAME)) stepper.disable_axis(I_AXIS),
if (parser.seen_test(AXIS5_NAME)) stepper.disable_axis(J_AXIS),
if (parser.seen_test(AXIS6_NAME)) stepper.disable_axis(K_AXIS)
);
} }
} }
else else

View file

@ -48,7 +48,7 @@ void GcodeSuite::M280() {
const int anew = parser.value_int(); const int anew = parser.value_int();
if (anew >= 0) { if (anew >= 0) {
#if ENABLED(POLARGRAPH) #if ENABLED(POLARGRAPH)
if (parser.seen('T')) { // (ms) Total duration of servo move if (parser.seenval('T')) { // (ms) Total duration of servo move
const int16_t t = constrain(parser.value_int(), 0, 10000); const int16_t t = constrain(parser.value_int(), 0, 10000);
const int aold = servo[servo_index].read(); const int aold = servo[servo_index].read();
millis_t now = millis(); millis_t now = millis();

View file

@ -93,7 +93,7 @@ void GcodeSuite::M3_M4(const bool is_M4) {
// Laser power in inline mode // Laser power in inline mode
cutter.inline_direction(is_M4); // Should always be unused cutter.inline_direction(is_M4); // Should always be unused
#if ENABLED(SPINDLE_LASER_USE_PWM) #if ENABLED(SPINDLE_LASER_USE_PWM)
if (parser.seen('O')) { if (parser.seenval('O')) {
cutter.unitPower = cutter.power_to_range(parser.value_byte(), 0); cutter.unitPower = cutter.power_to_range(parser.value_byte(), 0);
cutter.inline_ocr_power(cutter.unitPower); // The OCR is a value from 0 to 255 (uint8_t) cutter.inline_ocr_power(cutter.unitPower); // The OCR is a value from 0 to 255 (uint8_t)
} }

View file

@ -33,9 +33,9 @@
* Warning: Steps-per-unit remains unchanged. * Warning: Steps-per-unit remains unchanged.
*/ */
void GcodeSuite::M350() { void GcodeSuite::M350() {
if (parser.seen('S')) LOOP_LE_N(i, 4) stepper.microstep_mode(i, parser.value_byte()); if (parser.seen('S')) LOOP_DISTINCT_AXES(i) stepper.microstep_mode(i, parser.value_byte());
LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) stepper.microstep_mode(i, parser.value_byte()); LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_mode(i, parser.value_byte());
if (parser.seen('B')) stepper.microstep_mode(4, parser.value_byte()); if (parser.seenval('B')) stepper.microstep_mode(E_AXIS + 1, parser.value_byte());
stepper.microstep_readings(); stepper.microstep_readings();
} }

View file

@ -64,7 +64,7 @@
void GcodeSuite::M605() { void GcodeSuite::M605() {
planner.synchronize(); planner.synchronize();
if (parser.seen('S')) { if (parser.seenval('S')) {
const DualXMode previous_mode = dual_x_carriage_mode; const DualXMode previous_mode = dual_x_carriage_mode;
dual_x_carriage_mode = (DualXMode)parser.value_byte(); dual_x_carriage_mode = (DualXMode)parser.value_byte();
@ -78,8 +78,8 @@
case DXC_DUPLICATION_MODE: case DXC_DUPLICATION_MODE:
// Set the X offset, but no less than the safety gap // Set the X offset, but no less than the safety gap
if (parser.seen('X')) duplicate_extruder_x_offset = _MAX(parser.value_linear_units(), (X2_MIN_POS) - (X1_MIN_POS)); if (parser.seenval('X')) duplicate_extruder_x_offset = _MAX(parser.value_linear_units(), (X2_MIN_POS) - (X1_MIN_POS));
if (parser.seen('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff(); if (parser.seenval('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff();
// Always switch back to tool 0 // Always switch back to tool 0
if (active_extruder != 0) tool_change(0); if (active_extruder != 0) tool_change(0);
break; break;

View file

@ -44,14 +44,14 @@ void GcodeSuite::M486() {
cancelable.object_count = parser.intval('T', 1); cancelable.object_count = parser.intval('T', 1);
} }
if (parser.seen('S')) if (parser.seenval('S'))
cancelable.set_active_object(parser.value_int()); cancelable.set_active_object(parser.value_int());
if (parser.seen('C')) cancelable.cancel_active_object(); if (parser.seen('C')) cancelable.cancel_active_object();
if (parser.seen('P')) cancelable.cancel_object(parser.value_int()); if (parser.seenval('P')) cancelable.cancel_object(parser.value_int());
if (parser.seen('U')) cancelable.uncancel_object(parser.value_int()); if (parser.seenval('U')) cancelable.uncancel_object(parser.value_int());
} }
#endif // CANCEL_OBJECTS #endif // CANCEL_OBJECTS

View file

@ -45,10 +45,10 @@
*/ */
void GcodeSuite::M260() { void GcodeSuite::M260() {
// Set the target address // Set the target address
if (parser.seen('A')) i2c.address(parser.value_byte()); if (parser.seenval('A')) i2c.address(parser.value_byte());
// Add a new byte to the buffer // Add a new byte to the buffer
if (parser.seen('B')) i2c.addbyte(parser.value_byte()); if (parser.seenval('B')) i2c.addbyte(parser.value_byte());
// Flush the buffer to the bus // Flush the buffer to the bus
if (parser.seen('S')) i2c.send(); if (parser.seen('S')) i2c.send();
@ -63,7 +63,7 @@ void GcodeSuite::M260() {
* Usage: M261 A<slave device address base 10> B<number of bytes> S<style> * Usage: M261 A<slave device address base 10> B<number of bytes> S<style>
*/ */
void GcodeSuite::M261() { void GcodeSuite::M261() {
if (parser.seen('A')) i2c.address(parser.value_byte()); if (parser.seenval('A')) i2c.address(parser.value_byte());
const uint8_t bytes = parser.byteval('B', 1), // Bytes to request const uint8_t bytes = parser.byteval('B', 1), // Bytes to request
style = parser.byteval('S'); // Serial output style (ASCII, HEX etc) style = parser.byteval('S'); // Serial output style (ASCII, HEX etc)

View file

@ -71,7 +71,7 @@ void GcodeSuite::G61() {
if (parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K))) { if (parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K))) {
DEBUG_ECHOPGM(STR_RESTORING_POS " S", slot); DEBUG_ECHOPGM(STR_RESTORING_POS " S", slot);
LOOP_LINEAR_AXES(i) { LOOP_LINEAR_AXES(i) {
destination[i] = parser.seen(AXIS_CHAR(i)) destination[i] = parser.seenval(AXIS_CHAR(i))
? stored_position[slot][i] + parser.value_axis_units((AxisEnum)i) ? stored_position[slot][i] + parser.value_axis_units((AxisEnum)i)
: current_position[i]; : current_position[i];
DEBUG_CHAR(' ', AXIS_CHAR(i)); DEBUG_CHAR(' ', AXIS_CHAR(i));

View file

@ -48,7 +48,7 @@ void GcodeSuite::M603() {
if (target_extruder < 0) return; if (target_extruder < 0) return;
// Unload length // Unload length
if (parser.seen('U')) { if (parser.seenval('U')) {
fc_settings[target_extruder].unload_length = ABS(parser.value_axis_units(E_AXIS)); fc_settings[target_extruder].unload_length = ABS(parser.value_axis_units(E_AXIS));
#if ENABLED(PREVENT_LENGTHY_EXTRUDE) #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
NOMORE(fc_settings[target_extruder].unload_length, EXTRUDE_MAXLENGTH); NOMORE(fc_settings[target_extruder].unload_length, EXTRUDE_MAXLENGTH);
@ -56,7 +56,7 @@ void GcodeSuite::M603() {
} }
// Load length // Load length
if (parser.seen('L')) { if (parser.seenval('L')) {
fc_settings[target_extruder].load_length = ABS(parser.value_axis_units(E_AXIS)); fc_settings[target_extruder].load_length = ABS(parser.value_axis_units(E_AXIS));
#if ENABLED(PREVENT_LENGTHY_EXTRUDE) #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
NOMORE(fc_settings[target_extruder].load_length, EXTRUDE_MAXLENGTH); NOMORE(fc_settings[target_extruder].load_length, EXTRUDE_MAXLENGTH);

View file

@ -106,8 +106,8 @@ void GcodeSuite::M701() {
#else #else
constexpr float purge_length = ADVANCED_PAUSE_PURGE_LENGTH, constexpr float purge_length = ADVANCED_PAUSE_PURGE_LENGTH,
slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH; slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) const float fast_load_length = ABS(parser.seenval('L') ? parser.value_axis_units(E_AXIS)
: fc_settings[active_extruder].load_length); : fc_settings[active_extruder].load_length);
load_filament( load_filament(
slow_load_length, fast_load_length, purge_length, slow_load_length, fast_load_length, purge_length,
FILAMENT_CHANGE_ALERT_BEEPS, FILAMENT_CHANGE_ALERT_BEEPS,

View file

@ -48,7 +48,7 @@ void GcodeSuite::M412() {
if (seenR || seenS) runout.reset(); if (seenR || seenS) runout.reset();
if (seenS) runout.enabled = parser.value_bool(); if (seenS) runout.enabled = parser.value_bool();
#if HAS_FILAMENT_RUNOUT_DISTANCE #if HAS_FILAMENT_RUNOUT_DISTANCE
if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units()); if (parser.seenval('D')) runout.set_runout_distance(parser.value_linear_units());
#endif #endif
} }
else { else {

View file

@ -40,13 +40,12 @@
void GcodeSuite::M206() { void GcodeSuite::M206() {
if (!parser.seen_any()) return M206_report(); if (!parser.seen_any()) return M206_report();
LOOP_LINEAR_AXES(i) LOOP_LINEAR_AXES(a)
if (parser.seen(AXIS_CHAR(i))) if (parser.seenval(AXIS_CHAR(a))) set_home_offset((AxisEnum)a, parser.value_axis_units((AxisEnum)a));
set_home_offset((AxisEnum)i, parser.value_linear_units());
#if ENABLED(MORGAN_SCARA) #if ENABLED(MORGAN_SCARA)
if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta if (parser.seenval('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta
if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi if (parser.seenval('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi
#endif #endif
report_current_position(); report_current_position();