Переглянути джерело

🎨 ExtUI "user click" and other tweaks (#22122)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
InsanityAutomation 3 роки тому
джерело
коміт
a3e8bb99e4
Аккаунт користувача з таким Email не знайдено

+ 3
- 1
Marlin/src/gcode/bedlevel/mbl/G29.cpp Переглянути файл

@@ -70,7 +70,7 @@ void GcodeSuite::G29() {
70 70
     return;
71 71
   }
72 72
 
73
-  int8_t ix, iy;
73
+  int8_t ix, iy = 0;
74 74
 
75 75
   switch (state) {
76 76
     case MeshReport:
@@ -88,6 +88,7 @@ void GcodeSuite::G29() {
88 88
       mbl_probe_index = 0;
89 89
       if (!ui.wait_for_move) {
90 90
         queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : PSTR("G29S2"));
91
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
91 92
         return;
92 93
       }
93 94
       state = MeshNext;
@@ -109,6 +110,7 @@ void GcodeSuite::G29() {
109 110
       else {
110 111
         // Save Z for the previous mesh position
111 112
         mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z);
113
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, current_position.z));
112 114
         SET_SOFT_ENDSTOP_LOOSE(false);
113 115
       }
114 116
       // If there's another point to sample, move there with optional lift.

+ 93
- 83
Marlin/src/lcd/extui/ui_api.cpp Переглянути файл

@@ -47,6 +47,7 @@
47 47
 
48 48
 #include "../marlinui.h"
49 49
 #include "../../gcode/queue.h"
50
+#include "../../gcode/gcode.h"
50 51
 #include "../../module/motion.h"
51 52
 #include "../../module/planner.h"
52 53
 #include "../../module/probe.h"
