Cleanups to gcode.h, use seenval()
This commit is contained in:
parent
941943c167
commit
12f092c812
4 changed files with 86 additions and 88 deletions
|
@ -638,11 +638,11 @@
|
||||||
g26_hotend_temp = HOTEND_TEMP;
|
g26_hotend_temp = HOTEND_TEMP;
|
||||||
g26_prime_flag = 0;
|
g26_prime_flag = 0;
|
||||||
|
|
||||||
g26_ooze_amount = parser.seen('O') && parser.has_value() ? parser.value_linear_units() : OOZE_AMOUNT;
|
g26_ooze_amount = parser.seenval('O') ? parser.value_linear_units() : OOZE_AMOUNT;
|
||||||
g26_keep_heaters_on = parser.seen('K') && parser.value_bool();
|
g26_keep_heaters_on = parser.seen('K') && parser.value_bool();
|
||||||
g26_continue_with_closest = parser.seen('C') && parser.value_bool();
|
g26_continue_with_closest = parser.seen('C') && parser.value_bool();
|
||||||
|
|
||||||
if (parser.seen('B')) {
|
if (parser.seenval('B')) {
|
||||||
g26_bed_temp = parser.value_celsius();
|
g26_bed_temp = parser.value_celsius();
|
||||||
if (!WITHIN(g26_bed_temp, 15, 140)) {
|
if (!WITHIN(g26_bed_temp, 15, 140)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible.");
|
SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible.");
|
||||||
|
@ -650,7 +650,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.seen('L')) {
|
if (parser.seenval('L')) {
|
||||||
g26_layer_height = parser.value_linear_units();
|
g26_layer_height = parser.value_linear_units();
|
||||||
if (!WITHIN(g26_layer_height, 0.0, 2.0)) {
|
if (!WITHIN(g26_layer_height, 0.0, 2.0)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
|
SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
|
||||||
|
@ -672,7 +672,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.seen('S')) {
|
if (parser.seenval('S')) {
|
||||||
g26_nozzle = parser.value_float();
|
g26_nozzle = parser.value_float();
|
||||||
if (!WITHIN(g26_nozzle, 0.1, 1.0)) {
|
if (!WITHIN(g26_nozzle, 0.1, 1.0)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?Specified nozzle size not plausible.");
|
SERIAL_PROTOCOLLNPGM("?Specified nozzle size not plausible.");
|
||||||
|
@ -699,7 +699,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.seen('F')) {
|
if (parser.seenval('F')) {
|
||||||
g26_filament_diameter = parser.value_linear_units();
|
g26_filament_diameter = parser.value_linear_units();
|
||||||
if (!WITHIN(g26_filament_diameter, 1.0, 4.0)) {
|
if (!WITHIN(g26_filament_diameter, 1.0, 4.0)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible.");
|
SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible.");
|
||||||
|
@ -712,7 +712,7 @@
|
||||||
|
|
||||||
g26_extrusion_multiplier *= g26_filament_diameter * sq(g26_nozzle) / sq(0.3); // Scale up by nozzle size
|
g26_extrusion_multiplier *= g26_filament_diameter * sq(g26_nozzle) / sq(0.3); // Scale up by nozzle size
|
||||||
|
|
||||||
if (parser.seen('H')) {
|
if (parser.seenval('H')) {
|
||||||
g26_hotend_temp = parser.value_celsius();
|
g26_hotend_temp = parser.value_celsius();
|
||||||
if (!WITHIN(g26_hotend_temp, 165, 280)) {
|
if (!WITHIN(g26_hotend_temp, 165, 280)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
|
SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
|
||||||
|
|
|
@ -1277,7 +1277,7 @@ void get_available_commands() {
|
||||||
* Returns TRUE if the target is invalid
|
* Returns TRUE if the target is invalid
|
||||||
*/
|
*/
|
||||||
bool get_target_extruder_from_command(const uint16_t code) {
|
bool get_target_extruder_from_command(const uint16_t code) {
|
||||||
if (parser.seen('T')) {
|
if (parser.seenval('T')) {
|
||||||
const int8_t e = parser.value_byte();
|
const int8_t e = parser.value_byte();
|
||||||
if (e >= EXTRUDERS) {
|
if (e >= EXTRUDERS) {
|
||||||
SERIAL_ECHO_START();
|
SERIAL_ECHO_START();
|
||||||
|
@ -3135,7 +3135,7 @@ static void homeaxis(const AxisEnum axis) {
|
||||||
const char* mixing_codes = "ABCDHI";
|
const char* mixing_codes = "ABCDHI";
|
||||||
byte mix_bits = 0;
|
byte mix_bits = 0;
|
||||||
for (uint8_t i = 0; i < MIXING_STEPPERS; i++) {
|
for (uint8_t i = 0; i < MIXING_STEPPERS; i++) {
|
||||||
if (parser.seen(mixing_codes[i])) {
|
if (parser.seenval(mixing_codes[i])) {
|
||||||
SBI(mix_bits, i);
|
SBI(mix_bits, i);
|
||||||
float v = parser.value_float();
|
float v = parser.value_float();
|
||||||
NOLESS(v, 0.0);
|
NOLESS(v, 0.0);
|
||||||
|
@ -3304,7 +3304,7 @@ inline void gcode_G0_G1(
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float arc_offset[2] = { 0.0, 0.0 };
|
float arc_offset[2] = { 0.0, 0.0 };
|
||||||
if (parser.seen('R')) {
|
if (parser.seenval('R')) {
|
||||||
const float r = parser.value_linear_units(),
|
const float r = parser.value_linear_units(),
|
||||||
p1 = current_position[X_AXIS], q1 = current_position[Y_AXIS],
|
p1 = current_position[X_AXIS], q1 = current_position[Y_AXIS],
|
||||||
p2 = destination[X_AXIS], q2 = destination[Y_AXIS];
|
p2 = destination[X_AXIS], q2 = destination[Y_AXIS];
|
||||||
|
@ -3321,8 +3321,8 @@ inline void gcode_G0_G1(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (parser.seen('I')) arc_offset[0] = parser.value_linear_units();
|
if (parser.seenval('I')) arc_offset[0] = parser.value_linear_units();
|
||||||
if (parser.seen('J')) arc_offset[1] = parser.value_linear_units();
|
if (parser.seenval('J')) arc_offset[1] = parser.value_linear_units();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arc_offset[0] || arc_offset[1]) {
|
if (arc_offset[0] || arc_offset[1]) {
|
||||||
|
@ -3358,8 +3358,8 @@ inline void gcode_G0_G1(
|
||||||
inline void gcode_G4() {
|
inline void gcode_G4() {
|
||||||
millis_t dwell_ms = 0;
|
millis_t dwell_ms = 0;
|
||||||
|
|
||||||
if (parser.seen('P')) dwell_ms = parser.value_millis(); // milliseconds to wait
|
if (parser.seenval('P')) dwell_ms = parser.value_millis(); // milliseconds to wait
|
||||||
if (parser.seen('S')) dwell_ms = parser.value_millis_from_seconds(); // seconds to wait
|
if (parser.seenval('S')) dwell_ms = parser.value_millis_from_seconds(); // seconds to wait
|
||||||
|
|
||||||
stepper.synchronize();
|
stepper.synchronize();
|
||||||
refresh_cmd_timeout();
|
refresh_cmd_timeout();
|
||||||
|
@ -4111,7 +4111,7 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MeshSet:
|
case MeshSet:
|
||||||
if (parser.seen('X')) {
|
if (parser.seenval('X')) {
|
||||||
px = parser.value_int() - 1;
|
px = parser.value_int() - 1;
|
||||||
if (!WITHIN(px, 0, GRID_MAX_POINTS_X - 1)) {
|
if (!WITHIN(px, 0, GRID_MAX_POINTS_X - 1)) {
|
||||||
SERIAL_PROTOCOLLNPGM("X out of range (1-" STRINGIFY(GRID_MAX_POINTS_X) ").");
|
SERIAL_PROTOCOLLNPGM("X out of range (1-" STRINGIFY(GRID_MAX_POINTS_X) ").");
|
||||||
|
@ -4123,7 +4123,7 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.seen('Y')) {
|
if (parser.seenval('Y')) {
|
||||||
py = parser.value_int() - 1;
|
py = parser.value_int() - 1;
|
||||||
if (!WITHIN(py, 0, GRID_MAX_POINTS_Y - 1)) {
|
if (!WITHIN(py, 0, GRID_MAX_POINTS_Y - 1)) {
|
||||||
SERIAL_PROTOCOLLNPGM("Y out of range (1-" STRINGIFY(GRID_MAX_POINTS_Y) ").");
|
SERIAL_PROTOCOLLNPGM("Y out of range (1-" STRINGIFY(GRID_MAX_POINTS_Y) ").");
|
||||||
|
@ -4135,7 +4135,7 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.seen('Z')) {
|
if (parser.seenval('Z')) {
|
||||||
mbl.z_values[px][py] = parser.value_linear_units();
|
mbl.z_values[px][py] = parser.value_linear_units();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -4145,7 +4145,7 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MeshSetZOffset:
|
case MeshSetZOffset:
|
||||||
if (parser.seen('Z')) {
|
if (parser.seenval('Z')) {
|
||||||
mbl.z_offset = parser.value_linear_units();
|
mbl.z_offset = parser.value_linear_units();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -4371,17 +4371,17 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float z = parser.seen('Z') && parser.has_value() ? parser.value_float() : RAW_CURRENT_POSITION(Z);
|
const float z = parser.seenval('Z') ? parser.value_float() : RAW_CURRENT_POSITION(Z);
|
||||||
if (!WITHIN(z, -10, 10)) {
|
if (!WITHIN(z, -10, 10)) {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
SERIAL_ERRORLNPGM("Bad Z value");
|
SERIAL_ERRORLNPGM("Bad Z value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float x = parser.seen('X') && parser.has_value() ? parser.value_float() : NAN,
|
const float x = parser.seenval('X') ? parser.value_float() : NAN,
|
||||||
y = parser.seen('Y') && parser.has_value() ? parser.value_float() : NAN;
|
y = parser.seenval('Y') ? parser.value_float() : NAN;
|
||||||
int8_t i = parser.seen('I') && parser.has_value() ? parser.value_byte() : -1,
|
int8_t i = parser.seenval('I') ? parser.value_byte() : -1,
|
||||||
j = parser.seen('J') && parser.has_value() ? parser.value_byte() : -1;
|
j = parser.seenval('J') ? parser.value_byte() : -1;
|
||||||
|
|
||||||
if (!isnan(x) && !isnan(y)) {
|
if (!isnan(x) && !isnan(y)) {
|
||||||
// Get nearest i / j from x / y
|
// Get nearest i / j from x / y
|
||||||
|
@ -4413,7 +4413,7 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
verbose_level = parser.seen('V') && parser.has_value() ? parser.value_int() : 0;
|
verbose_level = parser.seenval('V') ? parser.value_int() : 0;
|
||||||
if (!WITHIN(verbose_level, 0, 4)) {
|
if (!WITHIN(verbose_level, 0, 4)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4).");
|
SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4).");
|
||||||
return;
|
return;
|
||||||
|
@ -4433,7 +4433,7 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
// These values may be saved with the completed mesh
|
// These values may be saved with the completed mesh
|
||||||
abl_grid_points_x = parser.seen('X') ? parser.value_int() : GRID_MAX_POINTS_X;
|
abl_grid_points_x = parser.seen('X') ? parser.value_int() : GRID_MAX_POINTS_X;
|
||||||
abl_grid_points_y = parser.seen('Y') ? parser.value_int() : GRID_MAX_POINTS_Y;
|
abl_grid_points_y = parser.seen('Y') ? parser.value_int() : GRID_MAX_POINTS_Y;
|
||||||
if (parser.seen('P')) abl_grid_points_x = abl_grid_points_y = parser.value_int();
|
if (parser.seenval('P')) abl_grid_points_x = abl_grid_points_y = parser.value_int();
|
||||||
|
|
||||||
if (abl_grid_points_x < 2 || abl_grid_points_y < 2) {
|
if (abl_grid_points_x < 2 || abl_grid_points_y < 2) {
|
||||||
SERIAL_PROTOCOLLNPGM("?Number of probe points is implausible (2 minimum).");
|
SERIAL_PROTOCOLLNPGM("?Number of probe points is implausible (2 minimum).");
|
||||||
|
@ -5595,7 +5595,7 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
// If any axis has enough movement, do the move
|
// If any axis has enough movement, do the move
|
||||||
LOOP_XYZ(i)
|
LOOP_XYZ(i)
|
||||||
if (FABS(destination[i] - current_position[i]) >= G38_MINIMUM_MOVE) {
|
if (FABS(destination[i] - current_position[i]) >= G38_MINIMUM_MOVE) {
|
||||||
if (!parser.seen('F')) feedrate_mm_s = homing_feedrate(i);
|
if (!parser.seenval('F')) feedrate_mm_s = homing_feedrate(i);
|
||||||
// If G38.2 fails throw an error
|
// If G38.2 fails throw an error
|
||||||
if (!G38_run_probe() && is_38_2) {
|
if (!G38_run_probe() && is_38_2) {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
|
@ -5616,10 +5616,10 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
*/
|
*/
|
||||||
inline void gcode_G42() {
|
inline void gcode_G42() {
|
||||||
if (IsRunning()) {
|
if (IsRunning()) {
|
||||||
const bool hasI = parser.seen('I');
|
const bool hasI = parser.seenval('I');
|
||||||
const int8_t ix = parser.has_value() ? parser.value_int() : 0;
|
const int8_t ix = hasI ? parser.value_int() : 0;
|
||||||
const bool hasJ = parser.seen('J');
|
const bool hasJ = parser.seenval('J');
|
||||||
const int8_t iy = parser.has_value() ? parser.value_int() : 0;
|
const int8_t iy = hasJ ? parser.value_int() : 0;
|
||||||
|
|
||||||
if ((hasI && !WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) || (hasJ && !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))) {
|
if ((hasI && !WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) || (hasJ && !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))) {
|
||||||
SERIAL_ECHOLNPGM(MSG_ERR_MESH_XY);
|
SERIAL_ECHOLNPGM(MSG_ERR_MESH_XY);
|
||||||
|
@ -5664,12 +5664,12 @@ void home_all_axes() { gcode_G28(true); }
|
||||||
*/
|
*/
|
||||||
inline void gcode_G92() {
|
inline void gcode_G92() {
|
||||||
bool didXYZ = false,
|
bool didXYZ = false,
|
||||||
didE = parser.seen('E');
|
didE = parser.seenval('E');
|
||||||
|
|
||||||
if (!didE) stepper.synchronize();
|
if (!didE) stepper.synchronize();
|
||||||
|
|
||||||
LOOP_XYZE(i) {
|
LOOP_XYZE(i) {
|
||||||
if (parser.seen(axis_codes[i])) {
|
if (parser.seenval(axis_codes[i])) {
|
||||||
#if IS_SCARA
|
#if IS_SCARA
|
||||||
current_position[i] = parser.value_axis_units((AxisEnum)i);
|
current_position[i] = parser.value_axis_units((AxisEnum)i);
|
||||||
if (i != E_AXIS) didXYZ = true;
|
if (i != E_AXIS) didXYZ = true;
|
||||||
|
@ -5715,11 +5715,11 @@ inline void gcode_G92() {
|
||||||
|
|
||||||
millis_t ms = 0;
|
millis_t ms = 0;
|
||||||
bool hasP = false, hasS = false;
|
bool hasP = false, hasS = false;
|
||||||
if (parser.seen('P')) {
|
if (parser.seenval('P')) {
|
||||||
ms = parser.value_millis(); // milliseconds to wait
|
ms = parser.value_millis(); // milliseconds to wait
|
||||||
hasP = ms > 0;
|
hasP = ms > 0;
|
||||||
}
|
}
|
||||||
if (parser.seen('S')) {
|
if (parser.seenval('S')) {
|
||||||
ms = parser.value_millis_from_seconds(); // seconds to wait
|
ms = parser.value_millis_from_seconds(); // seconds to wait
|
||||||
hasS = ms > 0;
|
hasS = ms > 0;
|
||||||
}
|
}
|
||||||
|
@ -6272,7 +6272,7 @@ inline void gcode_M17() {
|
||||||
* M26: Set SD Card file index
|
* M26: Set SD Card file index
|
||||||
*/
|
*/
|
||||||
inline void gcode_M26() {
|
inline void gcode_M26() {
|
||||||
if (card.cardOK && parser.seen('S'))
|
if (card.cardOK && parser.seenval('S'))
|
||||||
card.setIndex(parser.value_long());
|
card.setIndex(parser.value_long());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6334,7 +6334,7 @@ inline void gcode_M31() {
|
||||||
if (card.cardOK) {
|
if (card.cardOK) {
|
||||||
card.openFile(namestartpos, true, call_procedure);
|
card.openFile(namestartpos, true, call_procedure);
|
||||||
|
|
||||||
if (parser.seen('S'))
|
if (parser.seenval('S'))
|
||||||
card.setIndex(parser.value_long());
|
card.setIndex(parser.value_long());
|
||||||
|
|
||||||
card.startFileprint();
|
card.startFileprint();
|
||||||
|
@ -6370,8 +6370,8 @@ inline void gcode_M31() {
|
||||||
*/
|
*/
|
||||||
inline void gcode_M34() {
|
inline void gcode_M34() {
|
||||||
if (parser.seen('S')) card.setSortOn(parser.value_bool());
|
if (parser.seen('S')) card.setSortOn(parser.value_bool());
|
||||||
if (parser.seen('F')) {
|
if (parser.seenval('F')) {
|
||||||
int v = parser.value_long();
|
const int v = parser.value_long();
|
||||||
card.setSortFolders(v < 0 ? -1 : v > 0 ? 1 : 0);
|
card.setSortFolders(v < 0 ? -1 : v > 0 ? 1 : 0);
|
||||||
}
|
}
|
||||||
//if (parser.seen('R')) card.setSortReverse(parser.value_bool());
|
//if (parser.seen('R')) card.setSortReverse(parser.value_bool());
|
||||||
|
@ -6404,10 +6404,8 @@ static bool pin_is_protected(const int8_t pin) {
|
||||||
* S<byte> Pin status from 0 - 255
|
* S<byte> Pin status from 0 - 255
|
||||||
*/
|
*/
|
||||||
inline void gcode_M42() {
|
inline void gcode_M42() {
|
||||||
if (!parser.seen('S')) return;
|
if (!parser.seenval('S')) return;
|
||||||
|
const byte pin_status = parser.value_byte();
|
||||||
const int pin_status = parser.value_int();
|
|
||||||
if (!WITHIN(pin_status, 0, 255)) return;
|
|
||||||
|
|
||||||
int pin_number = parser.seen('P') ? parser.value_int() : LED_PIN;
|
int pin_number = parser.seen('P') ? parser.value_int() : LED_PIN;
|
||||||
if (pin_number < 0) return;
|
if (pin_number < 0) return;
|
||||||
|
@ -6666,8 +6664,8 @@ inline void gcode_M42() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the range of pins to test or watch
|
// Get the range of pins to test or watch
|
||||||
const uint8_t first_pin = parser.seen('P') ? parser.value_byte() : 0,
|
const uint8_t first_pin = parser.seenval('P') ? parser.value_byte() : 0,
|
||||||
last_pin = parser.seen('P') ? first_pin : NUM_DIGITAL_PINS - 1;
|
last_pin = parser.seenval('P') ? first_pin : NUM_DIGITAL_PINS - 1;
|
||||||
|
|
||||||
if (first_pin > last_pin) return;
|
if (first_pin > last_pin) return;
|
||||||
|
|
||||||
|
@ -7026,7 +7024,7 @@ inline void gcode_M104() {
|
||||||
if (target_extruder != active_extruder) return;
|
if (target_extruder != active_extruder) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (parser.seen('S')) {
|
if (parser.seenval('S')) {
|
||||||
const int16_t temp = parser.value_celsius();
|
const int16_t temp = parser.value_celsius();
|
||||||
thermalManager.setTargetHotend(temp, target_extruder);
|
thermalManager.setTargetHotend(temp, target_extruder);
|
||||||
|
|
||||||
|
@ -7153,7 +7151,7 @@ inline void gcode_M105() {
|
||||||
* M155: Set temperature auto-report interval. M155 S<seconds>
|
* M155: Set temperature auto-report interval. M155 S<seconds>
|
||||||
*/
|
*/
|
||||||
inline void gcode_M155() {
|
inline void gcode_M155() {
|
||||||
if (parser.seen('S')) {
|
if (parser.seenval('S')) {
|
||||||
auto_report_temp_interval = parser.value_byte();
|
auto_report_temp_interval = parser.value_byte();
|
||||||
NOMORE(auto_report_temp_interval, 60);
|
NOMORE(auto_report_temp_interval, 60);
|
||||||
next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
|
next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
|
||||||
|
@ -7240,8 +7238,8 @@ inline void gcode_M109() {
|
||||||
if (target_extruder != active_extruder) return;
|
if (target_extruder != active_extruder) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const bool no_wait_for_cooling = parser.seen('S');
|
const bool no_wait_for_cooling = parser.seenval('S');
|
||||||
if (no_wait_for_cooling || parser.seen('R')) {
|
if (no_wait_for_cooling || parser.seenval('R')) {
|
||||||
const int16_t temp = parser.value_celsius();
|
const int16_t temp = parser.value_celsius();
|
||||||
thermalManager.setTargetHotend(temp, target_extruder);
|
thermalManager.setTargetHotend(temp, target_extruder);
|
||||||
|
|
||||||
|
@ -7389,8 +7387,8 @@ inline void gcode_M109() {
|
||||||
if (DEBUGGING(DRYRUN)) return;
|
if (DEBUGGING(DRYRUN)) return;
|
||||||
|
|
||||||
LCD_MESSAGEPGM(MSG_BED_HEATING);
|
LCD_MESSAGEPGM(MSG_BED_HEATING);
|
||||||
const bool no_wait_for_cooling = parser.seen('S');
|
const bool no_wait_for_cooling = parser.seenval('S');
|
||||||
if (no_wait_for_cooling || parser.seen('R')) {
|
if (no_wait_for_cooling || parser.seenval('R')) {
|
||||||
thermalManager.setTargetBed(parser.value_celsius());
|
thermalManager.setTargetBed(parser.value_celsius());
|
||||||
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
|
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
|
||||||
if (parser.value_celsius() > BED_MINTEMP)
|
if (parser.value_celsius() > BED_MINTEMP)
|
||||||
|
@ -7497,7 +7495,7 @@ inline void gcode_M109() {
|
||||||
* M110: Set Current Line Number
|
* M110: Set Current Line Number
|
||||||
*/
|
*/
|
||||||
inline void gcode_M110() {
|
inline void gcode_M110() {
|
||||||
if (parser.seen('N')) gcode_LastN = parser.value_long();
|
if (parser.seenval('N')) gcode_LastN = parser.value_long();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7547,7 +7545,7 @@ inline void gcode_M111() {
|
||||||
* S<seconds> Optional. Set the keepalive interval.
|
* S<seconds> Optional. Set the keepalive interval.
|
||||||
*/
|
*/
|
||||||
inline void gcode_M113() {
|
inline void gcode_M113() {
|
||||||
if (parser.seen('S')) {
|
if (parser.seenval('S')) {
|
||||||
host_keepalive_interval = parser.value_byte();
|
host_keepalive_interval = parser.value_byte();
|
||||||
NOMORE(host_keepalive_interval, 60);
|
NOMORE(host_keepalive_interval, 60);
|
||||||
}
|
}
|
||||||
|
@ -7590,7 +7588,7 @@ inline void gcode_M111() {
|
||||||
*/
|
*/
|
||||||
inline void gcode_M140() {
|
inline void gcode_M140() {
|
||||||
if (DEBUGGING(DRYRUN)) return;
|
if (DEBUGGING(DRYRUN)) return;
|
||||||
if (parser.seen('S')) thermalManager.setTargetBed(parser.value_celsius());
|
if (parser.seenval('S')) thermalManager.setTargetBed(parser.value_celsius());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(ULTIPANEL)
|
#if ENABLED(ULTIPANEL)
|
||||||
|
@ -7611,16 +7609,16 @@ inline void gcode_M140() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int v;
|
int v;
|
||||||
if (parser.seen('H')) {
|
if (parser.seenval('H')) {
|
||||||
v = parser.value_int();
|
v = parser.value_int();
|
||||||
lcd_preheat_hotend_temp[material] = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
|
lcd_preheat_hotend_temp[material] = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
|
||||||
}
|
}
|
||||||
if (parser.seen('F')) {
|
if (parser.seenval('F')) {
|
||||||
v = parser.value_int();
|
v = parser.value_int();
|
||||||
lcd_preheat_fan_speed[material] = constrain(v, 0, 255);
|
lcd_preheat_fan_speed[material] = constrain(v, 0, 255);
|
||||||
}
|
}
|
||||||
#if TEMP_SENSOR_BED != 0
|
#if TEMP_SENSOR_BED != 0
|
||||||
if (parser.seen('B')) {
|
if (parser.seenval('B')) {
|
||||||
v = parser.value_int();
|
v = parser.value_int();
|
||||||
lcd_preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
|
lcd_preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
|
||||||
}
|
}
|
||||||
|
@ -7635,9 +7633,9 @@ inline void gcode_M140() {
|
||||||
* M149: Set temperature units
|
* M149: Set temperature units
|
||||||
*/
|
*/
|
||||||
inline void gcode_M149() {
|
inline void gcode_M149() {
|
||||||
if (parser.seen('C')) parser.set_input_temp_units(TEMPUNIT_C);
|
if (parser.seenval('C')) parser.set_input_temp_units(TEMPUNIT_C);
|
||||||
else if (parser.seen('K')) parser.set_input_temp_units(TEMPUNIT_K);
|
else if (parser.seenval('K')) parser.set_input_temp_units(TEMPUNIT_K);
|
||||||
else if (parser.seen('F')) parser.set_input_temp_units(TEMPUNIT_F);
|
else if (parser.seenval('F')) parser.set_input_temp_units(TEMPUNIT_F);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -7726,7 +7724,7 @@ inline void gcode_M83() { axis_relative_modes[E_AXIS] = true; }
|
||||||
* M18, M84: Disable stepper motors
|
* M18, M84: Disable stepper motors
|
||||||
*/
|
*/
|
||||||
inline void gcode_M18_M84() {
|
inline void gcode_M18_M84() {
|
||||||
if (parser.seen('S')) {
|
if (parser.seenval('S')) {
|
||||||
stepper_inactive_time = parser.value_millis_from_seconds();
|
stepper_inactive_time = parser.value_millis_from_seconds();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -8448,11 +8446,11 @@ inline void gcode_M211() {
|
||||||
inline void gcode_M218() {
|
inline void gcode_M218() {
|
||||||
if (get_target_extruder_from_command(218) || target_extruder == 0) return;
|
if (get_target_extruder_from_command(218) || target_extruder == 0) return;
|
||||||
|
|
||||||
if (parser.seen('X')) hotend_offset[X_AXIS][target_extruder] = parser.value_linear_units();
|
if (parser.seenval('X')) hotend_offset[X_AXIS][target_extruder] = parser.value_linear_units();
|
||||||
if (parser.seen('Y')) hotend_offset[Y_AXIS][target_extruder] = parser.value_linear_units();
|
if (parser.seenval('Y')) hotend_offset[Y_AXIS][target_extruder] = parser.value_linear_units();
|
||||||
|
|
||||||
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE)
|
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE)
|
||||||
if (parser.seen('Z')) hotend_offset[Z_AXIS][target_extruder] = parser.value_linear_units();
|
if (parser.seenval('Z')) hotend_offset[Z_AXIS][target_extruder] = parser.value_linear_units();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SERIAL_ECHO_START();
|
SERIAL_ECHO_START();
|
||||||
|
@ -8476,7 +8474,7 @@ inline void gcode_M211() {
|
||||||
* M220: Set speed percentage factor, aka "Feed Rate" (M220 S95)
|
* M220: Set speed percentage factor, aka "Feed Rate" (M220 S95)
|
||||||
*/
|
*/
|
||||||
inline void gcode_M220() {
|
inline void gcode_M220() {
|
||||||
if (parser.seen('S')) feedrate_percentage = parser.value_int();
|
if (parser.seenval('S')) feedrate_percentage = parser.value_int();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8484,7 +8482,7 @@ inline void gcode_M220() {
|
||||||
*/
|
*/
|
||||||
inline void gcode_M221() {
|
inline void gcode_M221() {
|
||||||
if (get_target_extruder_from_command(221)) return;
|
if (get_target_extruder_from_command(221)) return;
|
||||||
if (parser.seen('S'))
|
if (parser.seenval('S'))
|
||||||
flow_percentage[target_extruder] = parser.value_int();
|
flow_percentage[target_extruder] = parser.value_int();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9777,14 +9775,14 @@ inline void gcode_M907() {
|
||||||
* S# determines MS1 or MS2, X# sets the pin high/low.
|
* S# determines MS1 or MS2, X# sets the pin high/low.
|
||||||
*/
|
*/
|
||||||
inline void gcode_M351() {
|
inline void gcode_M351() {
|
||||||
if (parser.seen('S')) switch (parser.value_byte()) {
|
if (parser.seenval('S')) switch (parser.value_byte()) {
|
||||||
case 1:
|
case 1:
|
||||||
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) stepper.microstep_ms(i, parser.value_byte(), -1);
|
LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, parser.value_byte(), -1);
|
||||||
if (parser.seen('B')) stepper.microstep_ms(4, parser.value_byte(), -1);
|
if (parser.seenval('B')) stepper.microstep_ms(4, parser.value_byte(), -1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) stepper.microstep_ms(i, -1, parser.value_byte());
|
LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, parser.value_byte());
|
||||||
if (parser.seen('B')) stepper.microstep_ms(4, -1, parser.value_byte());
|
if (parser.seenval('B')) stepper.microstep_ms(4, -1, parser.value_byte());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stepper.microstep_readings();
|
stepper.microstep_readings();
|
||||||
|
@ -9827,8 +9825,8 @@ inline void gcode_M907() {
|
||||||
inline void gcode_M355() {
|
inline void gcode_M355() {
|
||||||
#if HAS_CASE_LIGHT
|
#if HAS_CASE_LIGHT
|
||||||
uint8_t args = 0;
|
uint8_t args = 0;
|
||||||
if (parser.seen('P')) ++args, case_light_brightness = parser.value_byte();
|
if (parser.seenval('P')) ++args, case_light_brightness = parser.value_byte();
|
||||||
if (parser.seen('S')) ++args, case_light_on = parser.value_bool();
|
if (parser.seenval('S')) ++args, case_light_on = parser.value_bool();
|
||||||
if (args) update_case_light();
|
if (args) update_case_light();
|
||||||
|
|
||||||
// always report case light status
|
// always report case light status
|
||||||
|
|
|
@ -132,7 +132,7 @@ public:
|
||||||
|
|
||||||
#define SEEN_TEST(L) TEST(codebits[(L - 'A') >> 3], (L - 'A') & 0x7)
|
#define SEEN_TEST(L) TEST(codebits[(L - 'A') >> 3], (L - 'A') & 0x7)
|
||||||
|
|
||||||
#else
|
#else // !FASTER_GCODE_PARSER
|
||||||
|
|
||||||
// Code is found in the string. If not found, value_ptr is unchanged.
|
// Code is found in the string. If not found, value_ptr is unchanged.
|
||||||
// This allows "if (seen('A')||seen('B'))" to use the last-found value.
|
// This allows "if (seen('A')||seen('B'))" to use the last-found value.
|
||||||
|
@ -147,7 +147,7 @@ public:
|
||||||
|
|
||||||
#define SEEN_TEST(L) !!strchr(command_args, L)
|
#define SEEN_TEST(L) !!strchr(command_args, L)
|
||||||
|
|
||||||
#endif // FASTER_GCODE_PARSER
|
#endif // !FASTER_GCODE_PARSER
|
||||||
|
|
||||||
// Populate all fields by parsing a single line of GCode
|
// Populate all fields by parsing a single line of GCode
|
||||||
// This uses 54 bytes of SRAM to speed up seen/value
|
// This uses 54 bytes of SRAM to speed up seen/value
|
||||||
|
@ -157,7 +157,7 @@ public:
|
||||||
FORCE_INLINE static bool has_value() { return value_ptr != NULL; }
|
FORCE_INLINE static bool has_value() { return value_ptr != NULL; }
|
||||||
|
|
||||||
// Seen and has value
|
// Seen and has value
|
||||||
FORCE_INLINE static bool seenval(const char c) { return seen(c) && has_value(); }
|
inline static bool seenval(const char c) { return seen(c) && has_value(); }
|
||||||
|
|
||||||
static volatile bool seen_axis() {
|
static volatile bool seen_axis() {
|
||||||
return SEEN_TEST('X') || SEEN_TEST('Y') || SEEN_TEST('Z') || SEEN_TEST('E');
|
return SEEN_TEST('X') || SEEN_TEST('Y') || SEEN_TEST('Z') || SEEN_TEST('E');
|
||||||
|
@ -184,20 +184,20 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code value as a long or ulong
|
// Code value as a long or ulong
|
||||||
inline static long value_long() { return value_ptr ? strtol(value_ptr, NULL, 10) : 0L; }
|
inline static int32_t value_long() { return value_ptr ? strtol(value_ptr, NULL, 10) : 0L; }
|
||||||
inline unsigned static long value_ulong() { return value_ptr ? strtoul(value_ptr, NULL, 10) : 0UL; }
|
inline static uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, NULL, 10) : 0UL; }
|
||||||
|
|
||||||
// Code value for use as time
|
// Code value for use as time
|
||||||
FORCE_INLINE static millis_t value_millis() { return value_ulong(); }
|
FORCE_INLINE static millis_t value_millis() { return value_ulong(); }
|
||||||
FORCE_INLINE static millis_t value_millis_from_seconds() { return value_float() * 1000UL; }
|
FORCE_INLINE static millis_t value_millis_from_seconds() { return value_float() * 1000UL; }
|
||||||
|
|
||||||
// Reduce to fewer bits
|
// Reduce to fewer bits
|
||||||
FORCE_INLINE static int value_int() { return (int)value_long(); }
|
FORCE_INLINE static int16_t value_int() { return (int16_t)value_long(); }
|
||||||
FORCE_INLINE uint16_t value_ushort() { return (uint16_t)value_long(); }
|
FORCE_INLINE static uint16_t value_ushort() { return (uint16_t)value_long(); }
|
||||||
inline static uint8_t value_byte() { return (uint8_t)(constrain(value_long(), 0, 255)); }
|
inline static uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
|
||||||
|
|
||||||
// Bool is true with no value or non-zero
|
// Bool is true with no value or non-zero
|
||||||
inline static bool value_bool() { return !has_value() || value_byte(); }
|
inline static bool value_bool() { return !has_value() || value_byte(); }
|
||||||
|
|
||||||
// Units modes: Inches, Fahrenheit, Kelvin
|
// Units modes: Inches, Fahrenheit, Kelvin
|
||||||
|
|
||||||
|
@ -282,12 +282,12 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else // !TEMPERATURE_UNITS_SUPPORT
|
||||||
|
|
||||||
FORCE_INLINE static float value_celsius() { return value_float(); }
|
FORCE_INLINE static float value_celsius() { return value_float(); }
|
||||||
FORCE_INLINE static float value_celsius_diff() { return value_float(); }
|
FORCE_INLINE static float value_celsius_diff() { return value_float(); }
|
||||||
|
|
||||||
#endif
|
#endif // !TEMPERATURE_UNITS_SUPPORT
|
||||||
|
|
||||||
FORCE_INLINE static float value_feedrate() { return value_linear_units(); }
|
FORCE_INLINE static float value_feedrate() { return value_linear_units(); }
|
||||||
|
|
||||||
|
|
|
@ -314,7 +314,7 @@
|
||||||
|
|
||||||
// Check for commands that require the printer to be homed
|
// Check for commands that require the printer to be homed
|
||||||
if (axis_unhomed_error()) {
|
if (axis_unhomed_error()) {
|
||||||
const int8_t p_val = parser.seen('P') && parser.has_value() ? parser.value_int() : -1;
|
const int8_t p_val = parser.seenval('P') ? parser.value_int() : -1;
|
||||||
if (p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J'))
|
if (p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J'))
|
||||||
home_all_axes();
|
home_all_axes();
|
||||||
}
|
}
|
||||||
|
@ -492,7 +492,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float height = parser.seen('H') && parser.has_value() ? parser.value_float() : Z_CLEARANCE_BETWEEN_PROBES;
|
const float height = parser.seenval('H') ? parser.value_float() : Z_CLEARANCE_BETWEEN_PROBES;
|
||||||
manually_probe_remaining_mesh(g29_x_pos, g29_y_pos, height, g29_card_thickness, parser.seen('T'));
|
manually_probe_remaining_mesh(g29_x_pos, g29_y_pos, height, g29_card_thickness, parser.seen('T'));
|
||||||
|
|
||||||
SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
|
SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
|
||||||
|
@ -1094,9 +1094,9 @@
|
||||||
g29_constant = 0.0;
|
g29_constant = 0.0;
|
||||||
g29_repetition_cnt = 0;
|
g29_repetition_cnt = 0;
|
||||||
|
|
||||||
g29_x_flag = parser.seen('X') && parser.has_value();
|
g29_x_flag = parser.seenval('X');
|
||||||
g29_x_pos = g29_x_flag ? parser.value_float() : current_position[X_AXIS];
|
g29_x_pos = g29_x_flag ? parser.value_float() : current_position[X_AXIS];
|
||||||
g29_y_flag = parser.seen('Y') && parser.has_value();
|
g29_y_flag = parser.seenval('Y');
|
||||||
g29_y_pos = g29_y_flag ? parser.value_float() : current_position[Y_AXIS];
|
g29_y_pos = g29_y_flag ? parser.value_float() : current_position[Y_AXIS];
|
||||||
|
|
||||||
if (parser.seen('R')) {
|
if (parser.seen('R')) {
|
||||||
|
@ -1170,7 +1170,7 @@
|
||||||
g29_constant = parser.value_float();
|
g29_constant = parser.value_float();
|
||||||
|
|
||||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||||
if (parser.seen('F') && parser.has_value()) {
|
if (parser.seenval('F')) {
|
||||||
const float fh = parser.value_float();
|
const float fh = parser.value_float();
|
||||||
if (!WITHIN(fh, 0.0, 100.0)) {
|
if (!WITHIN(fh, 0.0, 100.0)) {
|
||||||
SERIAL_PROTOCOLLNPGM("?(F)ade height for Bed Level Correction not plausible.\n");
|
SERIAL_PROTOCOLLNPGM("?(F)ade height for Bed Level Correction not plausible.\n");
|
||||||
|
@ -1180,7 +1180,7 @@
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g29_map_type = parser.seen('T') && parser.has_value() ? parser.value_int() : 0;
|
g29_map_type = parser.seenval('T') ? parser.value_int() : 0;
|
||||||
if (!WITHIN(g29_map_type, 0, 2)) {
|
if (!WITHIN(g29_map_type, 0, 2)) {
|
||||||
SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
|
SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
|
||||||
return UBL_ERR;
|
return UBL_ERR;
|
||||||
|
|
Reference in a new issue