Quellcode durchsuchen

Allow G26 to use the active extruder (#12387)

* Make lcd_quick_feedback argument optional
* Add click_to_cancel option to wait_for_hotend/bed
* Have G26 use the active nozzle and wait_for_hotend/bed
* Use wait_for_release in UBL G29
* Add 'T' parameter to G26 for an initial tool-change
Scott Lahteine vor 6 Jahren
Ursprung
Commit
6093df11dc
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden

+ 17
- 19
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Datei anzeigen

@@ -630,7 +630,7 @@
630 630
 
631 631
     #if HAS_LCD_MENU
632 632
       lcd_reset_alert_level();
633
-      lcd_quick_feedback(true);
633
+      lcd_quick_feedback();
634 634
       lcd_reset_status();
635 635
       lcd_external_control = false;
636 636
     #endif
@@ -689,16 +689,14 @@
689 689
 
690 690
     bool click_and_hold(const clickFunc_t func=NULL) {
691 691
       if (is_lcd_clicked()) {
692
-        lcd_quick_feedback(false); // Do NOT clear button status!  If cleared, the code
693
-                                   // code can not look for a 'click and hold'
692
+        lcd_quick_feedback(false);                // Preserve button state for click-and-hold
694 693
         const millis_t nxt = millis() + 1500UL;
695 694
         while (is_lcd_clicked()) {                // Loop while the encoder is pressed. Uses hardware flag!
696 695
           idle();                                 // idle, of course
697 696
           if (ELAPSED(millis(), nxt)) {           // After 1.5 seconds
698
-            lcd_quick_feedback(true);
697
+            lcd_quick_feedback();
699 698
             if (func) (*func)();
700 699
             wait_for_release();
701
-            safe_delay(50);                       // Debounce the Encoder wheel
702 700
             return true;
703 701
           }
704 702
         }
@@ -721,7 +719,7 @@
721 719
         lcd_external_control = true;
722 720
       #endif
723 721
 
724
-      save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
722
+      save_ubl_active_state_and_disable();   // No bed level correction so only raw data is obtained
725 723
       DEPLOY_PROBE();
726 724
 
727 725
       uint16_t count = GRID_MAX_POINTS;
@@ -731,14 +729,13 @@
731 729
 
732 730
         #if HAS_LCD_MENU
733 731
           if (is_lcd_clicked()) {
732
+            lcd_quick_feedback(false); // Preserve button state for click-and-hold
734 733
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
735
-            lcd_quick_feedback(false);
736 734
             STOW_PROBE();
737
-            while (is_lcd_clicked()) idle();
735
+            wait_for_release();
736
+            lcd_quick_feedback();
738 737
             lcd_external_control = false;
739 738
             restore_ubl_active_state_and_leave();
740
-            lcd_quick_feedback(true);
741
-            safe_delay(50);  // Debounce the Encoder wheel
742 739
             return;
743 740
           }
744 741
         #endif
@@ -843,7 +840,7 @@
843 840
       do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
844 841
       lcd_external_control = false;
845 842
       KEEPALIVE_STATE(IN_HANDLER);
846
-      lcd_quick_feedback(true);
843
+      lcd_quick_feedback();
847 844
       ubl.restore_ubl_active_state_and_leave();
848 845
     }
849 846
 
@@ -910,12 +907,16 @@
910 907
     }
911 908
   #endif // HAS_LCD_MENU
912 909
 
910
+  inline void set_message_with_feedback(PGM_P const msg_P) {
911
+    lcd_setstatusPGM(msg_P);
912
+    lcd_quick_feedback();
913
+  }
914
+
913 915
   bool unified_bed_leveling::g29_parameter_parsing() {
914 916
     bool err_flag = false;
915 917
 
916 918
     #if HAS_LCD_MENU
917
-      LCD_MESSAGEPGM(MSG_UBL_DOING_G29);
918
-      lcd_quick_feedback(true);
919
+      set_message_with_feedback(PSTR(MSG_UBL_DOING_G29));
919 920
     #endif
920 921
 
921 922
     g29_constant = 0;
@@ -1037,8 +1038,7 @@
1037 1038
       if (ubl_state_recursion_chk != 1) {
1038 1039
         SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
1039 1040
         #if HAS_LCD_MENU
1040
-          LCD_MESSAGEPGM(MSG_UBL_SAVE_ERROR);
1041
-          lcd_quick_feedback(true);
1041
+          set_message_with_feedback(PSTR(MSG_UBL_SAVE_ERROR));
1042 1042
         #endif
1043 1043
         return;
1044 1044
       }
@@ -1052,8 +1052,7 @@
1052 1052
       if (--ubl_state_recursion_chk) {
1053 1053
         SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
1054 1054
         #if HAS_LCD_MENU
1055
-          LCD_MESSAGEPGM(MSG_UBL_RESTORE_ERROR);
1056
-          lcd_quick_feedback(true);
1055
+          set_message_with_feedback(PSTR(MSG_UBL_RESTORE_ERROR));
1057 1056
         #endif
1058 1057
         return;
1059 1058
       }
@@ -1344,8 +1343,7 @@
1344 1343
     void abort_fine_tune() {
1345 1344
       lcd_return_to_status();
1346 1345
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1347
-      LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
1348
-      lcd_quick_feedback(true);
1346
+      set_message_with_feedback(PSTR(MSG_EDITING_STOPPED));
1349 1347
     }
1350 1348
 
1351 1349
     void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {

+ 42
- 50
Marlin/src/gcode/bedlevel/G26.cpp Datei anzeigen

@@ -38,6 +38,7 @@
38 38
 #include "../../module/planner.h"
39 39
 #include "../../module/stepper.h"
40 40
 #include "../../module/motion.h"
41
+#include "../../module/tool_change.h"
41 42
 #include "../../module/temperature.h"
42 43
 #include "../../lcd/ultralcd.h"
43 44
 
@@ -165,18 +166,12 @@ int8_t g26_prime_flag;
165 166
     if (!is_lcd_clicked()) return false; // Return if the button isn't pressed
166 167
     lcd_setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
167 168
     #if HAS_LCD_MENU
168
-      lcd_quick_feedback(true);
169
+      lcd_quick_feedback();
169 170
     #endif
170 171
     wait_for_release();
171 172
     return true;
172 173
   }
173 174
 
174
-  bool exit_from_g26() {
175
-    lcd_setstatusPGM(PSTR("Leaving G26"), -1);
176
-    wait_for_release();
177
-    return G26_ERR;
178
-  }
179
-
180 175
 #endif
181 176
 
182 177
 mesh_index_pair find_closest_circle_to_print(const float &X, const float &Y) {
@@ -412,58 +407,50 @@ inline bool look_for_lines_to_connect() {
412 407
  * wait for them to get up to temperature.
413 408
  */
414 409
 inline bool turn_on_heaters() {
415
-  millis_t next = millis() + 5000UL;
410
+
411
+  SERIAL_ECHOLNPGM("Waiting for heatup.");
412
+
416 413
   #if HAS_HEATED_BED
417
-    #if ENABLED(ULTRA_LCD)
418
-      if (g26_bed_temp > 25) {
414
+
415
+    if (g26_bed_temp > 25) {
416
+      #if ENABLED(ULTRA_LCD)
419 417
         lcd_setstatusPGM(PSTR("G26 Heating Bed."), 99);
420
-        lcd_quick_feedback(true);
418
+        lcd_quick_feedback();
421 419
         #if HAS_LCD_MENU
422 420
           lcd_external_control = true;
423 421
         #endif
424
-    #endif
425
-        thermalManager.setTargetBed(g26_bed_temp);
426
-        while (ABS(thermalManager.degBed() - g26_bed_temp) > 3) {
422
+      #endif
423
+      thermalManager.setTargetBed(g26_bed_temp);
427 424
 
428
-          #if HAS_LCD_MENU
429
-            if (is_lcd_clicked()) return exit_from_g26();
425
+      // Wait for the temperature to stabilize
426
+      if (!thermalManager.wait_for_bed(true
427
+          #if G26_CLICK_CAN_CANCEL
428
+            , true
430 429
           #endif
430
+        )
431
+      ) return G26_ERR;
432
+    }
431 433
 
432
-          if (ELAPSED(millis(), next)) {
433
-            next = millis() + 5000UL;
434
-            thermalManager.print_heaterstates();
435
-            SERIAL_EOL();
436
-          }
437
-          idle();
438
-          SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
439
-        }
440
-    #if ENABLED(ULTRA_LCD)
441
-      }
442
-      lcd_setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
443
-      lcd_quick_feedback(true);
444
-    #endif
445
-  #endif
446
-
447
-  // Start heating the nozzle and wait for it to reach temperature.
448
-  thermalManager.setTargetHotend(g26_hotend_temp, 0);
449
-  while (ABS(thermalManager.degHotend(0) - g26_hotend_temp) > 3) {
434
+  #endif // HAS_HEATED_BED
450 435
 
451
-    #if HAS_LCD_MENU
452
-      if (is_lcd_clicked()) return exit_from_g26();
453
-    #endif
436
+  // Start heating the active nozzle
437
+  #if ENABLED(ULTRA_LCD)
438
+    lcd_setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
439
+    lcd_quick_feedback();
440
+  #endif
441
+  thermalManager.setTargetHotend(g26_hotend_temp, active_extruder);
454 442
 
455
-    if (ELAPSED(millis(), next)) {
456
-      next = millis() + 5000UL;
457
-      thermalManager.print_heaterstates();
458
-      SERIAL_EOL();
459
-    }
460
-    idle();
461
-    SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
462
-  }
443
+  // Wait for the temperature to stabilize
444
+  if (!thermalManager.wait_for_hotend(active_extruder, true
445
+      #if G26_CLICK_CAN_CANCEL
446
+        , true
447
+      #endif
448
+    )
449
+  ) return G26_ERR;
463 450
 
464 451
   #if ENABLED(ULTRA_LCD)
465 452
     lcd_reset_status();
466
-    lcd_quick_feedback(true);
453
+    lcd_quick_feedback();
467 454
   #endif
468 455
 
469 456
   return G26_OK;
@@ -507,7 +494,7 @@ inline bool prime_nozzle() {
507 494
       wait_for_release();
508 495
 
509 496
       lcd_setstatusPGM(PSTR("Done Priming"), 99);
510
-      lcd_quick_feedback(true);
497
+      lcd_quick_feedback();
511 498
       lcd_external_control = false;
512 499
     }
513 500
     else
@@ -515,7 +502,7 @@ inline bool prime_nozzle() {
515 502
   {
516 503
     #if ENABLED(ULTRA_LCD)
517 504
       lcd_setstatusPGM(PSTR("Fixed Length Prime."), 99);
518
-      lcd_quick_feedback(true);
505
+      lcd_quick_feedback();
519 506
     #endif
520 507
     set_destination_from_current();
521 508
     destination[E_AXIS] += g26_prime_length;
@@ -553,17 +540,21 @@ float valid_trig_angle(float d) {
553 540
  *  Q  Retraction multiplier
554 541
  *  R  Repetitions (number of grid points)
555 542
  *  S  Nozzle Size (diameter) in mm
543
+ *  T  Tool index to change to, if included
556 544
  *  U  Random deviation (50 if no value given)
557 545
  *  X  X position
558 546
  *  Y  Y position
559 547
  */
560 548
 void GcodeSuite::G26() {
561
-  SERIAL_ECHOLNPGM("G26 command started. Waiting for heater(s).");
549
+  SERIAL_ECHOLNPGM("G26 starting...");
562 550
 
563 551
   // Don't allow Mesh Validation without homing first,
564 552
   // or if the parameter parsing did not go OK, abort
565 553
   if (axis_unhomed_error()) return;
566 554
 
555
+  // Change the tool first, if specified
556
+  if (parser.seenval('T')) tool_change(parser.value_int());
557
+
567 558
   g26_extrusion_multiplier    = EXTRUSION_MULTIPLIER;
568 559
   g26_retraction_multiplier   = RETRACTION_MULTIPLIER;
569 560
   g26_layer_height            = MESH_TEST_LAYER_HEIGHT;
@@ -891,6 +882,7 @@ void GcodeSuite::G26() {
891 882
 
892 883
   LEAVE:
893 884
   lcd_setstatusPGM(PSTR("Leaving G26"), -1);
885
+  wait_for_release();
894 886
 
895 887
   retract_filament(destination);
896 888
   destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;
@@ -914,7 +906,7 @@ void GcodeSuite::G26() {
914 906
     #if HAS_HEATED_BED
915 907
       thermalManager.setTargetBed(0);
916 908
     #endif
917
-    thermalManager.setTargetHotend(0, 0);
909
+    thermalManager.setTargetHotend(active_extruder, 0);
918 910
   }
919 911
 }
920 912
 

+ 0
- 1
Marlin/src/lcd/menu/menu.h Datei anzeigen

@@ -30,7 +30,6 @@ extern bool screen_changed;
30 30
 constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
31 31
 
32 32
 void scroll_screen(const uint8_t limit, const bool is_menu);
33
-bool use_click();
34 33
 bool printer_busy();
35 34
 void lcd_completion_feedback(const bool good=true);
36 35
 void lcd_save_previous_screen();

+ 5
- 5
Marlin/src/lcd/ultralcd.cpp Datei anzeigen

@@ -244,8 +244,8 @@ bool lcd_blink() {
244 244
           #if HAS_LCD_MENU
245 245
             if      (RRK(EN_REPRAPWORLD_KEYPAD_DOWN))   encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
246 246
             else if (RRK(EN_REPRAPWORLD_KEYPAD_UP))     encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
247
-            else if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT))   { menu_item_back::action(); lcd_quick_feedback(true); }
248
-            else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT))  { lcd_return_to_status(); lcd_quick_feedback(true); }
247
+            else if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT))   { menu_item_back::action(); lcd_quick_feedback(); }
248
+            else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT))  { lcd_return_to_status(); lcd_quick_feedback(); }
249 249
           #endif
250 250
         }
251 251
         else if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN))     encoderPosition += ENCODER_PULSES_PER_STEP;
