Browse Source

Merge pull request #8696 from thinkyhead/bf1_fixes_DEC6

[1.1.x] Cleanup, bugfixes, parity with 2.0.x
Scott Lahteine 7 years ago
parent
commit
f30b774f26
No account linked to committer's email address

+ 30
- 33
Marlin/G26_Mesh_Validation_Tool.cpp View File

@@ -164,50 +164,49 @@
164 164
   static int8_t g26_prime_flag;
165 165
 
166 166
   #if ENABLED(NEWPANEL)
167
+
167 168
     /**
168 169
      * Detect is_lcd_clicked, debounce it, and return true for cancel
169 170
      */
170 171
     bool user_canceled() {
171
-      if (!is_lcd_clicked()) return false;
172
-      safe_delay(10);                       // Wait for click to settle
172
+      if (!is_lcd_clicked()) return false; // Return if the button isn't pressed
173 173
 
174 174
       #if ENABLED(ULTRA_LCD)
175 175
         lcd_setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
176 176
         lcd_quick_feedback();
177 177
       #endif
178 178
 
179
-      while (!is_lcd_clicked()) idle();    // Wait for button release
179
+      safe_delay(10);                      // Wait for click to settle
180
+      while (!is_lcd_clicked()) idle();    // Wait for button press again?
180 181
 
181 182
       // If the button is suddenly pressed again,
182 183
       // ask the user to resolve the issue
183 184
       lcd_setstatusPGM(PSTR("Release button"), 99); // will never appear...
184
-      while (is_lcd_clicked()) idle();             // unless this loop happens
185
+      wait_for_release();
185 186
       lcd_reset_status();
186
-
187 187
       return true;
188 188
     }
189
-  #endif
190 189
 
191
-  #if ENABLED(NEWPANEL)
192 190
     bool exit_from_g26() {
193 191
       lcd_setstatusPGM(PSTR("Leaving G26"), -1);
194
-      while (is_lcd_clicked()) idle();
192
+      wait_for_release();
195 193
       return G26_ERR;
196 194
     }
195
+
197 196
   #endif
198 197
 
199 198
   void G26_line_to_destination(const float &feed_rate) {
200 199
     const float save_feedrate = feedrate_mm_s;
201 200
     feedrate_mm_s = feed_rate;      // use specified feed rate
202
-    prepare_move_to_destination();  // will ultimately call ubl.line_to_destination_cartesian for UBL or ubl.prepare_linear_move_to for UBL_DELTA
201
+    prepare_move_to_destination();  // will ultimately call ubl.line_to_destination_cartesian or ubl.prepare_linear_move_to for UBL_DELTA
203 202
     feedrate_mm_s = save_feedrate;  // restore global feed rate
204 203
   }
205 204
 
