Browse Source

Merge pull request #8913 from thinkyhead/bf2_multitool_M600

[2.0.x] Multi extruder support for M600 / LCD
Scott Lahteine 7 years ago
parent
commit
f8156d2d2c
No account linked to committer's email address
2 changed files with 150 additions and 47 deletions
  1. 28
    12
      Marlin/src/gcode/feature/pause/M600.cpp
  2. 122
    35
      Marlin/src/lcd/ultralcd.cpp

+ 28
- 12
Marlin/src/gcode/feature/pause/M600.cpp View File

@@ -24,14 +24,15 @@
24 24
 
25 25
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
26 26
 
27
-#include "../../../feature/pause.h"
28
-
29 27
 #include "../../gcode.h"
28
+#include "../../../feature/pause.h"
30 29
 #include "../../../module/motion.h"
31
-#include "../../parser.h"
32
-
33 30
 #include "../../../module/printcounter.h"
34 31
 
32
+#if EXTRUDERS > 1
33
+  #include "../../../module/tool_change.h"
34
+#endif
35
+
35 36
 /**
36 37
  * M600: Pause for filament change
37 38
  *
@@ -42,6 +43,7 @@
42 43
  *  U[distance] - Retract distance for removal (negative value) (manual reload)
43 44
  *  L[distance] - Extrude distance for insertion (positive value) (manual reload)
44 45
  *  B[count]    - Number of times to beep, -1 for indefinite (if equipped with a buzzer)
46
+ *  T[toolhead] - Select extruder for filament change
45 47
  *
46 48
  *  Default values are used for omitted arguments.
47 49
  *
@@ -54,6 +56,18 @@ void GcodeSuite::M600() {
54 56
     if (axis_unhomed_error()) home_all_axes();
55 57
   #endif
56 58
 
59
+  #if EXTRUDERS > 1
60
+    // Change toolhead if specified
61
+    uint8_t active_extruder_before_filament_change = -1;
62
+    if (parser.seen('T')) {
63
+      const uint8_t extruder = parser.value_byte();
64
+      if (active_extruder != extruder) {
65
+        active_extruder_before_filament_change = active_extruder;
66
+        tool_change(extruder, 0, true);
67
+      }
68
+    }
69
+  #endif
70
+
57 71
   // Initial retract before move to filament change position
58 72
   const float retract = parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
59 73
     #ifdef PAUSE_PARK_RETRACT_LENGTH
@@ -61,16 +75,12 @@ void GcodeSuite::M600() {
61 75
     #endif
62 76
   ;
63 77
 
64
-  // Lift Z axis
65
-  if (parser.seenval('Z'))
66
-    park_point.z = parser.linearval('Z');
67
-
68 78
   // Move XY axes to filament change position or given position
69
-  if (parser.seenval('X'))
70
-    park_point.x = parser.linearval('X');
79
+  if (parser.seenval('X')) park_point.x = parser.linearval('X');
80
+  if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
71 81
 
72
-  if (parser.seenval('Y'))
73
-    park_point.y = parser.linearval('Y');
82
+  // Lift Z axis
83
+  if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
74 84
 
75 85
   #if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE)
76 86
     park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
@@ -106,6 +116,12 @@ void GcodeSuite::M600() {
106 116
     resume_print(load_length, ADVANCED_PAUSE_EXTRUDE_LENGTH, beep_count);
107 117
   }
108 118
 
119
+  #if EXTRUDERS > 1
120
+    // Restore toolhead if it was changed
121
+    if (active_extruder_before_filament_change >= 0)
122
+      tool_change(active_extruder_before_filament_change, 0, true);
123
+  #endif
124
+
109 125
   // Resume the print job timer if it was running
110 126
   if (job_running) print_job_timer.start();
111 127
 }

+ 122
- 35
Marlin/src/lcd/ultralcd.cpp View File

@@ -295,7 +295,8 @@ uint16_t max_display_update_time = 0;
295 295
    */
296 296
   #define _MENU_ITEM_PART_1(TYPE, ...) \
