blob: 6b379f119051320b12dd0f9d7812a0423196ef7f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 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 <https://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() ? 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) || AXIS_HAS_STEALTHCHOP(Z4)
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
#if AXIS_HAS_STEALTHCHOP(Z4)
if (index == 3) TMC_SET_STEALTH(Z4);
#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
#if AXIS_HAS_STEALTHCHOP(E6)
case 6: TMC_SET_STEALTH(E6); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E7)
case 7: TMC_SET_STEALTH(E7); 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(Z4)
TMC_SAY_STEALTH_STATUS(Z4);
#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
#if AXIS_HAS_STEALTHCHOP(E6)
TMC_SAY_STEALTH_STATUS(E6);
#endif
#if AXIS_HAS_STEALTHCHOP(E7)
TMC_SAY_STEALTH_STATUS(E7);
#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
|