@@ -353,14 +354,9 @@ namespace ExtUI {
353 354
 
354 355
   extruder_t getTool(const uint8_t extruder) {
355 356
     switch (extruder) {
356
-      case 7:  return E7;
357
-      case 6:  return E6;
358
-      case 5:  return E5;
359
-      case 4:  return E4;
360
-      case 3:  return E3;
361
-      case 2:  return E2;
362
-      case 1:  return E1;
363
-      default: return E0;
357
+      default:
358
+      case 0: return E0; case 1: return E1; case 2: return E2; case 3: return E3;
359
+      case 4: return E4; case 5: return E5; case 6: return E6; case 7: return E7;
364 360
     }
365 361
   }
366 362
 
@@ -372,8 +368,8 @@ namespace ExtUI {
372 368
     switch (axis) {
373 369
       #if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
374 370
         case X: return axis_should_home(X_AXIS);
375
-        case Y: return axis_should_home(Y_AXIS);
376
-        case Z: return axis_should_home(Z_AXIS);
371
+        OPTCODE(HAS_Y_AXIS, case Y: return axis_should_home(Y_AXIS))
372
+        OPTCODE(HAS_Z_AXIS, case Z: return axis_should_home(Z_AXIS))
377 373
       #else
378 374
         case X: case Y: case Z: return true;
379 375
       #endif
@@ -385,6 +381,8 @@ namespace ExtUI {
385 381
     return !thermalManager.tooColdToExtrude(extruder - E0);
386 382
   }
387 383
 
384
+  GcodeSuite::MarlinBusyState getMachineBusyState() { return TERN0(HOST_KEEPALIVE_FEATURE, GcodeSuite::busy_state); }
385
+
388 386
   #if HAS_SOFTWARE_ENDSTOPS
389 387
     bool getSoftEndstopState() { return soft_endstop._enabled; }
390 388
     void setSoftEndstopState(const bool value) { soft_endstop._enabled = value; }
@@ -396,18 +394,27 @@ namespace ExtUI {
396 394
         #if AXIS_IS_TMC(X)
397 395
           case X: return stepperX.getMilliamps();
398 396
         #endif
399
-        #if AXIS_IS_TMC(X2)
400
-          case X2: return stepperX2.getMilliamps();
401
-        #endif
402 397
         #if AXIS_IS_TMC(Y)
403 398
           case Y: return stepperY.getMilliamps();
404 399
         #endif
405
-        #if AXIS_IS_TMC(Y2)
406
-          case Y2: return stepperY2.getMilliamps();
407
-        #endif
408 400
         #if AXIS_IS_TMC(Z)
409 401
           case Z: return stepperZ.getMilliamps();
410 402
         #endif
403
+        #if AXIS_IS_TMC(I)
404
+          case I: return stepperI.getMilliamps();
405
+        #endif
406
+        #if AXIS_IS_TMC(J)
407
+          case J: return stepperJ.getMilliamps();
408
+        #endif
409
+        #if AXIS_IS_TMC(K)
410
+          case K: return stepperK.getMilliamps();
411
+        #endif
412
+        #if AXIS_IS_TMC(X2)
413
+          case X2: return stepperX2.getMilliamps();
414
+        #endif
415
+        #if AXIS_IS_TMC(Y2)
416
+          case Y2: return stepperY2.getMilliamps();
417
+        #endif
411 418
         #if AXIS_IS_TMC(Z2)
412 419
           case Z2: return stepperZ2.getMilliamps();
413 420
         #endif
@@ -450,18 +457,27 @@ namespace ExtUI {
450 457
         #if AXIS_IS_TMC(X)
451 458
           case X: stepperX.rms_current(constrain(mA, 400, 1500)); break;
452 459
         #endif
453
-        #if AXIS_IS_TMC(X2)
454
-          case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break;
455
-        #endif
456 460
         #if AXIS_IS_TMC(Y)
457 461
           case Y: stepperY.rms_current(constrain(mA, 400, 1500)); break;
458 462
         #endif
459
-        #if AXIS_IS_TMC(Y2)
460
-          case Y2: stepperY2.rms_current(constrain(mA, 400, 1500)); break;
461
-        #endif
462 463
         #if AXIS_IS_TMC(Z)
463 464
           case Z: stepperZ.rms_current(constrain(mA, 400, 1500)); break;
464 465
         #endif
466
+        #if AXIS_IS_TMC(I)
467
+          case I: stepperI.rms_current(constrain(mA, 400, 1500)); break;
468
+        #endif
469
+        #if AXIS_IS_TMC(J)
470
+          case J: stepperJ.rms_current(constrain(mA, 400, 1500)); break;
471
+        #endif
472
+        #if AXIS_IS_TMC(K)
473
+          case K: stepperK.rms_current(constrain(mA, 400, 1500)); break;
474
+        #endif
475
+        #if AXIS_IS_TMC(X2)
476
+          case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break;
477
+        #endif
478
+        #if AXIS_IS_TMC(Y2)
479
+          case Y2: stepperY2.rms_current(constrain(mA, 400, 1500)); break;
480
+        #endif
465 481
         #if AXIS_IS_TMC(Z2)
466 482
           case Z2: stepperZ2.rms_current(constrain(mA, 400, 1500)); break;
467 483
         #endif
@@ -501,66 +517,59 @@ namespace ExtUI {
501 517
 
502 518
     int getTMCBumpSensitivity(const axis_t axis) {
503 519
       switch (axis) {
504
-        #if ENABLED(X_SENSORLESS)
505
-          case X:  return stepperX.homing_threshold();
520
+        OPTCODE(X_SENSORLESS,  case X:  return stepperX.homing_threshold())
521
+        OPTCODE(Y_SENSORLESS,  case Y:  return stepperY.homing_threshold())
522
+        OPTCODE(Z_SENSORLESS,  case Z:  return stepperZ.homing_threshold())
523
+        OPTCODE(I_SENSORLESS,  case I:  return stepperI.homing_threshold())
524
+        OPTCODE(J_SENSORLESS,  case J:  return stepperJ.homing_threshold())
525
+        OPTCODE(K_SENSORLESS,  case K:  return stepperK.homing_threshold())
526
+        OPTCODE(X2_SENSORLESS, case X2: return stepperX2.homing_threshold())
527
+        OPTCODE(Y2_SENSORLESS, case Y2: return stepperY2.homing_threshold())
528
+        OPTCODE(Z2_SENSORLESS, case Z2: return stepperZ2.homing_threshold())
529
+        OPTCODE(Z3_SENSORLESS, case Z3: return stepperZ3.homing_threshold())
530
+        OPTCODE(Z4_SENSORLESS, case Z4: return stepperZ4.homing_threshold())
531
+        default: return 0;
532
+      }
533
+    }
534
+
535
+    void setTMCBumpSensitivity(const_float_t value, const axis_t axis) {
536
+      switch (axis) {
537
+        #if X_SENSORLESS
538
+          case X: stepperX.homing_threshold(value); break;
506 539
         #endif
507
-        #if ENABLED(X2_SENSORLESS)
508
-          case X2: return stepperX2.homing_threshold();
540
+        #if Y_SENSORLESS
541
+          case Y: stepperY.homing_threshold(value); break;
509 542
         #endif
510
-        #if ENABLED(Y_SENSORLESS)
511
-          case Y:  return stepperY.homing_threshold();
543
+        #if Z_SENSORLESS
544
+          case Z: stepperZ.homing_threshold(value); break;
512 545
         #endif
513
-        #if ENABLED(Y2_SENSORLESS)
514
-          case Y2: return stepperY2.homing_threshold();
546
+        #if I_SENSORLESS
547
+          case I: stepperI.homing_threshold(value); break;
515 548
         #endif
516
-        #if ENABLED(Z_SENSORLESS)
517
-          case Z:  return stepperZ.homing_threshold();
549
+        #if J_SENSORLESS
550
+          case J: stepperJ.homing_threshold(value); break;
518 551
         #endif
519
-        #if ENABLED(Z2_SENSORLESS)
520
-          case Z2: return stepperZ2.homing_threshold();
552
+        #if K_SENSORLESS
553
+          case K: stepperK.homing_threshold(value); break;
521 554
         #endif
522
-        #if ENABLED(Z3_SENSORLESS)
523
-          case Z3: return stepperZ3.homing_threshold();
555
+        #if X2_SENSORLESS
556
+          case X2: stepperX2.homing_threshold(value); break;
524 557
         #endif
525
-        #if ENABLED(Z4_SENSORLESS)
526
-          case Z4: return stepperZ4.homing_threshold();
558
+        #if Y2_SENSORLESS
559
+          case Y2: stepperY2.homing_threshold(value); break;
527 560
         #endif
528
-        default: return 0;
529
-      }
530
-    }
531
-
532
-    void setTMCBumpSensitivity(const_float_t value, const axis_t axis) {
533
-      switch (axis) {
534
-        #if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS
535
-          #if X_SENSORLESS
536
-            case X:  stepperX.homing_threshold(value);  break;
537
-          #endif
538
-          #if X2_SENSORLESS
539
-            case X2: stepperX2.homing_threshold(value); break;
540
-          #endif
541
-          #if Y_SENSORLESS
542
-            case Y: stepperY.homing_threshold(value); break;
543
-          #endif
544
-          #if Y2_SENSORLESS
545
-            case Y2: stepperY2.homing_threshold(value); break;
546
-          #endif
547
-          #if Z_SENSORLESS
548
-            case Z: stepperZ.homing_threshold(value); break;
549
-          #endif
550
-          #if Z2_SENSORLESS
551
-            case Z2: stepperZ2.homing_threshold(value); break;
552
-          #endif
553
-          #if Z3_SENSORLESS
554
-            case Z3: stepperZ3.homing_threshold(value); break;
555
-          #endif
556
-          #if Z4_SENSORLESS
557
-            case Z4: stepperZ4.homing_threshold(value); break;
558
-          #endif
559
-        #else
560
-          UNUSED(value);
561
+        #if Z2_SENSORLESS
562
+          case Z2: stepperZ2.homing_threshold(value); break;
563
+        #endif
564
+        #if Z3_SENSORLESS
565
+          case Z3: stepperZ3.homing_threshold(value); break;
566
+        #endif
567
+        #if Z4_SENSORLESS
568
+          case Z4: stepperZ4.homing_threshold(value); break;
561 569
         #endif
562 570
         default: break;
563 571
       }
572
+      UNUSED(value);
564 573
     }
565 574
   #endif
566 575
 
@@ -661,9 +670,7 @@ namespace ExtUI {
661 670
 
662 671
   #if HAS_JUNCTION_DEVIATION
663 672
 
664
-    float getJunctionDeviation_mm() {
665
-      return planner.junction_deviation_mm;
666
-    }
673
+    float getJunctionDeviation_mm() { return planner.junction_deviation_mm; }
667 674
 
668 675
     void setJunctionDeviation_mm(const_float_t value) {
669 676
       planner.junction_deviation_mm = constrain(value, 0.001, 0.3);
@@ -682,7 +689,7 @@ namespace ExtUI {
682 689
   #endif
683 690
 
684 691
   #if PREHEAT_COUNT
685
-      uint16_t getMaterial_preset_E(const uint16_t index) { return ui.material_preset[index].hotend_temp; }
692
+    uint16_t getMaterial_preset_E(const uint16_t index) { return ui.material_preset[index].hotend_temp; }
686 693
     #if HAS_HEATED_BED
687 694
       uint16_t getMaterial_preset_B(const uint16_t index) { return ui.material_preset[index].bed_temp; }
688 695
     #endif
@@ -709,9 +716,13 @@ namespace ExtUI {
709 716
       switch (axis) {
710 717
         #if ENABLED(BABYSTEP_XY)
711 718
           case X: babystep.add_steps(X_AXIS, steps); break;
712
-          case Y: babystep.add_steps(Y_AXIS, steps); break;
719
+          #if HAS_Y_AXIS
720
+            case Y: babystep.add_steps(Y_AXIS, steps); break;
721
+          #endif
722
+        #endif
723
+        #if HAS_Z_AXIS
724
+          case Z: babystep.add_steps(Z_AXIS, steps); break;
713 725
         #endif
714
-        case Z: babystep.add_steps(Z_AXIS, steps); break;
715 726
         default: return false;
716 727
       };
717 728
       return true;
@@ -750,8 +761,8 @@ namespace ExtUI {
750 761
               hotend_offset[e][axis] += mm;
751 762
 
752 763
           normalizeNozzleOffset(X);
753
-          normalizeNozzleOffset(Y);
754
-          normalizeNozzleOffset(Z);
764
+          TERN_(HAS_Y_AXIS, normalizeNozzleOffset(Y));
765
+          TERN_(HAS_Z_AXIS, normalizeNozzleOffset(Z));
755 766
         }
756 767
       #else
757 768
         UNUSED(linked_nozzles);
@@ -1014,8 +1025,7 @@ namespace ExtUI {
1014 1025
     TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
1015 1026
   }
1016 1027
 
1017
-  bool awaitingUserConfirm() { return wait_for_user; }
1018
-
1028
+  bool awaitingUserConfirm() { return TERN0(HAS_RESUME_CONTINUE, wait_for_user); }
1019 1029
   void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); }
1020 1030
 
1021 1031
   void printFile(const char *filename) {
@@ -1038,9 +1048,9 @@ namespace ExtUI {
1038 1048
 
1039 1049
   bool isMediaInserted() { return TERN0(SDSUPPORT, IS_SD_INSERTED() && card.isMounted()); }
1040 1050
 
1041
-  void pausePrint() { ui.pause_print(); }
1051
+  void pausePrint()  { ui.pause_print(); }
1042 1052
   void resumePrint() { ui.resume_print(); }
1043
-  void stopPrint() { ui.abort_print(); }
1053
+  void stopPrint()   { ui.abort_print(); }
1044 1054
 
1045 1055
   void onUserConfirmRequired_P(PGM_P const pstr) {
1046 1056
     char msg[strlen_P(pstr) + 1];

+ 7
- 1
Marlin/src/lcd/extui/ui_api.h Переглянути файл

@@ -44,6 +44,7 @@
44 44
 
45 45
 #include "../../inc/MarlinConfig.h"
46 46
 #include "../marlinui.h"
47
+#include "../../gcode/gcode.h"
47 48
 
48 49
 namespace ExtUI {
49 50
 
@@ -53,7 +54,7 @@ namespace ExtUI {
53 54
 
54 55
   static constexpr size_t eeprom_data_size = 48;
55 56
 
56
-  enum axis_t     : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4 };
57
+  enum axis_t     : uint8_t { X, Y, Z, I, J, K, X2, Y2, Z2, Z3, Z4 };
57 58
   enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 };
58 59
   enum heater_t   : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER, COOLER };
59 60
   enum fan_t      : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 };
@@ -78,6 +79,8 @@ namespace ExtUI {
78 79
   void injectCommands(char * const);
79 80
   bool commandsInQueue();
80 81
 
82
+  GcodeSuite::MarlinBusyState getMachineBusyState();
83
+
81 84
   bool isHeaterIdle(const heater_t);
82 85
   bool isHeaterIdle(const extruder_t);
83 86
   void enableHeater(const heater_t);
@@ -125,6 +128,7 @@ namespace ExtUI {
125 128
   float getAxisMaxAcceleration_mm_s2(const extruder_t);
126 129
   feedRate_t getMinFeedrate_mm_s();
127 130
   feedRate_t getMinTravelFeedrate_mm_s();
131
+  feedRate_t getFeedrate_mm_s();
128 132
   float getPrintingAcceleration_mm_s2();
129 133
   float getRetractAcceleration_mm_s2();
130 134
   float getTravelAcceleration_mm_s2();
@@ -186,6 +190,8 @@ namespace ExtUI {
186 190
     void setHostResponse(const uint8_t);
187 191
   #endif
188 192
 
193
+  inline void simulateUserClick() { ui.lcd_clicked = true; }
194
+
189 195
   #if ENABLED(PRINTCOUNTER)
190 196
     char* getFailedPrints_str(char buffer[21]);
191 197
     char* getTotalPrints_str(char buffer[21]);

+ 4
- 8
Marlin/src/lcd/marlinui.cpp Переглянути файл

@@ -223,6 +223,10 @@ millis_t MarlinUI::next_button_update_ms; // = 0
223 223
 
224 224
 #endif
225 225
 
226
+#if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI)
227
+  bool MarlinUI::lcd_clicked;
228
+#endif
229
+
226 230
 #if HAS_LCD_MENU
227 231
   #include "menu/menu.h"
228 232
 
@@ -247,14 +251,6 @@ millis_t MarlinUI::next_button_update_ms; // = 0
247 251
     uint8_t MarlinUI::repeat_delay;
248 252
   #endif
249 253
 
250
-  bool MarlinUI::lcd_clicked;
251
-
252
-  bool MarlinUI::use_click() {
253
-    const bool click = lcd_clicked;
254
-    lcd_clicked = false;
255
-    return click;
256
-  }
257
-
258 254
   #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION)
259 255
 
260 256
     bool MarlinUI::external_control; // = false

+ 12
- 4
Marlin/src/lcd/marlinui.h Переглянути файл

@@ -474,9 +474,6 @@ public:
474 474
     static void set_selection(const bool sel) { selection = sel; }
475 475
     static bool update_selection();
476 476
 
477
-    static bool lcd_clicked;
478
-    static bool use_click();
479
-
480 477
     static void synchronize(PGM_P const msg=nullptr);
481 478
 
482 479
     static screenFunc_t currentScreen;
@@ -527,12 +524,23 @@ public:
527 524
 
528 525
   #elif HAS_WIRED_LCD
529 526
 
530
-    static constexpr bool lcd_clicked = false;
531 527
     static constexpr bool on_status_screen() { return true; }
532 528
     FORCE_INLINE static void run_current_screen() { status_screen(); }
533 529
 
534 530
   #endif
535 531
 
532
+  #if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI)
533
+    static bool lcd_clicked;
534
+    static inline bool use_click() {
535
+      const bool click = lcd_clicked;
536
+      lcd_clicked = false;
537
+      return click;
538
+    }
539
+  #else
540
+    static constexpr bool lcd_clicked = false;
541
+    static inline bool use_click() { return false; }
542
+  #endif
543
+
536 544
   #if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE)
537 545
     static void pause_show_message(const PauseMessage message, const PauseMode mode=PAUSE_MODE_SAME, const uint8_t extruder=active_extruder);
538 546
   #else

+ 1
- 1
Marlin/src/module/probe.cpp Переглянути файл

@@ -384,7 +384,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
384 384
     DEBUG_EOL();
385 385
 
386 386
     TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0));
387
-    TERN_(WAIT_FOR_BED_HEAT,    if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW))    thermalManager.wait_for_bed_heating());
387
+    TERN_(WAIT_FOR_BED_HEAT,    if (bed_temp    > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating());
388 388
   }
389 389
 
390 390
 #endif

+ 2
- 2
Marlin/src/module/temperature.cpp Переглянути файл

@@ -3621,7 +3621,7 @@ void Temperature::isr() {
3621 3621
         #if G26_CLICK_CAN_CANCEL
3622 3622
           if (click_to_cancel && ui.use_click()) {
3623 3623
             wait_for_heatup = false;
3624
-            ui.quick_feedback();
3624
+            TERN_(HAS_LCD_MENU, ui.quick_feedback());
3625 3625
           }
3626 3626
         #endif
3627 3627
 
@@ -3755,7 +3755,7 @@ void Temperature::isr() {
3755 3755
         #if G26_CLICK_CAN_CANCEL
3756 3756
           if (click_to_cancel && ui.use_click()) {
3757 3757
             wait_for_heatup = false;
3758
-            ui.quick_feedback();
3758
+            TERN_(HAS_LCD_MENU, ui.quick_feedback());
3759 3759
           }
3760 3760
         #endif
3761 3761
 

+ 1
- 1
Marlin/src/module/temperature.h Переглянути файл

@@ -174,7 +174,7 @@ enum ADCSensorState : char {
174 174
   #define unscalePID_d(d) ( float(d) * PID_dT )
175 175
 #endif
176 176
 
177
-#if BOTH(HAS_LCD_MENU, G26_MESH_VALIDATION)
177
+#if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_LCD_MENU, EXTENSIBLE_UI)
178 178
   #define G26_CLICK_CAN_CANCEL 1
179 179
 #endif
180 180
 

Завантаження…
Відмінити
Зберегти