297 297
     if (_menuLineNr == _thisItemNr) { \
298
-      if (lcd_clicked && encoderLine == _thisItemNr) {
298
+      if (encoderLine == _thisItemNr && lcd_clicked) { \
299
+        lcd_clicked = false
299 300
 
300 301
   #define _MENU_ITEM_PART_2(TYPE, LABEL, ...) \
301 302
         menu_action_ ## TYPE(__VA_ARGS__); \
@@ -499,6 +500,12 @@ uint16_t max_display_update_time = 0;
499 500
     float raw_Ki, raw_Kd; // place-holders for Ki and Kd edits
500 501
   #endif
501 502
 
503
+  inline bool use_click() {
504
+    const bool click = lcd_clicked;
505
+    lcd_clicked = false;
506
+    return click;
507
+  }
508
+
502 509
   /**
503 510
    * General function to go directly to a screen
504 511
    */
@@ -678,7 +685,7 @@ void lcd_status_screen() {
678 685
 
679 686
   #if ENABLED(ULTIPANEL)
680 687
 
681
-    if (lcd_clicked) {
688
+    if (use_click()) {
682 689
       #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
683 690
         previous_lcd_status_ms = millis();  // get status message to show up for a while
684 691
       #endif
@@ -861,7 +868,7 @@ void kill_screen(const char* lcd_msg) {
861 868
 
862 869
     static void progress_bar_test() {
863 870
       static int8_t bar_percent = 0;
864
-      if (lcd_clicked) {
871
+      if (use_click()) {
865 872
         lcd_goto_previous_menu();
866 873
         lcd_set_custom_characters(CHARSET_MENU);
867 874
         return;
@@ -1088,7 +1095,7 @@ void kill_screen(const char* lcd_msg) {
1088 1095
   #if ENABLED(BABYSTEPPING)
1089 1096
 
1090 1097
     void _lcd_babystep(const AxisEnum axis, const char* msg) {
1091
-      if (lcd_clicked) { return lcd_goto_previous_menu_no_defer(); }
1098
+      if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
1092 1099
       ENCODER_DIRECTION_NORMAL();
1093 1100
       if (encoderPosition) {
1094 1101
         const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
@@ -1111,7 +1118,7 @@ void kill_screen(const char* lcd_msg) {
1111 1118
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
1112 1119
 
1113 1120
       void lcd_babystep_zoffset() {
1114
-        if (lcd_clicked) { return lcd_goto_previous_menu_no_defer(); }
1121
+        if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
1115 1122
         defer_return_to_status = true;
1116 1123
         ENCODER_DIRECTION_NORMAL();
1117 1124
         if (encoderPosition) {
@@ -1239,11 +1246,14 @@ void kill_screen(const char* lcd_msg) {
1239 1246
 
1240 1247
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
1241 1248
 
1242
-    void lcd_enqueue_filament_change() {
1249
+    void lcd_enqueue_filament_change(
1250
+      #if EXTRUDERS > 1
1251
+        const uint8_t extruder
1252
+      #endif
1253
+    ) {
1243 1254
 
1244 1255
       #if ENABLED(PREVENT_COLD_EXTRUSION)
1245
-        if (!DEBUGGING(DRYRUN) && !thermalManager.allow_cold_extrude &&
1246
-            thermalManager.degTargetHotend(active_extruder) < thermalManager.extrude_min_temp) {
1256
+        if (!DEBUGGING(DRYRUN) && thermalManager.tooColdToExtrude(active_extruder)) {
1247 1257
           lcd_save_previous_screen();
1248 1258
           lcd_goto_screen(lcd_advanced_pause_toocold_menu);
1249 1259
           return;
@@ -1251,9 +1261,42 @@ void kill_screen(const char* lcd_msg) {
1251 1261
       #endif
1252 1262
 
1253 1263
       lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT);
1254
-      enqueue_and_echo_commands_P(PSTR("M600 B0"));
1264
+
1265
+      #if EXTRUDERS <= 1
1266
+        enqueue_and_echo_commands_P(PSTR("M600 B0"));
1267
+      #else
1268
+        char *command_M600;
1269
+        switch (extruder) {
1270
+          case 0: command_M600 = PSTR("M600 B0 T0"); break;
1271
+          case 1: command_M600 = PSTR("M600 B0 T1"); break;
1272
+          #if EXTRUDERS > 2
1273
+            case 2: command_M600 = PSTR("M600 B0 T2"); break;
1274
+            #if EXTRUDERS > 3
1275
+              case 3: command_M600 = PSTR("M600 B0 T3"); break;
1276
+              #if EXTRUDERS > 4
1277
+                case 4: command_M600 = PSTR("M600 B0 T4"); break;
1278
+              #endif // EXTRUDERS > 4
1279
+            #endif // EXTRUDERS > 3
1280
+          #endif // EXTRUDERS > 2
1281
+        }
1282
+        enqueue_and_echo_commands_P(command_M600);
1283
+      #endif // EXTRUDERS > 1
1255 1284
     }
1256 1285
 
1286
+    #if EXTRUDERS > 1
1287
+      void lcd_enqueue_filament_change_e0() { lcd_enqueue_filament_change(0); }
1288
+      void lcd_enqueue_filament_change_e1() { lcd_enqueue_filament_change(1); }
1289
+      #if EXTRUDERS > 2
1290
+        void lcd_enqueue_filament_change_e2() { lcd_enqueue_filament_change(2); }
1291
+        #if EXTRUDERS > 3
1292
+          void lcd_enqueue_filament_change_e3() { lcd_enqueue_filament_change(3); }
1293
+          #if EXTRUDERS > 4
1294
+            void lcd_enqueue_filament_change_e4() { lcd_enqueue_filament_change(4); }
1295
+          #endif // EXTRUDERS > 4
1296
+        #endif // EXTRUDERS > 3
1297
+      #endif // EXTRUDERS > 2
1298
+    #endif // EXTRUDERS > 1
1299
+
1257 1300
   #endif // ADVANCED_PAUSE_FEATURE
1258 1301
 
1259 1302
   // First Fan Speed title in "Tune" and "Control>Temperature" menus
@@ -1397,8 +1440,27 @@ void kill_screen(const char* lcd_msg) {
1397 1440
     // Change filament
1398 1441
     //
1399 1442
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
1400
-      if (!thermalManager.tooColdToExtrude(active_extruder))
1401
-        MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change);
1443
+      #if EXTRUDERS > 1
1444
+        if (!thermalManager.tooColdToExtrude(0))
1445
+          MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E1, lcd_enqueue_filament_change_e0);
1446
+        if (!thermalManager.tooColdToExtrude(1))
1447
+          MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E2, lcd_enqueue_filament_change_e1);
1448
+        #if EXTRUDERS > 2
1449
+          if (!thermalManager.tooColdToExtrude(2))
1450
+            MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E3, lcd_enqueue_filament_change_e2);
1451
+          #if EXTRUDERS > 3
1452
+            if (!thermalManager.tooColdToExtrude(3))
1453
+              MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E4, lcd_enqueue_filament_change_e3);
1454
+            #if EXTRUDERS > 4
1455
+              if (!thermalManager.tooColdToExtrude(4))
1456
+                MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E5, lcd_enqueue_filament_change_e4);
1457
+            #endif // EXTRUDERS > 4
1458
+          #endif // EXTRUDERS > 3
1459
+        #endif // EXTRUDERS > 2
1460
+      #else
1461
+        if (!thermalManager.tooColdToExtrude(active_extruder))
1462
+          MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change);
1463
+      #endif
1402 1464
     #endif
1403 1465
 
1404 1466
     END_MENU();
@@ -1793,7 +1855,7 @@ void kill_screen(const char* lcd_msg) {
1793 1855
     void _lcd_level_bed_get_z() {
1794 1856
       ENCODER_DIRECTION_NORMAL();
1795 1857
 
1796
-      if (lcd_clicked) {
1858
+      if (use_click()) {
1797 1859
 
1798 1860
         //
1799 1861
         // Save the current Z position and move
@@ -1873,7 +1935,7 @@ void kill_screen(const char* lcd_msg) {
1873 1935
      */
1874 1936
     void _lcd_level_bed_homing_done() {
1875 1937
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
1876
-      if (lcd_clicked) {
1938
+      if (use_click()) {
1877 1939
         manual_probe_index = 0;
1878 1940
         _lcd_level_goto_next_point();
1879 1941
       }
@@ -2364,7 +2426,7 @@ void kill_screen(const char* lcd_msg) {
2364 2426
       if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
2365 2427
         return lcd_goto_screen(_lcd_ubl_map_homing);
2366 2428
 
2367
-      if (lcd_clicked) return _lcd_ubl_map_lcd_edit_cmd();
2429
+      if (use_click()) return _lcd_ubl_map_lcd_edit_cmd();
2368 2430
       ENCODER_DIRECTION_NORMAL();
2369 2431
 
2370 2432
       if (encoderPosition) {
@@ -2588,9 +2650,30 @@ void kill_screen(const char* lcd_msg) {
2588 2650
     // Change filament
2589 2651
     //
2590 2652
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
2591
-      if (!thermalManager.tooColdToExtrude(active_extruder) && !IS_SD_FILE_OPEN)
2592
-        MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change);
2593
-    #endif
2653
+      if (!IS_SD_FILE_OPEN) {
2654
+        #if EXTRUDERS > 1
2655
+          if (!thermalManager.tooColdToExtrude(0))
2656
+            MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E1, lcd_enqueue_filament_change_e0);
2657
+          if (!thermalManager.tooColdToExtrude(1))
2658
+            MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E2, lcd_enqueue_filament_change_e1);
2659
+          #if EXTRUDERS > 2
2660
+            if (!thermalManager.tooColdToExtrude(2))
2661
+              MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E3, lcd_enqueue_filament_change_e2);
2662
+            #if EXTRUDERS > 3
2663
+              if (!thermalManager.tooColdToExtrude(3))
2664
+                MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E4, lcd_enqueue_filament_change_e3);
2665
+              #if EXTRUDERS > 4
2666
+                if (!thermalManager.tooColdToExtrude(4))
2667
+                  MENU_ITEM(function, MSG_FILAMENTCHANGE " " MSG_E5, lcd_enqueue_filament_change_e4);
2668
+              #endif // EXTRUDERS > 4
2669
+            #endif // EXTRUDERS > 3
2670
+          #endif // EXTRUDERS > 2
2671
+        #else
2672
+          if (!thermalManager.tooColdToExtrude(active_extruder))
2673
+            MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_enqueue_filament_change);
2674
+        #endif
2675
+      }
2676
+    #endif // ADVANCED_PAUSE_FEATURE
2594 2677
 
2595 2678
     #if TEMP_SENSOR_0 != 0
2596 2679
 
@@ -2833,7 +2916,7 @@ void kill_screen(const char* lcd_msg) {
2833 2916
    */
2834 2917
 
2835 2918
   void _lcd_move_xyz(const char* name, AxisEnum axis) {
2836
-    if (lcd_clicked) { return lcd_goto_previous_menu(); }
2919
+    if (use_click()) { return lcd_goto_previous_menu(); }
2837 2920
     ENCODER_DIRECTION_NORMAL();
2838 2921
     if (encoderPosition && !processing_manual_move) {
2839 2922
       gcode.refresh_cmd_timeout();
@@ -2917,7 +3000,7 @@ void kill_screen(const char* lcd_msg) {
2917 3000
       int8_t eindex=-1
2918 3001
     #endif
2919 3002
   ) {
2920
-    if (lcd_clicked) { return lcd_goto_previous_menu(); }
3003
+    if (use_click()) { return lcd_goto_previous_menu(); }
2921 3004
     ENCODER_DIRECTION_NORMAL();
2922 3005
     if (encoderPosition) {
2923 3006
       if (!processing_manual_move) {
@@ -2999,7 +3082,7 @@ void kill_screen(const char* lcd_msg) {
2999 3082
     _manual_move_func_ptr = func;
3000 3083
     START_MENU();
3001 3084
     if (LCD_HEIGHT >= 4) {
3002
-      switch(axis) {
3085
+      switch (axis) {
3003 3086
         case X_AXIS:
3004 3087
           STATIC_ITEM(MSG_MOVE_X, true, true); break;
3005 3088
         case Y_AXIS:
@@ -3802,7 +3885,7 @@ void kill_screen(const char* lcd_msg) {
3802 3885
        *
3803 3886
        */
3804 3887
       void lcd_info_stats_menu() {
3805
-        if (lcd_clicked) { return lcd_goto_previous_menu(); }
3888
+        if (use_click()) { return lcd_goto_previous_menu(); }
3806 3889
 
3807 3890
         char buffer[21];
3808 3891
         printStatistics stats = print_job_timer.getStats();
@@ -3836,7 +3919,7 @@ void kill_screen(const char* lcd_msg) {
3836 3919
      *
3837 3920
      */
3838 3921
     void lcd_info_thermistors_menu() {
3839
-      if (lcd_clicked) { return lcd_goto_previous_menu(); }
3922
+      if (use_click()) { return lcd_goto_previous_menu(); }
3840 3923
       START_SCREEN();
3841 3924
       #define THERMISTOR_ID TEMP_SENSOR_0
3842 3925
       #include "thermistornames.h"
@@ -3897,7 +3980,7 @@ void kill_screen(const char* lcd_msg) {
3897 3980
      *
3898 3981
      */
3899 3982
     void lcd_info_board_menu() {
3900
-      if (lcd_clicked) { return lcd_goto_previous_menu(); }
3983
+      if (use_click()) { return lcd_goto_previous_menu(); }
3901 3984
       START_SCREEN();
3902 3985
       STATIC_ITEM(BOARD_NAME, true, true);                           // MyPrinterController
3903 3986
       STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
@@ -3918,7 +4001,7 @@ void kill_screen(const char* lcd_msg) {
3918 4001
      *
3919 4002
      */
3920 4003
     void lcd_info_printer_menu() {
3921
-      if (lcd_clicked) { return lcd_goto_previous_menu(); }
4004
+      if (use_click()) { return lcd_goto_previous_menu(); }
3922 4005
       START_SCREEN();
3923 4006
       STATIC_ITEM(MSG_MARLIN, true, true);                             // Marlin
3924 4007
       STATIC_ITEM(SHORT_BUILD_VERSION, true);                          // x.x.x-Branch
@@ -4317,7 +4400,7 @@ void kill_screen(const char* lcd_msg) {
4317 4400
         if (liveEdit) (*callbackFunc)(); \
4318 4401
         if (lcd_clicked) lcd_goto_previous_menu(); \
4319 4402
       } \
4320
-      return lcd_clicked; \
4403
+      return use_click(); \
4321 4404
     } \
4322 4405
     void menu_edit_ ## _name() { _menu_edit_ ## _name(); } \
4323 4406
     void menu_edit_callback_ ## _name() { if (_menu_edit_ ## _name()) (*callbackFunc)(); } \
@@ -4674,7 +4757,7 @@ void lcd_update() {
4674 4757
     #if ENABLED(DOGLCD)
4675 4758
       || drawing_screen
4676 4759
     #endif
4677
-    ) {
4760
+  ) {
4678 4761
 
4679 4762
     next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
4680 4763
 
@@ -4778,12 +4861,13 @@ void lcd_update() {
4778 4861
 
4779 4862
     if ((lcdDrawUpdate || IS_DRAWING) && (!bbr2 || bbr2 > max_display_update_time)) {
4780 4863
 
4864
+      // Change state of drawing flag between screen updates
4781 4865
       if (!IS_DRAWING) switch (lcdDrawUpdate) {
4782 4866
         case LCDVIEW_CALL_NO_REDRAW:
4783 4867
           lcdDrawUpdate = LCDVIEW_NONE;
4784 4868
           break;
4785
-        case LCDVIEW_CLEAR_CALL_REDRAW: // set by handlers, then altered after (rarely occurs here)
4786
-        case LCDVIEW_CALL_REDRAW_NEXT:  // set by handlers, then altered after (never occurs here?)
4869
+        case LCDVIEW_CLEAR_CALL_REDRAW:
4870
+        case LCDVIEW_CALL_REDRAW_NEXT:
4787 4871
           lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
4788 4872
         case LCDVIEW_REDRAW_NOW:        // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT
4789 4873
         case LCDVIEW_NONE:
@@ -4795,7 +4879,7 @@ void lcd_update() {
4795 4879
       #endif
4796 4880
 
4797 4881
       #if ENABLED(ULTIPANEL)
4798
-        #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
4882
+        #define CURRENTSCREEN() (*currentScreen)()
4799 4883
       #else
4800 4884
         #define CURRENTSCREEN() lcd_status_screen()
4801 4885
       #endif
@@ -4820,6 +4904,10 @@ void lcd_update() {
4820 4904
         CURRENTSCREEN();
4821 4905
       #endif
4822 4906
 
4907
+      #if ENABLED(ULTIPANEL)
4908
+        lcd_clicked = false;
4909
+      #endif
4910
+
4823 4911
       // Keeping track of the longest time for an individual LCD update.
4824 4912
       // Used to do screen throttling when the planner starts to fill up.
4825 4913
       NOLESS(max_display_update_time, millis() - ms);
@@ -4835,17 +4923,16 @@ void lcd_update() {
4835 4923
 
4836 4924
     #endif // ULTIPANEL
4837 4925
 
4926
+    // Change state of drawing flag between screen updates
4838 4927
     if (!IS_DRAWING) switch (lcdDrawUpdate) {
4839 4928
       case LCDVIEW_CLEAR_CALL_REDRAW:
4840
-        lcd_implementation_clear();
4841
-      case LCDVIEW_CALL_REDRAW_NEXT:
4842
-        lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
4843
-        break;
4929
+        lcd_implementation_clear(); break;
4844 4930
       case LCDVIEW_REDRAW_NOW:
4845 4931
         lcdDrawUpdate = LCDVIEW_NONE;
4846
-        break;
4847 4932
       case LCDVIEW_NONE:
4848
-        break;
4933
+      case LCDVIEW_CALL_REDRAW_NEXT:
4934
+      case LCDVIEW_CALL_NO_REDRAW:
4935
+      default: break;
4849 4936
     } // switch
4850 4937
 
4851 4938
   } // ELAPSED(ms, next_lcd_update_ms)

Loading…
Cancel
Save