Merge upstream changes from Marlin 2.1.1

This commit is contained in:
Stefan Kalscheuer
2022-09-03 09:23:32 +02:00
parent 626283aadb
commit 986e416c7f
1610 changed files with 73839 additions and 40857 deletions

View File

@@ -40,7 +40,7 @@ void GcodeSuite::M108() {
* M112: Full Shutdown
*/
void GcodeSuite::M112() {
kill(M112_KILL_STR, nullptr, true);
kill(FPSTR(M112_KILL_STR), nullptr, true);
}
/**

View File

@@ -26,7 +26,7 @@
* M111: Set the debug level
*/
void GcodeSuite::M111() {
if (parser.seen('S')) marlin_debug_flags = parser.byteval('S');
if (parser.seenval('S')) marlin_debug_flags = parser.value_byte();
static PGMSTR(str_debug_1, STR_DEBUG_ECHO);
static PGMSTR(str_debug_2, STR_DEBUG_INFO);
@@ -34,12 +34,12 @@ void GcodeSuite::M111() {
static PGMSTR(str_debug_8, STR_DEBUG_DRYRUN);
static PGMSTR(str_debug_16, STR_DEBUG_COMMUNICATION);
#if ENABLED(DEBUG_LEVELING_FEATURE)
static PGMSTR(str_debug_lvl, STR_DEBUG_LEVELING);
static PGMSTR(str_debug_detail, STR_DEBUG_DETAIL);
#endif
static PGM_P const debug_strings[] PROGMEM = {
str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16,
TERN_(DEBUG_LEVELING_FEATURE, str_debug_lvl)
TERN_(DEBUG_LEVELING_FEATURE, str_debug_detail)
};
SERIAL_ECHO_START();
@@ -49,7 +49,7 @@ void GcodeSuite::M111() {
LOOP_L_N(i, COUNT(debug_strings)) {
if (TEST(marlin_debug_flags, i)) {
if (comma++) SERIAL_CHAR(',');
SERIAL_ECHOPGM_P((char*)pgm_read_ptr(&debug_strings[i]));
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&debug_strings[i]));
}
}
}

View File

@@ -23,6 +23,8 @@
#include "../gcode.h"
#include "../../MarlinCore.h" // for stepper_inactive_time, disable_e_steppers
#include "../../lcd/marlinui.h"
#include "../../module/motion.h" // for e_axis_mask
#include "../../module/planner.h"
#include "../../module/stepper.h"
#if ENABLED(AUTO_BED_LEVELING_UBL)
@@ -33,8 +35,8 @@
#include "../../core/debug_out.h"
#include "../../libs/hex_print.h"
inline axis_flags_t selected_axis_bits() {
axis_flags_t selected{0};
inline stepper_flags_t selected_axis_bits() {
stepper_flags_t selected{0};
#if HAS_EXTRUDERS
if (parser.seen('E')) {
if (E_TERN0(parser.has_value())) {
@@ -43,22 +45,25 @@ inline axis_flags_t selected_axis_bits() {
selected.bits = _BV(INDEX_OF_AXIS(E_AXIS, e));
}
else
selected.bits = selected.e_bits();
selected.bits = e_axis_mask;
}
#endif
selected.bits |= LINEAR_AXIS_GANG(
selected.bits |= NUM_AXIS_GANG(
(parser.seen_test('X') << X_AXIS),
| (parser.seen_test('Y') << Y_AXIS),
| (parser.seen_test('Z') << Z_AXIS),
| (parser.seen_test(AXIS4_NAME) << I_AXIS),
| (parser.seen_test(AXIS5_NAME) << J_AXIS),
| (parser.seen_test(AXIS6_NAME) << K_AXIS)
| (parser.seen_test(AXIS6_NAME) << K_AXIS),
| (parser.seen_test(AXIS7_NAME) << U_AXIS),
| (parser.seen_test(AXIS8_NAME) << V_AXIS),
| (parser.seen_test(AXIS9_NAME) << W_AXIS)
);
return selected;
}
// Enable specified axes and warn about other affected axes
void do_enable(const axis_flags_t to_enable) {
void do_enable(const stepper_flags_t to_enable) {
const ena_mask_t was_enabled = stepper.axis_enabled.bits,
shall_enable = to_enable.bits & ~was_enabled;
@@ -69,15 +74,15 @@ void do_enable(const axis_flags_t to_enable) {
ena_mask_t also_enabled = 0; // Track steppers enabled due to overlap
// Enable all flagged axes
LOOP_LINEAR_AXES(a) {
LOOP_NUM_AXES(a) {
if (TEST(shall_enable, a)) {
stepper.enable_axis(AxisEnum(a)); // Mark and enable the requested axis
DEBUG_ECHOLNPGM("Enabled ", axis_codes[a], " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... Enabled: ", hex_word(stepper.axis_enabled.bits));
DEBUG_ECHOLNPGM("Enabled ", AXIS_CHAR(a), " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... Enabled: ", hex_word(stepper.axis_enabled.bits));
also_enabled |= enable_overlap[a];
}
}
#if HAS_EXTRUDERS
LOOP_L_N(e, EXTRUDERS) {
EXTRUDER_LOOP() {
const uint8_t a = INDEX_OF_AXIS(E_AXIS, e);
if (TEST(shall_enable, a)) {
stepper.ENABLE_EXTRUDER(e);
@@ -89,7 +94,7 @@ void do_enable(const axis_flags_t to_enable) {
if ((also_enabled &= ~(shall_enable | was_enabled))) {
SERIAL_CHAR('(');
LOOP_LINEAR_AXES(a) if (TEST(also_enabled, a)) SERIAL_CHAR(axis_codes[a], ' ');
LOOP_NUM_AXES(a) if (TEST(also_enabled, a)) SERIAL_CHAR(AXIS_CHAR(a), ' ');
#if HAS_EXTRUDERS
#define _EN_ALSO(N) if (TEST(also_enabled, INDEX_OF_AXIS(E_AXIS, N))) SERIAL_CHAR('E', '0' + N, ' ');
REPEAT(EXTRUDERS, _EN_ALSO)
@@ -125,23 +130,17 @@ void GcodeSuite::M17() {
stepper.enable_e_steppers();
}
#endif
LINEAR_AXIS_CODE(
if (parser.seen_test('X')) stepper.enable_axis(X_AXIS),
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)
);
LOOP_NUM_AXES(a)
if (parser.seen_test(AXIS_CHAR(a))) stepper.enable_axis((AxisEnum)a);
}
}
else {
LCD_MESSAGEPGM(MSG_NO_MOVE);
LCD_MESSAGE(MSG_NO_MOVE);
stepper.enable_all_steppers();
}
}
void try_to_disable(const axis_flags_t to_disable) {
void try_to_disable(const stepper_flags_t to_disable) {
ena_mask_t still_enabled = to_disable.bits & stepper.axis_enabled.bits;
DEBUG_ECHOLNPGM("Enabled: ", hex_word(stepper.axis_enabled.bits), " To Disable: ", hex_word(to_disable.bits), " | ", hex_word(still_enabled));
@@ -149,9 +148,9 @@ void try_to_disable(const axis_flags_t to_disable) {
if (!still_enabled) return;
// Attempt to disable all flagged axes
LOOP_LINEAR_AXES(a)
LOOP_NUM_AXES(a)
if (TEST(to_disable.bits, a)) {
DEBUG_ECHOPGM("Try to disable ", axis_codes[a], " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... ");
DEBUG_ECHOPGM("Try to disable ", AXIS_CHAR(a), " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... ");
if (stepper.disable_axis(AxisEnum(a))) { // Mark the requested axis and request to disable
DEBUG_ECHOPGM("OK");
still_enabled &= ~(_BV(a) | enable_overlap[a]); // If actually disabled, clear one or more tracked bits
@@ -161,7 +160,7 @@ void try_to_disable(const axis_flags_t to_disable) {
DEBUG_ECHOLNPGM(" ... still_enabled=", hex_word(still_enabled));
}
#if HAS_EXTRUDERS
LOOP_L_N(e, EXTRUDERS) {
EXTRUDER_LOOP() {
const uint8_t a = INDEX_OF_AXIS(E_AXIS, e);
if (TEST(to_disable.bits, a)) {
DEBUG_ECHOPGM("Try to disable E", AS_DIGIT(e), " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... ");
@@ -178,7 +177,7 @@ void try_to_disable(const axis_flags_t to_disable) {
auto overlap_warning = [](const ena_mask_t axis_bits) {
SERIAL_ECHOPGM(" not disabled. Shared with");
LOOP_LINEAR_AXES(a) if (TEST(axis_bits, a)) SERIAL_CHAR(' ', axis_codes[a]);
LOOP_NUM_AXES(a) if (TEST(axis_bits, a)) SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_STR[a]));
#if HAS_EXTRUDERS
#define _EN_STILLON(N) if (TEST(axis_bits, INDEX_OF_AXIS(E_AXIS, N))) SERIAL_CHAR(' ', 'E', '0' + N);
REPEAT(EXTRUDERS, _EN_STILLON)
@@ -187,14 +186,14 @@ void try_to_disable(const axis_flags_t to_disable) {
};
// If any of the requested axes are still enabled, give a warning
LOOP_LINEAR_AXES(a) {
LOOP_NUM_AXES(a) {
if (TEST(still_enabled, a)) {
SERIAL_CHAR(axis_codes[a]);
SERIAL_CHAR(AXIS_CHAR(a));
overlap_warning(stepper.axis_enabled.bits & enable_overlap[a]);
}
}
#if HAS_EXTRUDERS
LOOP_L_N(e, EXTRUDERS) {
EXTRUDER_LOOP() {
const uint8_t a = INDEX_OF_AXIS(E_AXIS, e);
if (TEST(still_enabled, a)) {
SERIAL_CHAR('E', '0' + e);
@@ -213,7 +212,16 @@ void try_to_disable(const axis_flags_t to_disable) {
void GcodeSuite::M18_M84() {
if (parser.seenval('S')) {
reset_stepper_timeout();
stepper_inactive_time = parser.value_millis_from_seconds();
#if HAS_DISABLE_INACTIVE_AXIS
const millis_t ms = parser.value_millis_from_seconds();
#if LASER_SAFETY_TIMEOUT_MS > 0
if (ms && ms <= LASER_SAFETY_TIMEOUT_MS) {
SERIAL_ECHO_MSG("M18 timeout must be > ", MS_TO_SEC(LASER_SAFETY_TIMEOUT_MS + 999), " s for laser safety.");
return;
}
#endif
stepper_inactive_time = ms;
#endif
}
else {
if (parser.seen_axis()) {
@@ -229,19 +237,13 @@ void GcodeSuite::M18_M84() {
stepper.disable_e_steppers();
}
#endif
LINEAR_AXIS_CODE(
if (parser.seen_test('X')) stepper.disable_axis(X_AXIS),
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)
);
LOOP_NUM_AXES(a)
if (parser.seen_test(AXIS_CHAR(a))) stepper.disable_axis((AxisEnum)a);
}
}
else
planner.finish_and_disable();
TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled());
TERN_(AUTO_BED_LEVELING_UBL, bedlevel.steppers_were_disabled());
}
}

View File

@@ -40,15 +40,15 @@ void GcodeSuite::M211() {
}
void GcodeSuite::M211_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, PSTR(STR_SOFT_ENDSTOPS));
report_heading_etc(forReplay, F(STR_SOFT_ENDSTOPS));
SERIAL_ECHOPGM(" M211 S", AS_DIGIT(soft_endstop._enabled), " ; ");
serialprintln_onoff(soft_endstop._enabled);
report_echo_start(forReplay);
const xyz_pos_t l_soft_min = soft_endstop.min.asLogical(),
l_soft_max = soft_endstop.max.asLogical();
print_pos(l_soft_min, PSTR(STR_SOFT_MIN), PSTR(" "));
print_pos(l_soft_max, PSTR(STR_SOFT_MAX));
print_pos(l_soft_min, F(STR_SOFT_MIN), F(" "));
print_pos(l_soft_max, F(STR_SOFT_MAX));
}
#endif // HAS_SOFTWARE_ENDSTOPS

View File

@@ -26,7 +26,7 @@
#include "../gcode.h"
#include "../../MarlinCore.h" // for pin_is_protected and idle()
#include "../../module/stepper.h"
#include "../../module/planner.h"
void protected_pin_err();

View File

@@ -48,7 +48,7 @@ void GcodeSuite::M280() {
const int anew = parser.value_int();
if (anew >= 0) {
#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 int aold = servo[servo_index].read();
millis_t now = millis();
@@ -56,14 +56,14 @@ void GcodeSuite::M280() {
while (PENDING(now, end)) {
safe_delay(50);
now = _MIN(millis(), end);
MOVE_SERVO(servo_index, LROUND(aold + (anew - aold) * (float(now - start) / t)));
servo[servo_index].move(LROUND(aold + (anew - aold) * (float(now - start) / t)));
}
}
#endif // POLARGRAPH
MOVE_SERVO(servo_index, anew);
servo[servo_index].move(anew);
}
else
DETACH_SERVO(servo_index);
servo[servo_index].detach();
}
else
SERIAL_ECHO_MSG(" Servo ", servo_index, ": ", servo[servo_index].read());

View File

@@ -36,7 +36,7 @@ void GcodeSuite::M282() {
const int servo_index = parser.value_int();
if (WITHIN(servo_index, 0, NUM_SERVOS - 1))
DETACH_SERVO(servo_index);
servo[servo_index].detach();
else
SERIAL_ECHO_MSG("Servo ", servo_index, " out of range");

View File

@@ -26,24 +26,34 @@
#include "../gcode.h"
#include "../../feature/spindle_laser.h"
#include "../../module/stepper.h"
#include "../../module/planner.h"
/**
* Laser:
* M3 - Laser ON/Power (Ramped power)
* M4 - Laser ON/Power (Continuous power)
* M4 - Laser ON/Power (Ramped power)
* M5 - Set power output to 0 (leaving inline mode unchanged).
*
* M3I - Enable continuous inline power to be processed by the planner, with power
* calculated and set in the planner blocks, processed inline during stepping.
* Within inline mode M3 S-Values will set the power for the next moves e.g. G1 X10 Y10 powers on with the last S-Value.
* M3I must be set before using planner-synced M3 inline S-Values (LASER_POWER_SYNC).
*
* M4I - Set dynamic mode which calculates laser power OCR based on the current feedrate.
*
* M5I - Clear inline mode and set power to 0.
*
* Spindle:
* M3 - Spindle ON (Clockwise)
* M4 - Spindle ON (Counter-clockwise)
* M5 - Spindle OFF
*
* Parameters:
* S<power> - Set power. S0 will turn the spindle/laser off, except in relative mode.
* O<ocr> - Set power and OCR (oscillator count register)
* S<power> - Set power. S0 will turn the spindle/laser off.
*
* If no PWM pin is defined then M3/M4 just turns it on.
* If no PWM pin is defined then M3/M4 just turns it on or off.
*
* At least 12.8KHz (50Hz * 256) is needed for Spindle PWM.
* At least 12.8kHz (50Hz * 256) is needed for Spindle PWM.
* Hardware PWM is required on AVR. ISRs are too slow.
*
* NOTE: WGM for timers 3, 4, and 5 must be either Mode 1 or Mode 5.
@@ -66,75 +76,81 @@
* PWM duty cycle goes from 0 (off) to 255 (always on).
*/
void GcodeSuite::M3_M4(const bool is_M4) {
auto get_s_power = [] {
if (parser.seenval('S')) {
const float spwr = parser.value_float();
#if ENABLED(SPINDLE_SERVO)
cutter.unitPower = spwr;
#else
cutter.unitPower = TERN(SPINDLE_LASER_USE_PWM,
cutter.power_to_range(cutter_power_t(round(spwr))),
spwr > 0 ? 255 : 0);
#endif
#if LASER_SAFETY_TIMEOUT_MS > 0
reset_stepper_timeout(); // Reset timeout to allow subsequent G-code to power the laser (imm.)
#endif
if (cutter.cutter_mode == CUTTER_MODE_STANDARD)
planner.synchronize(); // Wait for previous movement commands (G0/G1/G2/G3) to complete before changing power
#if ENABLED(LASER_FEATURE)
if (parser.seen_test('I')) {
cutter.cutter_mode = is_M4 ? CUTTER_MODE_DYNAMIC : CUTTER_MODE_CONTINUOUS;
cutter.inline_power(0);
cutter.set_enabled(true);
}
else
cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP);
return cutter.unitPower;
#endif
auto get_s_power = [] {
float u;
if (parser.seenval('S')) {
const float v = parser.value_float();
u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v));
}
else if (cutter.cutter_mode == CUTTER_MODE_STANDARD)
u = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP);
cutter.menuPower = cutter.unitPower = u;
// PWM not implied, power converted to OCR from unit definition and on/off if not PWM.
cutter.power = TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0);
return u;
};
#if ENABLED(LASER_POWER_INLINE)
if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) {
// Laser power in inline mode
cutter.inline_direction(is_M4); // Should always be unused
#if ENABLED(SPINDLE_LASER_USE_PWM)
if (parser.seen('O')) {
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)
}
else
cutter.inline_power(cutter.upower_to_ocr(get_s_power()));
if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { // Laser power in inline mode
#if ENABLED(LASER_FEATURE)
planner.laser_inline.status.isPowered = true; // M3 or M4 is powered either way
get_s_power(); // Update cutter.power if seen
#if ENABLED(LASER_POWER_SYNC)
// With power sync we only set power so it does not effect queued inline power sets
planner.buffer_sync_block(BLOCK_BIT_LASER_PWR); // Send the flag, queueing inline power
#else
cutter.set_inline_enabled(true);
planner.synchronize();
cutter.inline_power(cutter.power);
#endif
return;
}
// Non-inline, standard case
cutter.inline_disable(); // Prevent future blocks re-setting the power
#endif
planner.synchronize(); // Wait for previous movement commands (G0/G0/G2/G3) to complete before changing power
cutter.set_reverse(is_M4);
#if ENABLED(SPINDLE_LASER_USE_PWM)
if (parser.seenval('O')) {
cutter.unitPower = cutter.power_to_range(parser.value_byte(), 0);
cutter.ocr_set_power(cutter.unitPower); // The OCR is a value from 0 to 255 (uint8_t)
}
else
cutter.set_power(cutter.upower_to_ocr(get_s_power()));
#elif ENABLED(SPINDLE_SERVO)
cutter.set_power(get_s_power());
#else
#endif
}
else {
cutter.set_enabled(true);
#endif
cutter.menuPower = cutter.unitPower;
get_s_power();
cutter.apply_power(
#if ENABLED(SPINDLE_SERVO)
cutter.unitPower
#elif ENABLED(SPINDLE_LASER_USE_PWM)
cutter.upower_to_ocr(cutter.unitPower)
#else
cutter.unitPower > 0 ? 255 : 0
#endif
);
TERN_(SPINDLE_CHANGE_DIR, cutter.set_reverse(is_M4));
}
}
/**
* M5 - Cutter OFF (when moves are complete)
*/
void GcodeSuite::M5() {
#if ENABLED(LASER_POWER_INLINE)
if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) {
cutter.set_inline_enabled(false); // Laser power in inline mode
return;
}
// Non-inline, standard case
cutter.inline_disable(); // Prevent future blocks re-setting the power
#endif
planner.synchronize();
cutter.set_enabled(false);
cutter.menuPower = cutter.unitPower;
cutter.power = 0;
cutter.apply_power(0); // M5 just kills power, leaving inline mode unchanged
if (cutter.cutter_mode != CUTTER_MODE_STANDARD) {
if (parser.seen_test('I')) {
TERN_(LASER_FEATURE, cutter.inline_power(cutter.power));
cutter.set_enabled(false); // Needs to happen while we are in inline mode to clear inline power.
cutter.cutter_mode = CUTTER_MODE_STANDARD; // Switch from inline to standard mode.
}
}
cutter.set_enabled(false); // Disable enable output setting
}
#endif // HAS_CUTTER

View File

@@ -27,35 +27,45 @@
#include "../gcode.h"
#include "../../module/stepper.h"
#if NUM_AXES == XYZ && EXTRUDERS >= 1
#define HAS_M350_B_PARAM 1 // "5th axis" (after E0) for an original XYZEB setup.
#if AXIS_COLLISION('B')
#error "M350 parameter 'B' collision with axis name."
#endif
#endif
/**
* M350: Set axis microstepping modes. S sets mode for all drivers.
*
* Warning: Steps-per-unit remains unchanged.
*/
void GcodeSuite::M350() {
if (parser.seen('S')) LOOP_LE_N(i, 4) stepper.microstep_mode(i, parser.value_byte());
LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) stepper.microstep_mode(i, parser.value_byte());
if (parser.seen('B')) stepper.microstep_mode(4, parser.value_byte());
if (parser.seen('S')) LOOP_DISTINCT_AXES(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());
TERN_(HAS_M350_B_PARAM, if (parser.seenval('B')) stepper.microstep_mode(E_AXIS + 1, parser.value_byte()));
stepper.microstep_readings();
}
/**
* M351: Toggle MS1 MS2 pins directly with axis codes X Y Z E B
* M351: Toggle MS1 MS2 pins directly with axis codes X Y Z . . . E [B]
* S# determines MS1, MS2 or MS3, X# sets the pin high/low.
*
* Parameter 'B' sets "5th axis" (after E0) only for an original XYZEB setup.
*/
void GcodeSuite::M351() {
const int8_t bval = TERN(HAS_M350_B_PARAM, parser.byteval('B', -1), -1); UNUSED(bval);
if (parser.seenval('S')) switch (parser.value_byte()) {
case 1:
LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, parser.value_byte(), -1, -1);
if (parser.seenval('B')) stepper.microstep_ms(4, parser.value_byte(), -1, -1);
LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, parser.value_byte(), -1, -1);
TERN_(HAS_M350_B_PARAM, if (bval >= 0) stepper.microstep_ms(E_AXIS + 1, bval != 0, -1, -1));
break;
case 2:
LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, parser.value_byte(), -1);
if (parser.seenval('B')) stepper.microstep_ms(4, -1, parser.value_byte(), -1);
LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, -1, parser.value_byte(), -1);
TERN_(HAS_M350_B_PARAM, if (bval >= 0) stepper.microstep_ms(E_AXIS + 1, -1, bval != 0, -1));
break;
case 3:
LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, -1, parser.value_byte());
if (parser.seenval('B')) stepper.microstep_ms(4, -1, -1, parser.value_byte());
LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, -1, -1, parser.value_byte());
TERN_(HAS_M350_B_PARAM, if (bval >= 0) stepper.microstep_ms(E_AXIS + 1, -1, -1, bval != 0));
break;
}
stepper.microstep_readings();

View File

@@ -37,7 +37,7 @@ void GcodeSuite::M380() {
#if ENABLED(MANUAL_SOLENOID_CONTROL)
enable_solenoid(parser.intval('S', active_extruder));
#else
enable_solenoid_on_active_extruder();
enable_solenoid(active_extruder);
#endif
}

View File

@@ -21,7 +21,7 @@
*/
#include "../gcode.h"
#include "../../module/stepper.h"
#include "../../module/planner.h"
/**
* M400: Finish all moves

View File

@@ -52,7 +52,7 @@ void protected_pin_err() {
* S<byte> Pin status from 0 - 255
* I Flag to ignore Marlin's pin protection
*
* M<mode> Pin mode: 0=INPUT 1=OUTPUT 2=INPUT_PULLUP 3=INPUT_PULLDOWN
* T<mode> Pin mode: 0=INPUT 1=OUTPUT 2=INPUT_PULLUP 3=INPUT_PULLDOWN
*/
void GcodeSuite::M42() {
const int pin_index = PARSED_PIN_INDEX('P', GET_PIN_MAP_INDEX(LED_PIN));
@@ -63,7 +63,7 @@ void GcodeSuite::M42() {
if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err();
bool avoidWrite = false;
if (parser.seenval('M')) {
if (parser.seenval('T')) {
switch (parser.value_byte()) {
case 0: pinMode(pin, INPUT); avoidWrite = true; break;
case 1: pinMode(pin, OUTPUT); break;
@@ -126,10 +126,10 @@ void GcodeSuite::M42() {
extDigitalWrite(pin, pin_status);
#ifdef ARDUINO_ARCH_STM32
// A simple I/O will be set to 0 by analogWrite()
// A simple I/O will be set to 0 by hal.set_pwm_duty()
if (pin_status <= 1 && !PWM_PIN(pin)) return;
#endif
analogWrite(pin, pin_status);
hal.set_pwm_duty(pin, pin_status);
}
#endif // DIRECT_PIN_CONTROL

View File

@@ -28,7 +28,6 @@
#include "../gcode.h"
#include "../../module/motion.h"
#include "../../module/stepper.h"
#include "../../module/tool_change.h"
#include "../../module/planner.h"
@@ -64,7 +63,7 @@
void GcodeSuite::M605() {
planner.synchronize();
if (parser.seen('S')) {
if (parser.seenval('S')) {
const DualXMode previous_mode = dual_x_carriage_mode;
dual_x_carriage_mode = (DualXMode)parser.value_byte();
@@ -78,8 +77,8 @@
case DXC_DUPLICATION_MODE:
// 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.seen('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff();
if (parser.seenval('X')) duplicate_extruder_x_offset = _MAX(parser.value_linear_units(), (X2_MIN_POS) - (X1_MIN_POS));
if (parser.seenval('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff();
// Always switch back to tool 0
if (active_extruder != 0) tool_change(0);
break;
@@ -110,7 +109,7 @@
set_duplication_enabled(false);
#ifdef EVENT_GCODE_IDEX_AFTER_MODECHANGE
gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_IDEX_AFTER_MODECHANGE));
process_subcommands_now(F(EVENT_GCODE_IDEX_AFTER_MODECHANGE));
#endif
}
else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default
@@ -146,7 +145,7 @@
HOTEND_LOOP() {
DEBUG_ECHOPGM_P(SP_T_STR, e);
LOOP_LINEAR_AXES(a) DEBUG_ECHOPGM(" hotend_offset[", e, "].", AS_CHAR(AXIS_CHAR(a) | 0x20), "=", hotend_offset[e][a]);
LOOP_NUM_AXES(a) DEBUG_ECHOPGM(" hotend_offset[", e, "].", AS_CHAR(AXIS_CHAR(a) | 0x20), "=", hotend_offset[e][a]);
DEBUG_EOL();
}
DEBUG_EOL();

View File

@@ -25,7 +25,7 @@
#include "../../module/temperature.h"
#include "../../module/planner.h" // for planner.finish_and_disable
#include "../../module/printcounter.h" // for print_job_timer.stop
#include "../../lcd/marlinui.h" // for LCD_MESSAGEPGM_P
#include "../../lcd/marlinui.h" // for LCD_MESSAGE_F
#include "../../inc/MarlinConfig.h"
@@ -54,7 +54,7 @@
// S: Report the current power supply state and exit
if (parser.seen('S')) {
SERIAL_ECHOPGM_P(powerManager.psu_on ? PSTR("PS:1\n") : PSTR("PS:0\n"));
SERIAL_ECHOF(powerManager.psu_on ? F("PS:1\n") : F("PS:0\n"));
return;
}
@@ -75,7 +75,7 @@
#endif
// PATCH END: Knutwurst
TERN_(HAS_LCD_MENU, ui.reset_status());
TERN_(HAS_MARLINUI_MENU, ui.reset_status());
}
#endif // PSU_CONTROL
@@ -86,26 +86,47 @@
* This code should ALWAYS be available for FULL SHUTDOWN!
*/
void GcodeSuite::M81() {
thermalManager.disable_all_heaters();
planner.finish_and_disable();
thermalManager.cooldown();
print_job_timer.stop();
#if HAS_FAN
thermalManager.zero_fan_speeds();
#if ENABLED(PROBING_FANS_OFF)
thermalManager.fans_paused = false;
ZERO(thermalManager.saved_fan_speed);
#endif
#if BOTH(HAS_FAN, PROBING_FANS_OFF)
thermalManager.fans_paused = false;
ZERO(thermalManager.saved_fan_speed);
#endif
safe_delay(1000); // Wait 1 second before switching off
LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF ".");
bool delayed_power_off = false;
#if ENABLED(POWER_OFF_TIMER)
if (parser.seenval('D')) {
uint16_t delay = parser.value_ushort();
if (delay > 1) { // skip already observed 1s delay
delayed_power_off = true;
powerManager.setPowerOffTimer(SEC_TO_MS(delay - 1));
}
}
#endif
#if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN)
if (parser.boolval('S')) {
delayed_power_off = true;
powerManager.setPowerOffOnCooldown(true);
}
#endif
if (delayed_power_off) {
SERIAL_ECHOLNPGM(STR_DELAYED_POWEROFF);
return;
}
#if HAS_SUICIDE
suicide();
#elif ENABLED(PSU_CONTROL)
powerManager.power_off_soon();
#endif
LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF "."));
}

View File

@@ -29,7 +29,14 @@ void GcodeSuite::M85() {
if (parser.seen('S')) {
reset_stepper_timeout();
max_inactive_time = parser.value_millis_from_seconds();
const millis_t ms = parser.value_millis_from_seconds();
#if LASER_SAFETY_TIMEOUT_MS > 0
if (ms && ms <= LASER_SAFETY_TIMEOUT_MS) {
SERIAL_ECHO_MSG("M85 timeout must be > ", MS_TO_SEC(LASER_SAFETY_TIMEOUT_MS + 999), " s for laser safety.");
return;
}
#endif
max_inactive_time = ms;
}
}

View File

@@ -24,8 +24,8 @@
#if ENABLED(PLATFORM_M997_SUPPORT)
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../lcd/e3v2/enhanced/dwin.h"
#if ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin.h"
#endif
/**
@@ -33,7 +33,7 @@
*/
void GcodeSuite::M997() {
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_RebootScreen());
TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen());
flashFirmware(parser.intval('S'));

View File

@@ -22,7 +22,7 @@
#include "../gcode.h"
#include "../../lcd/marlinui.h" // for lcd_reset_alert_level
#include "../../lcd/marlinui.h" // for ui.reset_alert_level
#include "../../MarlinCore.h" // for marlin_state
#include "../queue.h" // for flush_and_request_resend