@@ -484,7 +484,7 @@ void kill_screen(PGM_P lcd_msg) {
484 484
   }
485 485
 #endif
486 486
 
487
-void lcd_quick_feedback(const bool clear_buttons) {
487
+void lcd_quick_feedback(const bool clear_buttons/*=true*/) {
488 488
 
489 489
   #if HAS_LCD_MENU
490 490
     lcd_refresh();
@@ -661,14 +661,14 @@ void lcd_update() {
661 661
         wait_for_unclick = true;         //  Set debounce flag to ignore continous clicks
662 662
         lcd_clicked = !wait_for_user && !no_reentry; //  Keep the click if not waiting for a user-click
663 663
         wait_for_user = false;           //  Any click clears wait for user
664
-        lcd_quick_feedback(true);        //  Always make a click sound
664
+        lcd_quick_feedback();        //  Always make a click sound
665 665
       }
666 666
     }
667 667
     else wait_for_unclick = false;
668 668
 
669 669
     #if BUTTON_EXISTS(BACK)
670 670
       if (LCD_BACK_CLICKED) {
671
-        lcd_quick_feedback(true);
671
+        lcd_quick_feedback();
672 672
         lcd_goto_previous_menu();
673 673
       }
674 674
     #endif

+ 3
- 1
Marlin/src/lcd/ultralcd.h Datei anzeigen

@@ -242,7 +242,7 @@
242 242
     inline void lcd_buzz(const long duration, const uint16_t freq) { UNUSED(duration); UNUSED(freq); }
243 243
   #endif
244 244
 
245
-  void lcd_quick_feedback(const bool clear_buttons); // Audible feedback for a button click - could also be visual
245
+  void lcd_quick_feedback(const bool clear_buttons=true); // Audible feedback for a button click - could also be visual
246 246
 
247 247
   #if ENABLED(LCD_PROGRESS_BAR)
248 248
     extern millis_t progress_bar_ms;  // Start time for the current progress bar cycle
@@ -351,6 +351,8 @@
351 351
 
352 352
   bool lcd_blink();
353 353
 
354
+  bool use_click();
355
+
354 356
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
355 357
     bool is_lcd_clicked();
356 358
     void wait_for_release();

+ 26
- 2
Marlin/src/module/temperature.cpp Datei anzeigen

@@ -2441,7 +2441,11 @@ void Temperature::isr() {
2441 2441
       #define MIN_COOLING_SLOPE_TIME 60
2442 2442
     #endif
2443 2443
 
2444
-    bool Temperature::wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling/*=true*/) {
2444
+    bool Temperature::wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling/*=true*/
2445
+      #if G26_CLICK_CAN_CANCEL
2446
+        , const bool click_to_cancel/*=false*/
2447
+      #endif
2448
+    ) {
2445 2449
       #if TEMP_RESIDENCY_TIME > 0
2446 2450
         millis_t residency_start_ms = 0;
2447 2451
         // Loop until the temperature has stabilized
@@ -2525,6 +2529,13 @@ void Temperature::isr() {
2525 2529
           }
2526 2530
         }
2527 2531
 
2532
+        #if G26_CLICK_CAN_CANCEL
2533
+          if (click_to_cancel && use_click()) {
2534
+            wait_for_heatup = false;
2535
+            lcd_quick_feedback();
2536
+          }
2537
+        #endif
2538
+
2528 2539
       } while (wait_for_heatup && TEMP_CONDITIONS);
