|
@@ -579,6 +579,7 @@ void serial_echopair_P(const char* s_P, float v) { serialprintPGM(s_P);
|
579
|
579
|
void serial_echopair_P(const char* s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
|
580
|
580
|
void serial_echopair_P(const char* s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
|
581
|
581
|
|
|
582
|
+void tool_change(const uint8_t tmp_extruder, const float fr_mm_m=0.0, bool no_move=false);
|
582
|
583
|
static void report_current_position();
|
583
|
584
|
|
584
|
585
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
@@ -2838,6 +2839,12 @@ inline void gcode_G28() {
|
2838
|
2839
|
#endif
|
2839
|
2840
|
#endif
|
2840
|
2841
|
|
|
2842
|
+ // Always home with tool 0 active
|
|
2843
|
+ #if HOTENDS > 1
|
|
2844
|
+ uint8_t old_tool_index = active_extruder;
|
|
2845
|
+ tool_change(0, 0, true);
|
|
2846
|
+ #endif
|
|
2847
|
+
|
2841
|
2848
|
/**
|
2842
|
2849
|
* For mesh bed leveling deactivate the mesh calculations, will be turned
|
2843
|
2850
|
* on again when homing all axis
|
|
@@ -3141,6 +3148,11 @@ inline void gcode_G28() {
|
3141
|
3148
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
|
3142
|
3149
|
#endif
|
3143
|
3150
|
|
|
3151
|
+ // Restore the active tool after homing
|
|
3152
|
+ #if HOTENDS > 1
|
|
3153
|
+ tool_change(old_tool_index, 0, true);
|
|
3154
|
+ #endif
|
|
3155
|
+
|
3144
|
3156
|
report_current_position();
|
3145
|
3157
|
}
|
3146
|
3158
|
|
|
@@ -6622,13 +6634,7 @@ inline void invalid_extruder_error(const uint8_t &e) {
|
6622
|
6634
|
SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
|
6623
|
6635
|
}
|
6624
|
6636
|
|
6625
|
|
-/**
|
6626
|
|
- * T0-T3: Switch tool, usually switching extruders
|
6627
|
|
- *
|
6628
|
|
- * F[units/min] Set the movement feedrate
|
6629
|
|
- * S1 Don't move the tool in XY after change
|
6630
|
|
- */
|
6631
|
|
-inline void gcode_T(uint8_t tmp_extruder) {
|
|
6637
|
+void tool_change(const uint8_t tmp_extruder, const float fr_mm_m/*=0.0*/, bool no_move/*=false*/) {
|
6632
|
6638
|
|
6633
|
6639
|
#if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
|
6634
|
6640
|
|
|
@@ -6643,14 +6649,6 @@ inline void gcode_T(uint8_t tmp_extruder) {
|
6643
|
6649
|
|
6644
|
6650
|
#else //!MIXING_EXTRUDER || MIXING_VIRTUAL_TOOLS <= 1
|
6645
|
6651
|
|
6646
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
6647
|
|
- if (DEBUGGING(LEVELING)) {
|
6648
|
|
- SERIAL_ECHOPAIR(">>> gcode_T(", tmp_extruder);
|
6649
|
|
- SERIAL_ECHOLNPGM(")");
|
6650
|
|
- DEBUG_POS("BEFORE", current_position);
|
6651
|
|
- }
|
6652
|
|
- #endif
|
6653
|
|
-
|
6654
|
6652
|
#if HOTENDS > 1
|
6655
|
6653
|
|
6656
|
6654
|
if (tmp_extruder >= EXTRUDERS) {
|
|
@@ -6660,16 +6658,9 @@ inline void gcode_T(uint8_t tmp_extruder) {
|
6660
|
6658
|
|
6661
|
6659
|
float old_feedrate_mm_m = feedrate_mm_m;
|
6662
|
6660
|
|
6663
|
|
- if (code_seen('F')) {
|
6664
|
|
- float next_feedrate_mm_m = code_value_axis_units(X_AXIS);
|
6665
|
|
- if (next_feedrate_mm_m > 0.0) old_feedrate_mm_m = feedrate_mm_m = next_feedrate_mm_m;
|
6666
|
|
- }
|
6667
|
|
- else
|
6668
|
|
- feedrate_mm_m = XY_PROBE_FEEDRATE_MM_M;
|
|
6661
|
+ feedrate_mm_m = fr_mm_m > 0.0 ? (old_feedrate_mm_m = fr_mm_m) : XY_PROBE_FEEDRATE_MM_M;
|
6669
|
6662
|
|
6670
|
6663
|
if (tmp_extruder != active_extruder) {
|
6671
|
|
- bool no_move = code_seen('S') && code_value_bool();
|
6672
|
|
-
|
6673
|
6664
|
if (!no_move && axis_unhomed_error(true, true, true)) {
|
6674
|
6665
|
SERIAL_ECHOLNPGM("No move on toolchange");
|
6675
|
6666
|
no_move = true;
|
|
@@ -6926,13 +6917,6 @@ inline void gcode_T(uint8_t tmp_extruder) {
|
6926
|
6917
|
|
6927
|
6918
|
#endif // HOTENDS <= 1
|
6928
|
6919
|
|
6929
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
6930
|
|
- if (DEBUGGING(LEVELING)) {
|
6931
|
|
- DEBUG_POS("AFTER", current_position);
|
6932
|
|
- SERIAL_ECHOLNPGM("<<< gcode_T");
|
6933
|
|
- }
|
6934
|
|
- #endif
|
6935
|
|
-
|
6936
|
6920
|
SERIAL_ECHO_START;
|
6937
|
6921
|
SERIAL_ECHOPGM(MSG_ACTIVE_EXTRUDER);
|
6938
|
6922
|
SERIAL_PROTOCOLLN((int)active_extruder);
|
|
@@ -6941,6 +6925,44 @@ inline void gcode_T(uint8_t tmp_extruder) {
|
6941
|
6925
|
}
|
6942
|
6926
|
|
6943
|
6927
|
/**
|
|
6928
|
+ * T0-T3: Switch tool, usually switching extruders
|
|
6929
|
+ *
|
|
6930
|
+ * F[units/min] Set the movement feedrate
|
|
6931
|
+ * S1 Don't move the tool in XY after change
|
|
6932
|
+ */
|
|
6933
|
+inline void gcode_T(uint8_t tmp_extruder) {
|
|
6934
|
+
|
|
6935
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
6936
|
+ if (DEBUGGING(LEVELING)) {
|
|
6937
|
+ SERIAL_ECHOPAIR(">>> gcode_T(", tmp_extruder);
|
|
6938
|
+ SERIAL_ECHOLNPGM(")");
|
|
6939
|
+ DEBUG_POS("BEFORE", current_position);
|
|
6940
|
+ }
|
|
6941
|
+ #endif
|
|
6942
|
+
|
|
6943
|
+ #if HOTENDS == 1 || (ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1)
|
|
6944
|
+
|
|
6945
|
+ tool_change(tmp_extruder);
|
|
6946
|
+
|
|
6947
|
+ #elif HOTENDS > 1
|
|
6948
|
+
|
|
6949
|
+ tool_change(
|
|
6950
|
+ tmp_extruder,
|
|
6951
|
+ code_seen('F') ? code_value_axis_units(X_AXIS) : 0.0,
|
|
6952
|
+ (tmp_extruder == active_extruder) || (code_seen('S') && code_value_bool())
|
|
6953
|
+ );
|
|
6954
|
+
|
|
6955
|
+ #endif
|
|
6956
|
+
|
|
6957
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
6958
|
+ if (DEBUGGING(LEVELING)) {
|
|
6959
|
+ DEBUG_POS("AFTER", current_position);
|
|
6960
|
+ SERIAL_ECHOLNPGM("<<< gcode_T");
|
|
6961
|
+ }
|
|
6962
|
+ #endif
|
|
6963
|
+}
|
|
6964
|
+
|
|
6965
|
+/**
|
6944
|
6966
|
* Process a single command and dispatch it to its handler
|
6945
|
6967
|
* This is called from the main loop()
|
6946
|
6968
|
*/
|