M569 to change stepping mode. Add new TMC section to LCD. (#12884)

This commit is contained in:
teemuatlut
2019-01-17 21:17:16 +02:00
committed by Scott Lahteine
parent d08f27e27b
commit e6805582a6
84 changed files with 1542 additions and 80 deletions

View File

@ -0,0 +1,165 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if HAS_STEALTHCHOP
#include "../../gcode.h"
#include "../../../feature/tmc_util.h"
#include "../../../module/stepper_indirection.h"
template<typename TMC>
void tmc_say_stealth_status(TMC &st) {
st.printLabel();
SERIAL_ECHOPGM(" driver mode:\t");
serialprintPGM(st.get_stealthChop_status() ? PSTR("stealthChop") : PSTR("spreadCycle"));
SERIAL_EOL();
}
template<typename TMC>
void tmc_set_stealthChop(TMC &st, const bool enable) {
st.stored.stealthChop_enabled = enable;
st.refresh_stepping_mode();
}
static void set_stealth_status(const bool enable, const int8_t target_extruder) {
#define TMC_SET_STEALTH(Q) tmc_set_stealthChop(stepper##Q, enable)
#if AXIS_HAS_STEALTHCHOP(X) || AXIS_HAS_STEALTHCHOP(X2) || AXIS_HAS_STEALTHCHOP(Y) || AXIS_HAS_STEALTHCHOP(Y2) || AXIS_HAS_STEALTHCHOP(Z) || AXIS_HAS_STEALTHCHOP(Z2) || AXIS_HAS_STEALTHCHOP(Z3)
const uint8_t index = parser.byteval('I');
#endif
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) {
switch (i) {
case X_AXIS:
#if AXIS_HAS_STEALTHCHOP(X)
if (index == 0) TMC_SET_STEALTH(X);
#endif
#if AXIS_HAS_STEALTHCHOP(X2)
if (index == 1) TMC_SET_STEALTH(X2);
#endif
break;
case Y_AXIS:
#if AXIS_HAS_STEALTHCHOP(Y)
if (index == 0) TMC_SET_STEALTH(Y);
#endif
#if AXIS_HAS_STEALTHCHOP(Y2)
if (index == 1) TMC_SET_STEALTH(Y2);
#endif
break;
case Z_AXIS:
#if AXIS_HAS_STEALTHCHOP(Z)
if (index == 0) TMC_SET_STEALTH(Z);
#endif
#if AXIS_HAS_STEALTHCHOP(Z2)
if (index == 1) TMC_SET_STEALTH(Z2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z3)
if (index == 2) TMC_SET_STEALTH(Z3);
#endif
break;
case E_AXIS: {
if (target_extruder < 0) return;
switch (target_extruder) {
#if AXIS_HAS_STEALTHCHOP(E0)
case 0: TMC_SET_STEALTH(E0); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E1)
case 1: TMC_SET_STEALTH(E1); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E2)
case 2: TMC_SET_STEALTH(E2); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E3)
case 3: TMC_SET_STEALTH(E3); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E4)
case 4: TMC_SET_STEALTH(E4); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E5)
case 5: TMC_SET_STEALTH(E5); break;
#endif
}
} break;
}
}
}
static void say_stealth_status() {
#define TMC_SAY_STEALTH_STATUS(Q) tmc_say_stealth_status(stepper##Q)
#if AXIS_HAS_STEALTHCHOP(X)
TMC_SAY_STEALTH_STATUS(X);
#endif
#if AXIS_HAS_STEALTHCHOP(X2)
TMC_SAY_STEALTH_STATUS(X2);
#endif
#if AXIS_HAS_STEALTHCHOP(Y)
TMC_SAY_STEALTH_STATUS(Y);
#endif
#if AXIS_HAS_STEALTHCHOP(Y2)
TMC_SAY_STEALTH_STATUS(Y2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z)
TMC_SAY_STEALTH_STATUS(Z);
#endif
#if AXIS_HAS_STEALTHCHOP(Z2)
TMC_SAY_STEALTH_STATUS(Z2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z3)
TMC_SAY_STEALTH_STATUS(Z3);
#endif
#if AXIS_HAS_STEALTHCHOP(E0)
TMC_SAY_STEALTH_STATUS(E0);
#endif
#if AXIS_HAS_STEALTHCHOP(E1)
TMC_SAY_STEALTH_STATUS(E1);
#endif
#if AXIS_HAS_STEALTHCHOP(E2)
TMC_SAY_STEALTH_STATUS(E2);
#endif
#if AXIS_HAS_STEALTHCHOP(E3)
TMC_SAY_STEALTH_STATUS(E3);
#endif
#if AXIS_HAS_STEALTHCHOP(E4)
TMC_SAY_STEALTH_STATUS(E4);
#endif
#if AXIS_HAS_STEALTHCHOP(E5)
TMC_SAY_STEALTH_STATUS(E5);
#endif
}
/**
* M569: Enable stealthChop on an axis
*
* S[1|0] to enable or disable
* XYZE to target an axis
* No arguments reports the stealthChop status of all capable drivers.
*/
void GcodeSuite::M569() {
if (parser.seen('S'))
set_stealth_status(parser.value_bool(), get_target_extruder_from_command());
else
say_stealth_status();
}
#endif // HAS_STEALTHCHOP

View File

@ -652,6 +652,9 @@ void GcodeSuite::process_parsed_command(
#if HAS_TRINAMIC
case 122: M122(); break;
case 906: M906(); break; // M906: Set motor current in milliamps using axis codes X, Y, Z, E
#if HAS_STEALTHCHOP
case 569: M569(); break; // M569: Enable stealthChop on an axis.
#endif
#if ENABLED(MONITOR_DRIVER_STATUS)
case 911: M911(); break; // M911: Report TMC2130 prewarn triggered flags
case 912: M912(); break; // M912: Clear TMC2130 prewarn triggered flags

View File

@ -209,6 +209,7 @@
* M503 - Print the current settings (in memory): "M503 S<verbose>". S0 specifies compact output.
* M524 - Abort the current SD print job (started with M24)
* M540 - Enable/disable SD card abort on endstop hit: "M540 S<state>". (Requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
* M569 - Enable stealthChop on an axis. (Requires at least one #_X_DRIVER_TYPE to be TMC2130 or TMC2208)
* M600 - Pause for filament change: "M600 X<pos> Y<pos> Z<raise> E<first_retract> L<later_retract>". (Requires ADVANCED_PAUSE_FEATURE)
* M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
* M605 - Set Dual X-Carriage movement mode: "M605 S<mode> [X<x_offset>] [R<temp_offset>]". (Requires DUAL_X_CARRIAGE)
@ -796,6 +797,9 @@ private:
#if HAS_TRINAMIC
static void M122();
static void M906();
#if HAS_STEALTHCHOP
static void M569();
#endif
#if ENABLED(MONITOR_DRIVER_STATUS)
static void M911();
static void M912();