2529 2540
 
2530 2541
       if (wait_for_heatup) {
@@ -2552,7 +2563,11 @@ void Temperature::isr() {
2552 2563
       #define MIN_COOLING_SLOPE_TIME_BED 60
2553 2564
     #endif
2554 2565
 
2555
-    void Temperature::wait_for_bed(const bool no_wait_for_cooling) {
2566
+    bool Temperature::wait_for_bed(const bool no_wait_for_cooling
2567
+      #if G26_CLICK_CAN_CANCEL
2568
+        , const bool click_to_cancel/*=false*/
2569
+      #endif
2570
+    ) {
2556 2571
       #if TEMP_BED_RESIDENCY_TIME > 0
2557 2572
         millis_t residency_start_ms = 0;
2558 2573
         // Loop until the temperature has stabilized
@@ -2639,6 +2654,13 @@ void Temperature::isr() {
2639 2654
           }
2640 2655
         }
2641 2656
 
2657
+        #if G26_CLICK_CAN_CANCEL
2658
+          if (click_to_cancel && use_click()) {
2659
+            wait_for_heatup = false;
2660
+            lcd_quick_feedback();
2661
+          }
2662
+        #endif
2663
+
2642 2664
       } while (wait_for_heatup && TEMP_BED_CONDITIONS);
2643 2665
 
2644 2666
       if (wait_for_heatup) lcd_reset_status();
@@ -2646,6 +2668,8 @@ void Temperature::isr() {
2646 2668
       #if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
2647 2669
         gcode.busy_state = old_busy_state;
2648 2670
       #endif
2671
+
2672
+      return wait_for_heatup;
2649 2673
     }
2650 2674
 
2651 2675
   #endif // HAS_HEATED_BED

+ 12
- 2
Marlin/src/module/temperature.h Datei anzeigen

@@ -138,6 +138,8 @@ enum ADCSensorState : char {
138 138
   #define unscalePID_d(d) ( float(d) * PID_dT )
139 139
 #endif
140 140
 
141
+#define G26_CLICK_CAN_CANCEL (HAS_LCD_MENU && ENABLED(G26_MESH_VALIDATION))
142
+
141 143
 class Temperature {
142 144
 
143 145
   public:
@@ -426,7 +428,11 @@ class Temperature {
426 428
     }
427 429
 
428 430
     #if HAS_TEMP_HOTEND
429
-      static bool wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling=true);
431
+      static bool wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling=true
432
+        #if G26_CLICK_CAN_CANCEL
433
+          , const bool click_to_cancel=false
434
+        #endif
435
+      );
430 436
     #endif
431 437
 
432 438
     #if HAS_HEATED_BED
@@ -459,7 +465,11 @@ class Temperature {
459 465
         static void start_watching_bed();
460 466
       #endif
461 467
 
462
-      static void wait_for_bed(const bool no_wait_for_cooling);
468
+      static bool wait_for_bed(const bool no_wait_for_cooling
469
+        #if G26_CLICK_CAN_CANCEL
470
+          , const bool click_to_cancel=false
471
+        #endif
472
+      );
463 473
 
464 474
     #endif // HAS_HEATED_BED
465 475
 

Laden…
Abbrechen
Speichern