206
-  void move_to(const float &x, const float &y, const float &z, const float &e_delta) {
205
+  void move_to(const float &rx, const float &ry, const float &z, const float &e_delta) {
207 206
     float feed_value;
208 207
     static float last_z = -999.99;
209 208
 
210
-    bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
209
+    bool has_xy_component = (rx != current_position[X_AXIS] || ry != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
211 210
 
212 211
     if (z != last_z) {
213 212
       last_z = z;
@@ -230,8 +229,8 @@
230 229
 
231 230
     if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
232 231
 
233
-    destination[X_AXIS] = x;
234
-    destination[Y_AXIS] = y;
232
+    destination[X_AXIS] = rx;
233
+    destination[Y_AXIS] = ry;
235 234
     destination[E_AXIS] += e_delta;
236 235
 
237 236
     G26_line_to_destination(feed_value);
@@ -291,15 +290,13 @@
291 290
           idle();
292 291
         }
293 292
 
294
-        while (is_lcd_clicked()) idle();           // Debounce Encoder Wheel
293
+        wait_for_release();
295 294
 
296
-        #if ENABLED(ULTRA_LCD)
297
-          strcpy_P(lcd_status_message, PSTR("Done Priming")); // We can't do lcd_setstatusPGM() without having it continue;
298
-                                                              // So... We cheat to get a message up.
299
-          lcd_setstatusPGM(PSTR("Done Priming"), 99);
300
-          lcd_quick_feedback();
301
-          lcd_external_control = false;
302
-        #endif
295
+        strcpy_P(lcd_status_message, PSTR("Done Priming")); // We can't do lcd_setstatusPGM() without having it continue;
296
+                                                            // So... We cheat to get a message up.
297
+        lcd_setstatusPGM(PSTR("Done Priming"), 99);
298
+        lcd_quick_feedback();
299
+        lcd_external_control = false;
303 300
       }
304 301
       else
305 302
     #endif
@@ -491,17 +488,11 @@
491 488
     return false;
492 489
   }
493 490
 
494
-  float valid_trig_angle(float d) {
495
-    while (d > 360.0) d -= 360.0;
496
-    while (d < 0.0) d += 360.0;
497
-    return d;
498
-  }
499
-
500 491
   /**
501 492
    * Turn on the bed and nozzle heat and
502 493
    * wait for them to get up to temperature.
503 494
    */
504
-  bool turn_on_heaters() {
495
+  inline bool turn_on_heaters() {
505 496
     millis_t next = millis() + 5000UL;
506 497
     #if HAS_TEMP_BED
507 498
       #if ENABLED(ULTRA_LCD)
@@ -519,7 +510,7 @@
519 510
 
520 511
             if (ELAPSED(millis(), next)) {
521 512
               next = millis() + 5000UL;
522
-              print_heaterstates();
513
+              thermalManager.print_heaterstates();
523 514
               SERIAL_EOL();
524 515
             }
525 516
             idle();
@@ -541,7 +532,7 @@
541 532
 
542 533
       if (ELAPSED(millis(), next)) {
543 534
         next = millis() + 5000UL;
544
-        print_heaterstates();
535
+        thermalManager.print_heaterstates();
545 536
         SERIAL_EOL();
546 537
       }
547 538
       idle();
@@ -555,10 +546,16 @@
555 546
     return G26_OK;
556 547
   }
557 548
 
549
+  float valid_trig_angle(float d) {
550
+    while (d > 360.0) d -= 360.0;
551
+    while (d < 0.0) d += 360.0;
552
+    return d;
553
+  }
554
+
558 555
   /**
559 556
    * G26: Mesh Validation Pattern generation.
560 557
    *
561
-   * Used to interactively edit UBL's Mesh by placing the
558
+   * Used to interactively edit the mesh by placing the
562 559
    * nozzle in a problem area and doing a G29 P4 R command.
563 560
    */
564 561
   void gcode_G26() {
@@ -704,12 +701,12 @@
704 701
       set_current_from_destination();
705 702
     }
706 703
 
707
-    if (turn_on_heaters()) goto LEAVE;
704
+    if (turn_on_heaters() != G26_OK) goto LEAVE;
708 705
 
709 706
     current_position[E_AXIS] = 0.0;
710 707
     sync_plan_position_e();
711 708
 
712
-    if (g26_prime_flag && prime_nozzle()) goto LEAVE;
709
+    if (g26_prime_flag && prime_nozzle() != G26_OK) goto LEAVE;
713 710
 
714 711
     /**
715 712
      *  Bed is preheated

+ 0
- 4
Marlin/Marlin.h View File

@@ -457,10 +457,6 @@ void report_current_position();
457 457
 // Handling multiple extruders pins
458 458
 extern uint8_t active_extruder;
459 459
 
460
-#if HAS_TEMP_HOTEND || HAS_TEMP_BED
461
-  void print_heaterstates();
462
-#endif
463
-
464 460
 #if ENABLED(MIXING_EXTRUDER)
465 461
   extern float mixing_factor[MIXING_STEPPERS];
466 462
 #endif

+ 8
- 96
Marlin/Marlin_main.cpp View File

@@ -519,7 +519,7 @@ static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL
519 519
   #define BUZZ(d,f) NOOP
520 520
 #endif
521 521
 
522
-static uint8_t target_extruder;
522
+uint8_t target_extruder;
523 523
 
524 524
 #if HAS_BED_PROBE
525 525
   float zprobe_zoffset; // Initialized by settings.load()
@@ -7570,80 +7570,6 @@ inline void gcode_M104() {
7570 7570
   #endif
7571 7571
 }
7572 7572
 
7573
-#if HAS_TEMP_HOTEND || HAS_TEMP_BED
7574
-
7575
-  void print_heater_state(const float &c, const float &t,
7576
-    #if ENABLED(SHOW_TEMP_ADC_VALUES)
7577
-      const float r,
7578
-    #endif
7579
-    const int8_t e=-2
7580
-  ) {
7581
-    #if !(HAS_TEMP_BED && HAS_TEMP_HOTEND) && HOTENDS <= 1
7582
-      UNUSED(e);
7583
-    #endif
7584
-
7585
-    SERIAL_PROTOCOLCHAR(' ');
7586
-    SERIAL_PROTOCOLCHAR(
7587
-      #if HAS_TEMP_BED && HAS_TEMP_HOTEND
7588
-        e == -1 ? 'B' : 'T'
7589
-      #elif HAS_TEMP_HOTEND
7590
-        'T'
7591
-      #else
7592
-        'B'
7593
-      #endif
7594
-    );
7595
-    #if HOTENDS > 1
7596
-      if (e >= 0) SERIAL_PROTOCOLCHAR('0' + e);
7597
-    #endif
7598
-    SERIAL_PROTOCOLCHAR(':');
7599
-    SERIAL_PROTOCOL(c);
7600
-    SERIAL_PROTOCOLPAIR(" /" , t);
7601
-    #if ENABLED(SHOW_TEMP_ADC_VALUES)
7602
-      SERIAL_PROTOCOLPAIR(" (", r / OVERSAMPLENR);
7603
-      SERIAL_PROTOCOLCHAR(')');
7604
-    #endif
7605
-  }
7606
-
7607
-  void print_heaterstates() {
7608
-    #if HAS_TEMP_HOTEND
7609
-      print_heater_state(thermalManager.degHotend(target_extruder), thermalManager.degTargetHotend(target_extruder)
7610
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
7611
-          , thermalManager.rawHotendTemp(target_extruder)
7612
-        #endif
7613
-      );
7614
-    #endif
7615
-    #if HAS_TEMP_BED
7616
-      print_heater_state(thermalManager.degBed(), thermalManager.degTargetBed(),
7617
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
7618
-          thermalManager.rawBedTemp(),
7619
-        #endif
7620
-        -1 // BED
7621
-      );
7622
-    #endif
7623
-    #if HOTENDS > 1
7624
-      HOTEND_LOOP() print_heater_state(thermalManager.degHotend(e), thermalManager.degTargetHotend(e),
7625
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
7626
-          thermalManager.rawHotendTemp(e),
7627
-        #endif
7628
-        e
7629
-      );
7630
-    #endif
7631
-    SERIAL_PROTOCOLPGM(" @:");
7632
-    SERIAL_PROTOCOL(thermalManager.getHeaterPower(target_extruder));
7633
-    #if HAS_TEMP_BED
7634
-      SERIAL_PROTOCOLPGM(" B@:");
7635
-      SERIAL_PROTOCOL(thermalManager.getHeaterPower(-1));
7636
-    #endif
7637
-    #if HOTENDS > 1
7638
-      HOTEND_LOOP() {
7639
-        SERIAL_PROTOCOLPAIR(" @", e);
7640
-        SERIAL_PROTOCOLCHAR(':');
7641
-        SERIAL_PROTOCOL(thermalManager.getHeaterPower(e));
7642
-      }
7643
-    #endif
7644
-  }
7645
-#endif
7646
-
7647 7573
 /**
7648 7574
  * M105: Read hot end and bed temperature
7649 7575
  */
@@ -7652,7 +7578,7 @@ inline void gcode_M105() {
7652 7578
 
7653 7579
   #if HAS_TEMP_HOTEND || HAS_TEMP_BED
7654 7580
     SERIAL_PROTOCOLPGM(MSG_OK);
7655
-    print_heaterstates();
7581
+    thermalManager.print_heaterstates();
7656 7582
   #else // !HAS_TEMP_HOTEND && !HAS_TEMP_BED
7657 7583
     SERIAL_ERROR_START();
7658 7584
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
@@ -7663,26 +7589,12 @@ inline void gcode_M105() {
7663 7589
 
7664 7590
 #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
7665 7591
 
7666
-  static uint8_t auto_report_temp_interval;
7667
-  static millis_t next_temp_report_ms;
7668
-
7669 7592
   /**
7670 7593
    * M155: Set temperature auto-report interval. M155 S<seconds>
7671 7594
    */
7672 7595
   inline void gcode_M155() {
7673
-    if (parser.seenval('S')) {
7674
-      auto_report_temp_interval = parser.value_byte();
7675
-      NOMORE(auto_report_temp_interval, 60);
7676
-      next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
7677
-    }
7678
-  }
7679
-
7680
-  inline void auto_report_temperatures() {
7681
-    if (auto_report_temp_interval && ELAPSED(millis(), next_temp_report_ms)) {
7682
-      next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
7683
-      print_heaterstates();
7684
-      SERIAL_EOL();
7685
-    }
7596
+    if (parser.seenval('S'))
7597
+      thermalManager.set_auto_report_interval(parser.value_byte());
7686 7598
   }
7687 7599
 
7688 7600
 #endif // AUTO_REPORT_TEMPERATURES
@@ -7851,7 +7763,7 @@ inline void gcode_M109() {
7851 7763
     now = millis();
7852 7764
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
7853 7765
       next_temp_ms = now + 1000UL;
7854
-      print_heaterstates();
7766
+      thermalManager.print_heaterstates();
7855 7767
       #if TEMP_RESIDENCY_TIME > 0
7856 7768
         SERIAL_PROTOCOLPGM(" W:");
7857 7769
         if (residency_start_ms)
@@ -7988,7 +7900,7 @@ inline void gcode_M109() {
7988 7900
       now = millis();
7989 7901
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
7990 7902
         next_temp_ms = now + 1000UL;
7991
-        print_heaterstates();
7903
+        thermalManager.print_heaterstates();
7992 7904
         #if TEMP_BED_RESIDENCY_TIME > 0
7993 7905
           SERIAL_PROTOCOLPGM(" W:");
7994 7906
           if (residency_start_ms)
@@ -9917,7 +9829,7 @@ inline void gcode_M502() {
9917 9829
    * M503: print settings currently in memory
9918 9830
    */
9919 9831
   inline void gcode_M503() {
9920
-    (void)settings.report(parser.boolval('S'));
9832
+    (void)settings.report(parser.seen('S') && !parser.value_bool());
9921 9833
   }
9922 9834
 #endif
9923 9835
 
@@ -13672,7 +13584,7 @@ void idle(
13672 13584
   host_keepalive();
13673 13585
 
13674 13586
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
13675
-    auto_report_temperatures();
13587
+    thermalManager.auto_report_temperatures();
13676 13588
   #endif
13677 13589
 
13678 13590
   manage_inactivity(

+ 4
- 0
Marlin/SanityCheck.h View File

@@ -298,11 +298,15 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE && Y_MAX_LENGTH >= Y_BED_SIZE,
298 298
 #if ENABLED(LCD_PROGRESS_BAR)
299 299
   #if DISABLED(SDSUPPORT)
300 300
     #error "LCD_PROGRESS_BAR requires SDSUPPORT."
301
+  #elif DISABLED(ULTRA_LCD)
302
+    #error "LCD_PROGRESS_BAR requires a character LCD."
301 303
   #elif ENABLED(DOGLCD)
302 304
     #error "LCD_PROGRESS_BAR does not apply to graphical displays."
303 305
   #elif ENABLED(FILAMENT_LCD_DISPLAY)
304 306
     #error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both."
305 307
   #endif
308
+#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && DISABLED(DOGLCD)
309
+  #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR or Graphical LCD."
306 310
 #endif
307 311
 
308 312
 /**

+ 1
- 1
Marlin/configuration_store.cpp View File

@@ -1547,7 +1547,7 @@ void MarlinSettings::reset() {
1547 1547
    *
1548 1548
    * Unless specifically disabled, M503 is available even without EEPROM
1549 1549
    */
1550
-  void MarlinSettings::report(bool forReplay) {
1550
+  void MarlinSettings::report(const bool forReplay) {
1551 1551
 
1552 1552
     /**
1553 1553
      * Announce current units, in case inches are being displayed

+ 2
- 2
Marlin/configuration_store.h View File

@@ -52,10 +52,10 @@ class MarlinSettings {
52 52
     #endif
53 53
 
54 54
     #if DISABLED(DISABLE_M503)
55
-      static void report(bool forReplay=false);
55
+      static void report(const bool forReplay=false);
56 56
     #else
57 57
       FORCE_INLINE
58
-      static void report(bool forReplay=false) { UNUSED(forReplay); }
58
+      static void report(const bool forReplay=false) { UNUSED(forReplay); }
59 59
     #endif
60 60
 
61 61
   private:

+ 2
- 2
Marlin/language_en.h View File

@@ -813,8 +813,8 @@
813 813
 #ifndef MSG_DELTA_HEIGHT_CALIBRATE
814 814
   #define MSG_DELTA_HEIGHT_CALIBRATE          _UxGT("Set Delta Height")
815 815
 #endif
816
-#ifndef MSG_DELTA_DIAG_ROG
817
-  #define MSG_DELTA_DIAG_ROG                  _UxGT("Diag Rod")
816
+#ifndef MSG_DELTA_DIAG_ROD
817
+  #define MSG_DELTA_DIAG_ROD                  _UxGT("Diag Rod")
818 818
 #endif
819 819
 #ifndef MSG_DELTA_HEIGHT
820 820
   #define MSG_DELTA_HEIGHT                    _UxGT("Height")

+ 1
- 1
Marlin/pins_MELZI_CREALITY.h View File

@@ -60,7 +60,7 @@
60 60
 #define ST7920_DELAY_3 DELAY_2_NOP
61 61
 
62 62
 #if ENABLED(MINIPANEL)
63
-  #undef DOGLCD_CS    
63
+  #undef DOGLCD_CS
64 64
   #define DOGLCD_CS        LCD_PINS_RS
65 65
 #endif
66 66
 

+ 9
- 4
Marlin/planner.cpp View File

@@ -124,15 +124,20 @@ float Planner::min_feedrate_mm_s,
124 124
           Planner::inverse_z_fade_height,
125 125
           Planner::last_fade_z;
126 126
   #endif
127
+#else
128
+  constexpr bool Planner::leveling_active;
127 129
 #endif
128 130
 
129 131
 #if ENABLED(SKEW_CORRECTION)
130 132
   #if ENABLED(SKEW_CORRECTION_GCODE)
131
-    // Initialized by settings.load()
132 133
     float Planner::xy_skew_factor;
133
-    #if ENABLED(SKEW_CORRECTION_FOR_Z)
134
-      float Planner::xz_skew_factor, Planner::yz_skew_factor;
135
-    #endif
134
+  #else
135
+    constexpr float Planner::xy_skew_factor;
136
+  #endif
137
+  #if ENABLED(SKEW_CORRECTION_FOR_Z) && ENABLED(SKEW_CORRECTION_GCODE)
138
+    float Planner::xz_skew_factor, Planner::yz_skew_factor;
139
+  #else
140
+    constexpr float Planner::xz_skew_factor, Planner::yz_skew_factor;
136 141
   #endif
137 142
 #endif
138 143
 

+ 26
- 21
Marlin/stepper.cpp View File

@@ -83,7 +83,7 @@ block_t* Stepper::current_block = NULL;  // A pointer to the block currently bei
83 83
 // private:
84 84
 
85 85
 uint8_t Stepper::last_direction_bits = 0;        // The next stepping-bits to be output
86
-uint16_t Stepper::cleaning_buffer_counter = 0;
86
+int16_t Stepper::cleaning_buffer_counter = 0;
87 87
 
88 88
 #if ENABLED(X_DUAL_ENDSTOPS)
89 89
   bool Stepper::locked_x_motor = false, Stepper::locked_x2_motor = false;
@@ -381,8 +381,8 @@ void Stepper::isr() {
381 381
 
382 382
   uint16_t ocr_val;
383 383
 
384
-  #define ENDSTOP_NOMINAL_OCR_VAL 3000    // check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
385
-  #define OCR_VAL_TOLERANCE 1000          // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
384
+  #define ENDSTOP_NOMINAL_OCR_VAL 3000 // Check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
385
+  #define OCR_VAL_TOLERANCE       1000 // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
386 386
 
387 387
   #if DISABLED(LIN_ADVANCE)
388 388
     // Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars)
@@ -393,9 +393,13 @@ void Stepper::isr() {
393 393
 
394 394
   #define _SPLIT(L) (ocr_val = (uint16_t)L)
395 395
   #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
396
+
396 397
     #define SPLIT(L) _SPLIT(L)
397
-  #else                 // sample endstops in between step pulses
398
+
399
+  #else // !ENDSTOP_INTERRUPTS_FEATURE : Sample endstops between stepping ISRs
400
+
398 401
     static uint32_t step_remaining = 0;
402
+
399 403
     #define SPLIT(L) do { \
400 404
       _SPLIT(L); \
401 405
       if (ENDSTOPS_ENABLED && L > ENDSTOP_NOMINAL_OCR_VAL) { \
@@ -407,33 +411,34 @@ void Stepper::isr() {
407 411
 
408 412
     if (step_remaining && ENDSTOPS_ENABLED) {   // Just check endstops - not yet time for a step
409 413
       endstops.update();
410
-      if (step_remaining > ENDSTOP_NOMINAL_OCR_VAL) {
411
-        step_remaining -= ENDSTOP_NOMINAL_OCR_VAL;
412
-        ocr_val = ENDSTOP_NOMINAL_OCR_VAL;
413
-      }
414
-      else {
415
-        ocr_val = step_remaining;
416
-        step_remaining = 0;  //  last one before the ISR that does the step
417
-      }
418 414
 
415
+      // Next ISR either for endstops or stepping
416
+      ocr_val = step_remaining <= ENDSTOP_NOMINAL_OCR_VAL ? step_remaining : ENDSTOP_NOMINAL_OCR_VAL;
417
+      step_remaining -= ocr_val;
419 418
       _NEXT_ISR(ocr_val);
420
-
421 419
       NOLESS(OCR1A, TCNT1 + 16);
422
-
423 420
       _ENABLE_ISRs(); // re-enable ISRs
424 421
       return;
425 422
     }
426
-  #endif
427 423
 
424
+  #endif // !ENDSTOP_INTERRUPTS_FEATURE
425
+
426
+  //
427
+  // When cleaning, discard the current block and run fast
428
+  //
428 429
   if (cleaning_buffer_counter) {
429
-    --cleaning_buffer_counter;
430 430
     current_block = NULL;
431 431
     planner.discard_current_block();
432
-    #ifdef SD_FINISHED_RELEASECOMMAND
433
-      if (!cleaning_buffer_counter && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
434
-    #endif
435
-    _NEXT_ISR(200); // Run at max speed - 10 KHz
436
-    _ENABLE_ISRs(); // re-enable ISRs
432
+    if (cleaning_buffer_counter < 0)
433
+      ++cleaning_buffer_counter;            // Count up for endstop hit
434
+    else {
435
+      --cleaning_buffer_counter;            // Count down for abort print
436
+      #ifdef SD_FINISHED_RELEASECOMMAND
437
+        if (!cleaning_buffer_counter && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
438
+      #endif
439
+    }
440
+    _NEXT_ISR(200);                             // Run at max speed - 10 KHz
441
+    _ENABLE_ISRs();
437 442
     return;
438 443
   }
439 444
 

+ 1
- 1
Marlin/stepper.h View File

@@ -104,7 +104,7 @@ class Stepper {
104 104
   private:
105 105
 
106 106
     static uint8_t last_direction_bits;        // The next stepping-bits to be output
107
-    static uint16_t cleaning_buffer_counter;
107
+    static int16_t cleaning_buffer_counter;
108 108
 
109 109
     #if ENABLED(X_DUAL_ENDSTOPS)
110 110
       static bool locked_x_motor, locked_x2_motor;

+ 93
- 1
Marlin/temperature.cpp View File

@@ -1273,7 +1273,7 @@ void Temperature::init() {
1273 1273
    * their target temperature by a configurable margin.
1274 1274
    * This is called when the temperature is set. (M104, M109)
1275 1275
    */
1276
-  void Temperature::start_watching_heater(uint8_t e) {
1276
+  void Temperature::start_watching_heater(const uint8_t e) {
1277 1277
     #if HOTENDS == 1
1278 1278
       UNUSED(e);
1279 1279
     #endif
@@ -2186,3 +2186,95 @@ void Temperature::isr() {
2186 2186
   in_temp_isr = false;
2187 2187
   SBI(TIMSK0, OCIE0B); //re-enable Temperature ISR
2188 2188
 }
2189
+
2190
+#if HAS_TEMP_HOTEND || HAS_TEMP_BED
2191
+
2192
+  void print_heater_state(const float &c, const float &t,
2193
+    #if ENABLED(SHOW_TEMP_ADC_VALUES)
2194
+      const float r,
2195
+    #endif
2196
+    const int8_t e=-2
2197
+  ) {
2198
+    #if !(HAS_TEMP_BED && HAS_TEMP_HOTEND) && HOTENDS <= 1
2199
+      UNUSED(e);
2200
+    #endif
2201
+
2202
+    SERIAL_PROTOCOLCHAR(' ');
2203
+    SERIAL_PROTOCOLCHAR(
2204
+      #if HAS_TEMP_BED && HAS_TEMP_HOTEND
2205
+        e == -1 ? 'B' : 'T'
2206
+      #elif HAS_TEMP_HOTEND
2207
+        'T'
2208
+      #else
2209
+        'B'
2210
+      #endif
2211
+    );
2212
+    #if HOTENDS > 1
2213
+      if (e >= 0) SERIAL_PROTOCOLCHAR('0' + e);
2214
+    #endif
2215
+    SERIAL_PROTOCOLCHAR(':');
2216
+    SERIAL_PROTOCOL(c);
2217
+    SERIAL_PROTOCOLPAIR(" /" , t);
2218
+    #if ENABLED(SHOW_TEMP_ADC_VALUES)
2219
+      SERIAL_PROTOCOLPAIR(" (", r / OVERSAMPLENR);
2220
+      SERIAL_PROTOCOLCHAR(')');
2221
+    #endif
2222
+  }
2223
+
2224
+  extern uint8_t target_extruder;
2225
+
2226
+  void Temperature::print_heaterstates() {
2227
+    #if HAS_TEMP_HOTEND
2228
+      print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder)
2229
+        #if ENABLED(SHOW_TEMP_ADC_VALUES)
2230
+          , rawHotendTemp(target_extruder)
2231
+        #endif
2232
+      );
2233
+    #endif
2234
+    #if HAS_TEMP_BED
2235
+      print_heater_state(degBed(), degTargetBed()
2236
+        #if ENABLED(SHOW_TEMP_ADC_VALUES)
2237
+          , rawBedTemp()
2238
+        #endif
2239
+        , -1 // BED
2240
+      );
2241
+    #endif
2242
+    #if HOTENDS > 1
2243
+      HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e)
2244
+        #if ENABLED(SHOW_TEMP_ADC_VALUES)
2245
+          , rawHotendTemp(e)
2246
+        #endif
2247
+        , e
2248
+      );
2249
+    #endif
2250
+    SERIAL_PROTOCOLPGM(" @:");
2251
+    SERIAL_PROTOCOL(getHeaterPower(target_extruder));
2252
+    #if HAS_TEMP_BED
2253
+      SERIAL_PROTOCOLPGM(" B@:");
2254
+      SERIAL_PROTOCOL(getHeaterPower(-1));
2255
+    #endif
2256
+    #if HOTENDS > 1
2257
+      HOTEND_LOOP() {
2258
+        SERIAL_PROTOCOLPAIR(" @", e);
2259
+        SERIAL_PROTOCOLCHAR(':');
2260
+        SERIAL_PROTOCOL(getHeaterPower(e));
2261
+      }
2262
+    #endif
2263
+  }
2264
+
2265
+  #if ENABLED(AUTO_REPORT_TEMPERATURES)
2266
+
2267
+    uint8_t Temperature::auto_report_temp_interval;
2268
+    millis_t Temperature::next_temp_report_ms;
2269
+
2270
+    void Temperature::auto_report_temperatures() {
2271
+      if (auto_report_temp_interval && ELAPSED(millis(), next_temp_report_ms)) {
2272
+        next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
2273
+        print_heaterstates();
2274
+        SERIAL_EOL();
2275
+      }
2276
+    }
2277
+
2278
+  #endif // AUTO_REPORT_TEMPERATURES
2279
+
2280
+#endif // HAS_TEMP_HOTEND || HAS_TEMP_BED

+ 17
- 3
Marlin/temperature.h View File

@@ -370,14 +370,14 @@ class Temperature {
370 370
     static int16_t degTargetBed() { return target_temperature_bed; }
371 371
 
372 372
     #if WATCH_HOTENDS
373
-      static void start_watching_heater(uint8_t e = 0);
373
+      static void start_watching_heater(const uint8_t e = 0);
374 374
     #endif
375 375
 
376 376
     #if WATCH_THE_BED
377 377
       static void start_watching_bed();
378 378
     #endif
379 379
 
380
-    static void setTargetHotend(const int16_t celsius, uint8_t e) {
380
+    static void setTargetHotend(const int16_t celsius, const uint8_t e) {
381 381
       #if HOTENDS == 1
382 382
         UNUSED(e);
383 383
       #endif
@@ -455,7 +455,7 @@ class Temperature {
455 455
 
456 456
     #if ENABLED(BABYSTEPPING)
457 457
 
458
-      static void babystep_axis(const AxisEnum axis, const int distance) {
458
+      static void babystep_axis(const AxisEnum axis, const int16_t distance) {
459 459
         if (axis_known_position[axis]) {
460 460
           #if IS_CORE
461 461
             #if ENABLED(BABYSTEP_XY)
@@ -539,6 +539,20 @@ class Temperature {
539 539
       #endif
540 540
     #endif
541 541
 
542
+    #if HAS_TEMP_HOTEND || HAS_TEMP_BED
543
+      static void print_heaterstates();
544
+      #if ENABLED(AUTO_REPORT_TEMPERATURES)
545
+        static uint8_t auto_report_temp_interval;
546
+        static millis_t next_temp_report_ms;
547
+        static void auto_report_temperatures(void);
548
+        FORCE_INLINE void set_auto_report_interval(uint8_t v) {
549
+          NOMORE(v, 60);
550
+          auto_report_temp_interval = v;
551
+          next_temp_report_ms = millis() + 1000UL * v;
552
+        }
553
+      #endif
554
+    #endif
555
+
542 556
   private:
543 557
 
544 558
     static void set_current_temp_raw();

+ 8
- 4
Marlin/ubl.h View File

@@ -81,19 +81,23 @@
81 81
         static int  g29_grid_size;
82 82
       #endif
83 83
 
84
-      static float measure_point_with_encoder();
85
-      static float measure_business_card_thickness(float);
84
+      #if ENABLED(NEWPANEL)
85
+        static void move_z_with_encoder(const float &multiplier);
86
+        static float measure_point_with_encoder();
87
+        static float measure_business_card_thickness(const float&);
88
+        static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
89
+        static void fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map);
90
+      #endif
91
+
86 92
       static bool g29_parameter_parsing();
87 93
       static void find_mean_mesh_height();
88 94
       static void shift_mesh_height();
89 95
       static void probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
90
-      static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
91 96
       static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
92 97
       static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
93 98
       static void g29_what_command();
94 99
       static void g29_eeprom_dump();
95 100
       static void g29_compare_current_mesh_to_stored_mesh();
96
-      static void fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map);
97 101
       static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
98 102
       static void smart_fill_mesh();
99 103
 

+ 128
- 121
Marlin/ubl_G29.cpp View File

@@ -24,6 +24,8 @@
24 24
 
25 25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
26 26
 
27
+  //#define UBL_DEVEL_DEBUGGING
28
+
27 29
   #include "ubl.h"
28 30
   #include "Marlin.h"
29 31
   #include "hex_print_routines.h"
@@ -43,7 +45,7 @@
43 45
 
44 46
   #if ENABLED(NEWPANEL)
45 47
     void lcd_return_to_status();
46
-    void lcd_mesh_edit_setup(float initial);
48
+    void lcd_mesh_edit_setup(const float initial);
47 49
     float lcd_mesh_edit();
48 50
     void lcd_z_offset_edit_setup(float);
49 51
     extern void _lcd_ubl_output_map_lcd();
@@ -55,8 +57,9 @@
55 57
   extern float probe_pt(const float &rx, const float &ry, const bool, const uint8_t, const bool=true);
56 58
   extern bool set_probe_deployed(bool);
57 59
   extern void set_bed_leveling_enabled(bool);
60
+
58 61
   typedef void (*screenFunc_t)();
59
-  extern void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0);
62
+  extern void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder=0);
60 63
 
61 64
   #define SIZE_OF_LITTLE_RAISE 1
62 65
   #define BIG_RAISE_NOT_NEEDED 0
@@ -642,8 +645,8 @@
642 645
               SERIAL_ECHOPAIR(" J ", y);
643 646
               SERIAL_ECHOPGM(" Z ");
644 647
               SERIAL_ECHO_F(z_values[x][y], 6);
645
-              SERIAL_ECHOPAIR(" ; X ", mesh_index_to_xpos(x));
646
-              SERIAL_ECHOPAIR(", Y ", mesh_index_to_ypos(y));
648
+              SERIAL_ECHOPAIR(" ; X ", LOGICAL_X_POSITION(mesh_index_to_xpos(x)));
649
+              SERIAL_ECHOPAIR(", Y ", LOGICAL_Y_POSITION(mesh_index_to_ypos(y)));
647 650
               SERIAL_EOL();
648 651
             }
649 652
         return;
@@ -728,6 +731,30 @@
728 731
           z_values[x][y] += g29_constant;
729 732
   }
730 733
 
734
+  #if ENABLED(NEWPANEL)
735
+
736
+    typedef void (*clickFunc_t)();
737
+
738
+    bool click_and_hold(const clickFunc_t func=NULL) {
739
+      if (is_lcd_clicked()) {
740
+        lcd_quick_feedback();
741
+        const millis_t nxt = millis() + 1500UL;
742
+        while (is_lcd_clicked()) {                // Loop while the encoder is pressed. Uses hardware flag!
743
+          idle();                                 // idle, of course
744
+          if (ELAPSED(millis(), nxt)) {           // After 1.5 seconds
745
+            lcd_quick_feedback();
746
+            if (func) (*func)();
747
+            wait_for_release();
748
+            safe_delay(50);                       // Debounce the Encoder wheel
749
+            return true;
750
+          }
751
+        }
752
+      }
753
+      return false;
754
+    }
755
+
756
+  #endif // NEWPANEL
757
+
731 758
   #if HAS_BED_PROBE
732 759
     /**
733 760
      * Probe all invalidated locations of the mesh that can be reached by the probe.
@@ -753,10 +780,9 @@
753 780
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
754 781
             lcd_quick_feedback();
755 782
             STOW_PROBE();
756
-            while (is_lcd_clicked()) idle();
783
+            wait_for_release();
757 784
             lcd_external_control = false;
758 785
             restore_ubl_active_state_and_leave();
759
-            safe_delay(50);  // Debounce the Encoder wheel
760 786
             return;
761 787
           }
762 788
         #endif
@@ -774,7 +800,6 @@
774 800
           z_values[location.x_index][location.y_index] = measured_z;
775 801
         }
776 802
 
777
-
778 803
       } while (location.x_index >= 0 && --max_iterations);
779 804
 
780 805
       STOW_PROBE();
@@ -889,30 +914,32 @@
889 914
         }
890 915
       }
891 916
     }
917
+
892 918
   #endif // HAS_BED_PROBE
893 919
 
894 920
   #if ENABLED(NEWPANEL)
895 921
 
896
-    float unified_bed_leveling::measure_point_with_encoder() {
897
-
898
-      while (is_lcd_clicked()) delay(50);  // wait for user to release encoder wheel
899
-      delay(50);  // debounce
900
-
901
-      KEEPALIVE_STATE(PAUSED_FOR_USER);
902
-      while (!is_lcd_clicked()) {     // we need the loop to move the nozzle based on the encoder wheel here!
922
+    void unified_bed_leveling::move_z_with_encoder(const float &multiplier) {
923
+      wait_for_release();
924
+      while (!is_lcd_clicked()) {
903 925
         idle();
904 926
         if (encoder_diff) {
905
-          do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(encoder_diff));
927
+          do_blocking_move_to_z(current_position[Z_AXIS] + float(encoder_diff) * multiplier);
906 928
           encoder_diff = 0;
907 929
         }
908 930
       }
931
+    }
932
+
933
+    float unified_bed_leveling::measure_point_with_encoder() {
934
+      KEEPALIVE_STATE(PAUSED_FOR_USER);
935
+      move_z_with_encoder(0.01);
909 936
       KEEPALIVE_STATE(IN_HANDLER);
910 937
       return current_position[Z_AXIS];
911 938
     }
912 939
 
913 940
     static void echo_and_take_a_measurement() { SERIAL_PROTOCOLLNPGM(" and take a measurement."); }
914 941
 
915
-    float unified_bed_leveling::measure_business_card_thickness(float in_height) {
942
+    float unified_bed_leveling::measure_business_card_thickness(const float &in_height) {
916 943
       lcd_external_control = true;
917 944
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
918 945
 
@@ -945,8 +972,6 @@
945 972
         SERIAL_PROTOCOLLNPGM("mm thick.");
946 973
       }
947 974
 
948
-      in_height = current_position[Z_AXIS]; // do manual probing at lower height
949
-
950 975
       lcd_external_control = false;
951 976
 
952 977
       restore_ubl_active_state_and_leave();
@@ -954,6 +979,14 @@
954 979
       return thickness;
955 980
     }
956 981
 
982
+    void abort_manual_probe_remaining_mesh() {
983
+      SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
984
+      do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
985
+      lcd_external_control = false;
986
+      KEEPALIVE_STATE(IN_HANDLER);
987
+      ubl.restore_ubl_active_state_and_leave();
988
+    }
989
+
957 990
     void unified_bed_leveling::manually_probe_remaining_mesh(const float &rx, const float &ry, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
958 991
 
959 992
       lcd_external_control = true;
@@ -989,36 +1022,15 @@
989 1022
         const float z_step = 0.01;                                        // existing behavior: 0.01mm per click, occasionally step
990 1023
         //const float z_step = 1.0 / planner.axis_steps_per_mm[Z_AXIS];   // approx one step each click
991 1024
 
992
-        while (is_lcd_clicked()) delay(50);             // wait for user to release encoder wheel
993
-        delay(50);                                       // debounce
994
-        while (!is_lcd_clicked()) {                     // we need the loop to move the nozzle based on the encoder wheel here!
995
-          idle();
996
-          if (encoder_diff) {
997
-            do_blocking_move_to_z(current_position[Z_AXIS] + float(encoder_diff) * z_step);
998
-            encoder_diff = 0;
999
-          }
1000
-        }
1025
+        move_z_with_encoder(z_step);
1001 1026
 
1002
-        // this sequence to detect an is_lcd_clicked() debounce it and leave if it is
1003
-        // a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp).   This
1004
-        // should be redone and compressed.
1005
-        const millis_t nxt = millis() + 1500L;
1006
-        while (is_lcd_clicked()) {     // debounce and watch for abort
1007
-          idle();
1008
-          if (ELAPSED(millis(), nxt)) {
1009
-            SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
1010
-            do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
1011
-
1012
-            #if ENABLED(NEWPANEL)
1013
-              lcd_quick_feedback();
1014
-              while (is_lcd_clicked()) idle();
1015
-              lcd_external_control = false;
1016
-            #endif
1017
-
1018
-            KEEPALIVE_STATE(IN_HANDLER);
1019
-            restore_ubl_active_state_and_leave();
1020
-            return;
1021
-          }
1027
+        if (click_and_hold()) {
1028
+          SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
1029
+          do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
1030
+          lcd_external_control = false;
1031
+          KEEPALIVE_STATE(IN_HANDLER);
1032
+          restore_ubl_active_state_and_leave();
1033
+          return;
1022 1034
         }
1023 1035
 
1024 1036
         z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - thick;
@@ -1152,36 +1164,39 @@
1152 1164
     return UBL_OK;
1153 1165
   }
1154 1166
 
1155
-  static int ubl_state_at_invocation = 0,
1156
-             ubl_state_recursion_chk = 0;
1167
+  static uint8_t ubl_state_at_invocation = 0;
1157 1168
 
1158
-  void unified_bed_leveling::save_ubl_active_state_and_disable() {
1159
-    ubl_state_recursion_chk++;
1160
-    if (ubl_state_recursion_chk != 1) {
1161
-      SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
1162
-
1163
-      #if ENABLED(NEWPANEL)
1164
-        LCD_MESSAGEPGM(MSG_UBL_SAVE_ERROR);
1165
-        lcd_quick_feedback();
1166
-      #endif
1169
+  #ifdef UBL_DEVEL_DEBUGGING
1170
+    static uint8_t ubl_state_recursion_chk = 0;
1171
+  #endif
1167 1172
 
1168
-      return;
1169
-    }
1173
+  void unified_bed_leveling::save_ubl_active_state_and_disable() {
1174
+    #ifdef UBL_DEVEL_DEBUGGING
1175
+      ubl_state_recursion_chk++;
1176
+      if (ubl_state_recursion_chk != 1) {
1177
+        SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
1178
+        #if ENABLED(NEWPANEL)
1179
+          LCD_MESSAGEPGM(MSG_UBL_SAVE_ERROR);
1180
+          lcd_quick_feedback();
1181
+        #endif
1182
+        return;
1183
+      }
1184
+    #endif
1170 1185
     ubl_state_at_invocation = planner.leveling_active;
1171 1186
     set_bed_leveling_enabled(false);
1172 1187
   }
1173 1188
 
1174 1189
   void unified_bed_leveling::restore_ubl_active_state_and_leave() {
1175
-    if (--ubl_state_recursion_chk) {
1176
-      SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
1177
-
1178
-      #if ENABLED(NEWPANEL)
1179
-        LCD_MESSAGEPGM(MSG_UBL_RESTORE_ERROR);
1180
-        lcd_quick_feedback();
1181
-      #endif
1182
-
1183
-      return;
1184
-    }
1190
+    #ifdef UBL_DEVEL_DEBUGGING
1191
+      if (--ubl_state_recursion_chk) {
1192
+        SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
1193
+        #if ENABLED(NEWPANEL)
1194
+          LCD_MESSAGEPGM(MSG_UBL_RESTORE_ERROR);
1195
+          lcd_quick_feedback();
1196
+        #endif
1197
+        return;
1198
+      }
1199
+    #endif
1185 1200
     set_bed_leveling_enabled(ubl_state_at_invocation);
1186 1201
   }
1187 1202
 
@@ -1253,28 +1268,30 @@
1253 1268
     SERIAL_EOL();
1254 1269
     safe_delay(50);
1255 1270
 
1256
-    SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1257
-    SERIAL_EOL();
1258
-    SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1259
-    SERIAL_EOL();
1260
-    safe_delay(50);
1271
+    #ifdef UBL_DEVEL_DEBUGGING
1272
+      SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1273
+      SERIAL_EOL();
1274
+      SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1275
+      SERIAL_EOL();
1276
+      safe_delay(50);
1261 1277
 
1262
-    SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes()));
1263
-    SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes()));
1264
-    safe_delay(50);
1278
+      SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes()));
1279
+      SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes()));
1280
+      safe_delay(50);
1265 1281
 
1266
-    SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1267
-    SERIAL_EOL();
1268
-    SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
1269
-    SERIAL_EOL();
1270
-    safe_delay(25);
1282
+      SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1283
+      SERIAL_EOL();
1284
+      SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
1285
+      SERIAL_EOL();
1286
+      safe_delay(25);
1271 1287
 
1272
-    SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes())));
1273
-    safe_delay(50);
1288
+      SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes())));
1289
+      safe_delay(50);
1274 1290
 
1275
-    SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
1276
-    SERIAL_PROTOCOLLNPGM(" meshes.\n");
1277
-    safe_delay(25);
1291
+      SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
1292
+      SERIAL_PROTOCOLLNPGM(" meshes.\n");
1293
+      safe_delay(25);
1294
+    #endif // UBL_DEVEL_DEBUGGING
1278 1295
 
1279 1296
     if (!sanity_check()) {
1280 1297
       echo_name();
@@ -1344,11 +1361,10 @@
1344 1361
         z_values[x][y] -= tmp_z_values[x][y];
1345 1362
   }
1346 1363
 
1347
-
1348 1364
   mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
1349 1365
 
1350
-    bool found_a_NAN  = false;
1351
-    bool found_a_real = false;
1366
+    bool found_a_NAN  = false, found_a_real = false;
1367
+
1352 1368
     mesh_index_pair out_mesh;
1353 1369
     out_mesh.x_index = out_mesh.y_index = -1;
1354 1370
     out_mesh.distance = -99999.99;
@@ -1356,12 +1372,12 @@
1356 1372
     for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1357 1373
       for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
1358 1374
 
1359
-        if ( isnan(z_values[i][j])) { // Check to see if this location holds an invalid mesh point
1375
+        if (isnan(z_values[i][j])) { // Check to see if this location holds an invalid mesh point
1360 1376
 
1361 1377
           const float mx = mesh_index_to_xpos(i),
1362 1378
                       my = mesh_index_to_ypos(j);
1363 1379
 
1364
-          if ( !position_is_reachable_by_probe(mx, my))  // make sure the probe can get to the mesh point
1380
+          if (!position_is_reachable_by_probe(mx, my))  // make sure the probe can get to the mesh point
1365 1381
             continue;
1366 1382
 
1367 1383
           found_a_NAN = true;
@@ -1443,10 +1459,9 @@
1443 1459
 
1444 1460
           float distance = HYPOT(px - mx, py - my);
1445 1461
 
1446
-            // factor in the distance from the current location for the normal case
1447
-            // so the nozzle isn't running all over the bed.
1448
-            distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1;
1449
-
1462
+          // factor in the distance from the current location for the normal case
1463
+          // so the nozzle isn't running all over the bed.
1464
+          distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1;
1450 1465
           if (distance < best_so_far) {
1451 1466
             best_so_far = distance;   // We found a closer location with
1452 1467
             out_mesh.x_index = i;     // the specified type of mesh value.
@@ -1462,6 +1477,12 @@
1462 1477
 
1463 1478
   #if ENABLED(NEWPANEL)
1464 1479
 
1480
+    void abort_fine_tune() {
1481
+      lcd_return_to_status();
1482
+      do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1483
+      LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
1484
+    }
1485
+
1465 1486
     void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {
1466 1487
       if (!parser.seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
1467 1488
         g29_repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
@@ -1495,8 +1516,8 @@
1495 1516
 
1496 1517
         if (location.x_index < 0) break; // stop when we can't find any more reachable points.
1497 1518
 
1498
-        bitmap_clear(not_done, location.x_index, location.y_index);  // Mark this location as 'adjusted' so we will find a
1499
-                                                                  // different location the next time through the loop
1519
+        bitmap_clear(not_done, location.x_index, location.y_index); // Mark this location as 'adjusted' so we will find a
1520
+                                                                    // different location the next time through the loop
1500 1521
 
1501 1522
         const float rawx = mesh_index_to_xpos(location.x_index),
1502 1523
                     rawy = mesh_index_to_ypos(location.y_index);
@@ -1504,15 +1525,8 @@
1504 1525
         if (!position_is_reachable(rawx, rawy)) // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
1505 1526
           break;
1506 1527
 
1507
-        float new_z = z_values[location.x_index][location.y_index];
1508
-
1509
-        if (isnan(new_z)) // if the mesh point is invalid, set it to 0.0 so it can be edited
1510
-          new_z = 0.0;
1511
-
1512 1528
         do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point
1513 1529
 
1514
-        new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
1515
-
1516 1530
         KEEPALIVE_STATE(PAUSED_FOR_USER);
1517 1531
         lcd_external_control = true;
1518 1532
 
@@ -1520,15 +1534,19 @@
1520 1534
 
1521 1535
         lcd_refresh();
1522 1536
 
1537
+        float new_z = z_values[location.x_index][location.y_index];
1538
+        if (isnan(new_z)) new_z = 0.0;          // Set invalid mesh points to 0.0 so they can be edited
1539
+        new_z = FLOOR(new_z * 1000.0) * 0.001;  // Chop off digits after the 1000ths place
1540
+
1523 1541
         lcd_mesh_edit_setup(new_z);
1524 1542
 
1525
-        do {
1543
+        while (!is_lcd_clicked()) {
1526 1544
           new_z = lcd_mesh_edit();
1527 1545
           #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1528 1546
             do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
1529 1547
           #endif
1530 1548
           idle();
1531
-        } while (!is_lcd_clicked());
1549
+        }
1532 1550
 
1533 1551
         if (!lcd_map_control) lcd_return_to_status();
1534 1552
 
@@ -1540,19 +1558,8 @@
1540 1558
         // this sequence to detect an is_lcd_clicked() debounce it and leave if it is
1541 1559
         // a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp).   This
1542 1560
         // should be redone and compressed.
1543
-        const millis_t nxt = millis() + 1500UL;
1544
-        while (is_lcd_clicked()) { // debounce and watch for abort
1545
-          idle();
1546
-          if (ELAPSED(millis(), nxt)) {
1547
-            lcd_return_to_status();
1548
-            do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1549
-            LCD_MESSAGEPGM(MSG_EDITING_STOPPED);
1550
-
1551
-            while (is_lcd_clicked()) idle();
1552
-
1553
-            goto FINE_TUNE_EXIT;
1554
-          }
1555
-        }
1561
+        if (click_and_hold(abort_fine_tune))
1562
+          goto FINE_TUNE_EXIT;
1556 1563
 
1557 1564
         safe_delay(20);                       // We don't want any switch noise.
1558 1565
 

+ 34
- 31
Marlin/ultralcd.cpp View File

@@ -57,16 +57,12 @@
57 57
 #endif
58 58
 
59 59
 #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
60
-  bool lcd_external_control;
60
+  bool lcd_external_control; // = false
61 61
 #endif
62 62
 
63 63
 // Initialized by settings.load()
64 64
 int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
65 65
 
66
-#if ENABLED(LCD_SET_PROGRESS_MANUALLY) && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(DOGLCD))
67
-  uint8_t progress_bar_percent;
68
-#endif
69
-
70 66
 #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
71 67
   millis_t previous_lcd_status_ms = 0;
72 68
 #endif
@@ -92,6 +88,10 @@ char lcd_status_message[3 * (LCD_WIDTH) + 1] = WELCOME_MSG; // worst case is kan
92 88
   uint8_t filename_scroll_pos, filename_scroll_max, filename_scroll_hash;
93 89
 #endif
94 90
 
91
+#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
92
+  uint8_t progress_bar_percent;
93
+#endif
94
+
95 95
 #if ENABLED(DOGLCD)
96 96
   #include "ultralcd_impl_DOGM.h"
97 97
   #include <U8glib.h>
@@ -259,10 +259,6 @@ uint16_t max_display_update_time = 0;
259 259
   //////////// Menu System Macros ////////////
260 260
   ////////////////////////////////////////////
261 261
 
262
-  #ifndef ENCODER_FEEDRATE_DEADZONE
263
-    #define ENCODER_FEEDRATE_DEADZONE 6
264
-  #endif
265
-
266 262
   /**
267 263
    * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
268 264
    *
@@ -734,7 +730,7 @@ void kill_screen(const char* lcd_msg) {
734 730
    * Audio feedback for controller clicks
735 731
    *
736 732
    */
737
-  void lcd_buzz(long duration, uint16_t freq) {
733
+  void lcd_buzz(const long duration, const uint16_t freq) {
738 734
     #if ENABLED(LCD_USE_I2C_BUZZER)
739 735
       lcd.buzz(duration, freq);
740 736
     #elif PIN_EXISTS(BEEPER)
@@ -1180,7 +1176,7 @@ void kill_screen(const char* lcd_msg) {
1180 1176
       return mesh_edit_value;
1181 1177
     }
1182 1178
 
1183
-    void lcd_mesh_edit_setup(float initial) {
1179
+    void lcd_mesh_edit_setup(const float initial) {
1184 1180
       mesh_edit_value = mesh_edit_accumulator = initial;
1185 1181
       lcd_goto_screen(_lcd_mesh_edit_NOP);
1186 1182
     }
@@ -1332,9 +1328,9 @@ void kill_screen(const char* lcd_msg) {
1332 1328
     #if FAN_COUNT > 0
1333 1329
       #if HAS_FAN0
1334 1330
         MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fanSpeeds[0], 0, 255);
1335
-       #if ENABLED(EXTRA_FAN_SPEED)
1331
+        #if ENABLED(EXTRA_FAN_SPEED)
1336 1332
           MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fanSpeeds[0], 3, 255);
1337
-       #endif
1333
+        #endif
1338 1334
       #endif
1339 1335
       #if HAS_FAN1
1340 1336
         MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 2", &fanSpeeds[1], 0, 255);
@@ -1836,7 +1832,6 @@ void kill_screen(const char* lcd_msg) {
1836 1832
     /**
1837 1833
      * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
1838 1834
      */
1839
-
1840 1835
     void _lcd_level_bed_moving() {
1841 1836
       if (lcdDrawUpdate) {
1842 1837
         char msg[10];
@@ -2306,11 +2301,12 @@ void kill_screen(const char* lcd_msg) {
2306 2301
 
2307 2302
     void _lcd_ubl_map_homing() {
2308 2303
       defer_return_to_status = true;
2309
-      ubl.lcd_map_control = true; // Return to the map screen
2310 2304
       if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT < 3 ? 0 : (LCD_HEIGHT > 4 ? 2 : 1), PSTR(MSG_LEVEL_BED_HOMING));
2311 2305
       lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
2312
-      if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
2306
+      if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
2307
+        ubl.lcd_map_control = true; // Return to the map screen
2313 2308
         lcd_goto_screen(_lcd_ubl_output_map_lcd);
2309
+      }
2314 2310
     }
2315 2311
 
2316 2312
     /**
@@ -2648,7 +2644,7 @@ void kill_screen(const char* lcd_msg) {
2648 2644
 
2649 2645
     void lcd_move_z();
2650 2646
 
2651
-    void _man_probe_pt(const float rx, const float ry) {
2647
+    void _man_probe_pt(const float &rx, const float &ry) {
2652 2648
       #if HAS_LEVELING
2653 2649
         reset_bed_level(); // After calibration bed-level data is no longer valid
2654 2650
       #endif
@@ -2711,7 +2707,7 @@ void kill_screen(const char* lcd_msg) {
2711 2707
     void lcd_delta_settings() {
2712 2708
       START_MENU();
2713 2709
       MENU_BACK(MSG_DELTA_CALIBRATE);
2714
-      MENU_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_DIAG_ROG, &delta_diagonal_rod, delta_diagonal_rod - 5.0, delta_diagonal_rod + 5.0, recalc_delta_settings);
2710
+      MENU_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_DIAG_ROD, &delta_diagonal_rod, delta_diagonal_rod - 5.0, delta_diagonal_rod + 5.0, recalc_delta_settings);
2715 2711
       MENU_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10.0, delta_height + 10.0, recalc_delta_settings);
2716 2712
       MENU_ITEM_EDIT_CALLBACK(float43, "Ex", &delta_endstop_adj[A_AXIS], -5.0, 5.0, recalc_delta_settings);
2717 2713
       MENU_ITEM_EDIT_CALLBACK(float43, "Ey", &delta_endstop_adj[B_AXIS], -5.0, 5.0, recalc_delta_settings);
@@ -2784,10 +2780,7 @@ void kill_screen(const char* lcd_msg) {
2784 2780
         manual_move_offset = 0.0;
2785 2781
         manual_move_axis = (int8_t)NO_AXIS;
2786 2782
 
2787
-        // DELTA and SCARA machines use segmented moves, which could fill the planner during the call to
2788
-        // move_to_destination. This will cause idle() to be called, which can then call this function while the
2789
-        // previous invocation is being blocked. Modifications to manual_move_offset shouldn't be made while
2790
-        // processing_manual_move is true or the planner will get out of sync.
2783
+        // Set a blocking flag so no new moves can be added until all segments are done
2791 2784
         processing_manual_move = true;
2792 2785
         prepare_move_to_destination(); // will call set_current_from_destination()
2793 2786
         processing_manual_move = false;
@@ -2867,7 +2860,6 @@ void kill_screen(const char* lcd_msg) {
2867 2860
             #if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
2868 2861
               max = soft_endstop_max[Z_AXIS];
2869 2862
             #endif
2870
-            break;
2871 2863
           default: break;
2872 2864
         }
2873 2865
       #endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS
@@ -3141,7 +3133,7 @@ void kill_screen(const char* lcd_msg) {
3141 3133
     MENU_ITEM(submenu, MSG_FILAMENT, lcd_control_filament_menu);
3142 3134
 
3143 3135
     #if HAS_LCD_CONTRAST
3144
-      MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, (int*)&lcd_contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, lcd_callback_set_contrast, true);
3136
+      MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, &lcd_contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, lcd_callback_set_contrast, true);
3145 3137
     #endif
3146 3138
     #if ENABLED(FWRETRACT)
3147 3139
       MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);
@@ -4338,6 +4330,7 @@ void kill_screen(const char* lcd_msg) {
4338 4330
     } \
4339 4331
     typedef void _name
4340 4332
 
4333
+  DEFINE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01);
4341 4334
   DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1);
4342 4335
   DEFINE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1);
4343 4336
   DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
@@ -4347,7 +4340,6 @@ void kill_screen(const char* lcd_msg) {
4347 4340
   DEFINE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10.0);
4348 4341
   DEFINE_MENU_EDIT_TYPE(float, float52, ftostr52sign, 100.0);
4349 4342
   DEFINE_MENU_EDIT_TYPE(float, float62, ftostr62rj, 100.0);
4350
-  DEFINE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01);
4351 4343
 
4352 4344
   /**
4353 4345
    *
@@ -4610,8 +4602,13 @@ void lcd_update() {
4610 4602
 
4611 4603
   #if ENABLED(ULTIPANEL)
4612 4604
     static millis_t return_to_status_ms = 0;
4605
+
4606
+    // Handle any queued Move Axis motion
4613 4607
     manage_manual_move();
4614 4608
 
4609
+    // Update button states for LCD_CLICKED, etc.
4610
+    // After state changes the next button update
4611
+    // may be delayed 300-500ms.
4615 4612
     lcd_buttons_update();
4616 4613
 
4617 4614
     #if ENABLED(AUTO_BED_LEVELING_UBL)
@@ -4946,7 +4943,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
4946 4943
     #define encrot3 1
4947 4944
   #endif
4948 4945
 
4949
-  #define GET_BUTTON_STATES(DST) \
4946
+  #define GET_SHIFT_BUTTON_STATES(DST) \
4950 4947
     uint8_t new_##DST = 0; \
4951 4948
     WRITE(SHIFT_LD, LOW); \
4952 4949
     WRITE(SHIFT_LD, HIGH); \
@@ -4965,7 +4962,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
4965 4962
    */
4966 4963
   void lcd_buttons_update() {
4967 4964
     static uint8_t lastEncoderBits;
4968
-    millis_t now = millis();
4965
+    const millis_t now = millis();
4969 4966
     if (ELAPSED(now, next_button_update_ms)) {
4970 4967
 
4971 4968
       #if ENABLED(NEWPANEL)
@@ -5046,13 +5043,15 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
5046 5043
 
5047 5044
         #elif ENABLED(REPRAPWORLD_KEYPAD)
5048 5045
 
5049
-          GET_BUTTON_STATES(buttons_reprapworld_keypad);
5046
+          GET_SHIFT_BUTTON_STATES(buttons_reprapworld_keypad);
5050 5047
 
5051 5048
         #endif
5052 5049
 
5053
-      #else
5054
-        GET_BUTTON_STATES(buttons);
5055
-      #endif // !NEWPANEL
5050
+      #else // !NEWPANEL
5051
+
5052
+        GET_SHIFT_BUTTON_STATES(buttons);
5053
+
5054
+      #endif
5056 5055
 
5057 5056
     } // next_button_update_ms
5058 5057
 
@@ -5111,6 +5110,10 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
5111 5110
 
5112 5111
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
5113 5112
     bool is_lcd_clicked() { return LCD_CLICKED; }
5113
+    void wait_for_release() {
5114
+      while (is_lcd_clicked()) safe_delay(50);
5115
+      safe_delay(50);
5116
+    }
5114 5117
   #endif
5115 5118
 
5116 5119
 #endif // ULTIPANEL

+ 6
- 3
Marlin/ultralcd.h View File

@@ -23,10 +23,12 @@
23 23
 #ifndef ULTRALCD_H
24 24
 #define ULTRALCD_H
25 25
 
26
-#include "Marlin.h"
26
+#include "MarlinConfig.h"
27 27
 
28 28
 #if ENABLED(ULTRA_LCD)
29 29
 
30
+  #include "Marlin.h"
31
+
30 32
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
31 33
     extern bool lcd_external_control;
32 34
     #if ENABLED(G26_MESH_VALIDATION)
@@ -57,7 +59,7 @@
57 59
   inline void lcd_refresh() { lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; }
58 60
 
59 61
   #if HAS_BUZZER
60
-    void lcd_buzz(long duration, uint16_t freq);
62
+    void lcd_buzz(const long duration, const uint16_t freq);
61 63
   #endif
62 64
 
63 65
   #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
@@ -176,6 +178,7 @@
176 178
 
177 179
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
178 180
     bool is_lcd_clicked();
181
+    void wait_for_release();
179 182
   #endif
180 183
 
181 184
   #if ENABLED(LCD_SET_PROGRESS_MANUALLY) && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(DOGLCD))
@@ -204,7 +207,7 @@
204 207
 void lcd_reset_status();
205 208
 
206 209
 #if ENABLED(AUTO_BED_LEVELING_UBL)
207
-  void lcd_mesh_edit_setup(float initial);
210
+  void lcd_mesh_edit_setup(const float initial);
208 211
   float lcd_mesh_edit();
209 212
   void lcd_z_offset_edit_setup(float);
210 213
   float lcd_z_offset_edit();

Loading…
Cancel
Save