Browse Source

Merge pull request #4360 from thinkyhead/rc_toolchange_for_G28

Always switch to tool 0 for G28
Scott Lahteine 9 years ago
parent
commit
16e5348659
3 changed files with 58 additions and 36 deletions
  1. 52
    30
      Marlin/Marlin_main.cpp
  2. 3
    3
      Marlin/ultralcd_impl_DOGM.h
  3. 3
    3
      Marlin/ultralcd_impl_HD44780.h

+ 52
- 30
Marlin/Marlin_main.cpp View File

579
 void serial_echopair_P(const char* s_P, double v)        { serialprintPGM(s_P); SERIAL_ECHO(v); }
579
 void serial_echopair_P(const char* s_P, double v)        { serialprintPGM(s_P); SERIAL_ECHO(v); }
580
 void serial_echopair_P(const char* s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
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
 static void report_current_position();
583
 static void report_current_position();
583
 
584
 
584
 #if ENABLED(DEBUG_LEVELING_FEATURE)
585
 #if ENABLED(DEBUG_LEVELING_FEATURE)
2838
     #endif
2839
     #endif
2839
   #endif
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
    * For mesh bed leveling deactivate the mesh calculations, will be turned
2849
    * For mesh bed leveling deactivate the mesh calculations, will be turned
2843
    * on again when homing all axis
2850
    * on again when homing all axis
3141
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
3148
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
3142
   #endif
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
   report_current_position();
3156
   report_current_position();
3145
 }
3157
 }
3146
 
3158
 
6622
   SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
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
   #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
6639
   #if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
6634
 
6640
 
6643
 
6649
 
6644
   #else //!MIXING_EXTRUDER || MIXING_VIRTUAL_TOOLS <= 1
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
     #if HOTENDS > 1
6652
     #if HOTENDS > 1
6655
 
6653
 
6656
       if (tmp_extruder >= EXTRUDERS) {
6654
       if (tmp_extruder >= EXTRUDERS) {
6660
 
6658
 
6661
       float old_feedrate_mm_m = feedrate_mm_m;
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
       if (tmp_extruder != active_extruder) {
6663
       if (tmp_extruder != active_extruder) {
6671
-        bool no_move = code_seen('S') && code_value_bool();
6672
-
6673
         if (!no_move && axis_unhomed_error(true, true, true)) {
6664
         if (!no_move && axis_unhomed_error(true, true, true)) {
6674
           SERIAL_ECHOLNPGM("No move on toolchange");
6665
           SERIAL_ECHOLNPGM("No move on toolchange");
6675
           no_move = true;
6666
           no_move = true;
6926
 
6917
 
6927
     #endif // HOTENDS <= 1
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
     SERIAL_ECHO_START;
6920
     SERIAL_ECHO_START;
6937
     SERIAL_ECHOPGM(MSG_ACTIVE_EXTRUDER);
6921
     SERIAL_ECHOPGM(MSG_ACTIVE_EXTRUDER);
6938
     SERIAL_PROTOCOLLN((int)active_extruder);
6922
     SERIAL_PROTOCOLLN((int)active_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
  * Process a single command and dispatch it to its handler
6966
  * Process a single command and dispatch it to its handler
6945
  * This is called from the main loop()
6967
  * This is called from the main loop()
6946
  */
6968
  */

+ 3
- 3
Marlin/ultralcd_impl_DOGM.h View File

33
  * License: http://opensource.org/licenses/BSD-3-Clause
33
  * License: http://opensource.org/licenses/BSD-3-Clause
34
  */
34
  */
35
 
35
 
36
-#ifndef DOGM_LCD_IMPLEMENTATION_H
37
-#define DOGM_LCD_IMPLEMENTATION_H
36
+#ifndef ULTRALCD_IMPL_DOGM_H
37
+#define ULTRALCD_IMPL_DOGM_H
38
 
38
 
39
 /**
39
 /**
40
  * Implementation of the LCD display routines for a DOGM128 graphic display.
40
  * Implementation of the LCD display routines for a DOGM128 graphic display.
635
 #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
635
 #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
636
 #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
636
 #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
637
 
637
 
638
-#endif //__DOGM_LCD_IMPLEMENTATION_H
638
+#endif //__ULTRALCD_IMPL_DOGM_H

+ 3
- 3
Marlin/ultralcd_impl_HD44780.h View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-#ifndef ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H
24
-#define ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H
23
+#ifndef ULTRALCD_IMPL_HD44780_H
24
+#define ULTRALCD_IMPL_HD44780_H
25
 
25
 
26
 /**
26
 /**
27
 * Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays.
27
 * Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays.
1006
 
1006
 
1007
 #endif // LCD_HAS_SLOW_BUTTONS
1007
 #endif // LCD_HAS_SLOW_BUTTONS
1008
 
1008
 
1009
-#endif // ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H
1009
+#endif // ULTRALCD_IMPL_HD44780_H

Loading…
Cancel
Save