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
   static int8_t g26_prime_flag;
164
   static int8_t g26_prime_flag;
165
 
165
 
166
   #if ENABLED(NEWPANEL)
166
   #if ENABLED(NEWPANEL)
167
+
167
     /**
168
     /**
168
      * Detect is_lcd_clicked, debounce it, and return true for cancel
169
      * Detect is_lcd_clicked, debounce it, and return true for cancel
169
      */
170
      */
170
     bool user_canceled() {
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
       #if ENABLED(ULTRA_LCD)
174
       #if ENABLED(ULTRA_LCD)
175
         lcd_setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
175
         lcd_setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
176
         lcd_quick_feedback();
176
         lcd_quick_feedback();
177
       #endif
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
       // If the button is suddenly pressed again,
182
       // If the button is suddenly pressed again,
182
       // ask the user to resolve the issue
183
       // ask the user to resolve the issue
183
       lcd_setstatusPGM(PSTR("Release button"), 99); // will never appear...
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
       lcd_reset_status();
186
       lcd_reset_status();
186
-
187
       return true;
187
       return true;
188
     }
188
     }
189
-  #endif
190
 
189
 
191
-  #if ENABLED(NEWPANEL)
192
     bool exit_from_g26() {
190
     bool exit_from_g26() {
193
       lcd_setstatusPGM(PSTR("Leaving G26"), -1);
191
       lcd_setstatusPGM(PSTR("Leaving G26"), -1);
194
-      while (is_lcd_clicked()) idle();
192
+      wait_for_release();
195
       return G26_ERR;
193
       return G26_ERR;
196
     }
194
     }
195
+
197
   #endif
196
   #endif
198
 
197
 
199
   void G26_line_to_destination(const float &feed_rate) {
198
   void G26_line_to_destination(const float &feed_rate) {
200
     const float save_feedrate = feedrate_mm_s;
199
     const float save_feedrate = feedrate_mm_s;
201
     feedrate_mm_s = feed_rate;      // use specified feed rate
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
     feedrate_mm_s = save_feedrate;  // restore global feed rate
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
     float feed_value;
206
     float feed_value;
208
     static float last_z = -999.99;
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
     if (z != last_z) {
211
     if (z != last_z) {
213
       last_z = z;
212
       last_z = z;
230
 
229
 
231
     if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
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
     destination[E_AXIS] += e_delta;
234
     destination[E_AXIS] += e_delta;
236
 
235
 
237
     G26_line_to_destination(feed_value);
236
     G26_line_to_destination(feed_value);
291
           idle();
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
       else
301
       else
305
     #endif
302
     #endif
491
     return false;
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
    * Turn on the bed and nozzle heat and
492
    * Turn on the bed and nozzle heat and
502
    * wait for them to get up to temperature.
493
    * wait for them to get up to temperature.
503
    */
494
    */
504
-  bool turn_on_heaters() {
495
+  inline bool turn_on_heaters() {
505
     millis_t next = millis() + 5000UL;
496
     millis_t next = millis() + 5000UL;
506
     #if HAS_TEMP_BED
497
     #if HAS_TEMP_BED
507
       #if ENABLED(ULTRA_LCD)
498
       #if ENABLED(ULTRA_LCD)
519
 
510
 
520
             if (ELAPSED(millis(), next)) {
511
             if (ELAPSED(millis(), next)) {
521
               next = millis() + 5000UL;
512
               next = millis() + 5000UL;
522
-              print_heaterstates();
513
+              thermalManager.print_heaterstates();
523
               SERIAL_EOL();
514
               SERIAL_EOL();
524
             }
515
             }
525
             idle();
516
             idle();
541
 
532
 
542
       if (ELAPSED(millis(), next)) {
533
       if (ELAPSED(millis(), next)) {
543
         next = millis() + 5000UL;
534
         next = millis() + 5000UL;
544
-        print_heaterstates();
535
+        thermalManager.print_heaterstates();
545
         SERIAL_EOL();
536
         SERIAL_EOL();
546
       }
537
       }
547
       idle();
538
       idle();
555
     return G26_OK;
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
    * G26: Mesh Validation Pattern generation.
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
    * nozzle in a problem area and doing a G29 P4 R command.
559
    * nozzle in a problem area and doing a G29 P4 R command.
563
    */
560
    */
564
   void gcode_G26() {
561
   void gcode_G26() {
704
       set_current_from_destination();
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
     current_position[E_AXIS] = 0.0;
706
     current_position[E_AXIS] = 0.0;
710
     sync_plan_position_e();
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
      *  Bed is preheated
712
      *  Bed is preheated

+ 0
- 4
Marlin/Marlin.h View File

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

+ 8
- 96
Marlin/Marlin_main.cpp View File

519
   #define BUZZ(d,f) NOOP
519
   #define BUZZ(d,f) NOOP
520
 #endif
520
 #endif
521
 
521
 
522
-static uint8_t target_extruder;
522
+uint8_t target_extruder;
523
 
523
 
524
 #if HAS_BED_PROBE
524
 #if HAS_BED_PROBE
525
   float zprobe_zoffset; // Initialized by settings.load()
525
   float zprobe_zoffset; // Initialized by settings.load()
7570
   #endif
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
  * M105: Read hot end and bed temperature
7574
  * M105: Read hot end and bed temperature
7649
  */
7575
  */
7652
 
7578
 
7653
   #if HAS_TEMP_HOTEND || HAS_TEMP_BED
7579
   #if HAS_TEMP_HOTEND || HAS_TEMP_BED
7654
     SERIAL_PROTOCOLPGM(MSG_OK);
7580
     SERIAL_PROTOCOLPGM(MSG_OK);
7655
-    print_heaterstates();
7581
+    thermalManager.print_heaterstates();
7656
   #else // !HAS_TEMP_HOTEND && !HAS_TEMP_BED
7582
   #else // !HAS_TEMP_HOTEND && !HAS_TEMP_BED
7657
     SERIAL_ERROR_START();
7583
     SERIAL_ERROR_START();
7658
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
7584
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
7663
 
7589
 
7664
 #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
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
    * M155: Set temperature auto-report interval. M155 S<seconds>
7593
    * M155: Set temperature auto-report interval. M155 S<seconds>
7671
    */
7594
    */
7672
   inline void gcode_M155() {
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
 #endif // AUTO_REPORT_TEMPERATURES
7600
 #endif // AUTO_REPORT_TEMPERATURES
7851
     now = millis();
7763
     now = millis();
7852
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
7764
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
7853
       next_temp_ms = now + 1000UL;
7765
       next_temp_ms = now + 1000UL;
7854
-      print_heaterstates();
7766
+      thermalManager.print_heaterstates();
7855
       #if TEMP_RESIDENCY_TIME > 0
7767
       #if TEMP_RESIDENCY_TIME > 0
7856
         SERIAL_PROTOCOLPGM(" W:");
7768
         SERIAL_PROTOCOLPGM(" W:");
7857
         if (residency_start_ms)
7769
         if (residency_start_ms)
7988
       now = millis();
7900
       now = millis();
7989
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
7901
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
7990
         next_temp_ms = now + 1000UL;
7902
         next_temp_ms = now + 1000UL;
7991
-        print_heaterstates();
7903
+        thermalManager.print_heaterstates();
7992
         #if TEMP_BED_RESIDENCY_TIME > 0
7904
         #if TEMP_BED_RESIDENCY_TIME > 0
7993
           SERIAL_PROTOCOLPGM(" W:");
7905
           SERIAL_PROTOCOLPGM(" W:");
7994
           if (residency_start_ms)
7906
           if (residency_start_ms)
9917
    * M503: print settings currently in memory
9829
    * M503: print settings currently in memory
9918
    */
9830
    */
9919
   inline void gcode_M503() {
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
 #endif
9834
 #endif
9923
 
9835
 
13672
   host_keepalive();
13584
   host_keepalive();
13673
 
13585
 
13674
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
13586
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
13675
-    auto_report_temperatures();
13587
+    thermalManager.auto_report_temperatures();
13676
   #endif
13588
   #endif
13677
 
13589
 
13678
   manage_inactivity(
13590
   manage_inactivity(

+ 4
- 0
Marlin/SanityCheck.h View File

298
 #if ENABLED(LCD_PROGRESS_BAR)
298
 #if ENABLED(LCD_PROGRESS_BAR)
299
   #if DISABLED(SDSUPPORT)
299
   #if DISABLED(SDSUPPORT)
300
     #error "LCD_PROGRESS_BAR requires SDSUPPORT."
300
     #error "LCD_PROGRESS_BAR requires SDSUPPORT."
301
+  #elif DISABLED(ULTRA_LCD)
302
+    #error "LCD_PROGRESS_BAR requires a character LCD."
301
   #elif ENABLED(DOGLCD)
303
   #elif ENABLED(DOGLCD)
302
     #error "LCD_PROGRESS_BAR does not apply to graphical displays."
304
     #error "LCD_PROGRESS_BAR does not apply to graphical displays."
303
   #elif ENABLED(FILAMENT_LCD_DISPLAY)
305
   #elif ENABLED(FILAMENT_LCD_DISPLAY)
304
     #error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both."
306
     #error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both."
305
   #endif
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
 #endif
310
 #endif
307
 
311
 
308
 /**
312
 /**

+ 1
- 1
Marlin/configuration_store.cpp View File

1547
    *
1547
    *
1548
    * Unless specifically disabled, M503 is available even without EEPROM
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
      * Announce current units, in case inches are being displayed
1553
      * Announce current units, in case inches are being displayed

+ 2
- 2
Marlin/configuration_store.h View File

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

+ 2
- 2
Marlin/language_en.h View File

813
 #ifndef MSG_DELTA_HEIGHT_CALIBRATE
813
 #ifndef MSG_DELTA_HEIGHT_CALIBRATE
814
   #define MSG_DELTA_HEIGHT_CALIBRATE          _UxGT("Set Delta Height")
814
   #define MSG_DELTA_HEIGHT_CALIBRATE          _UxGT("Set Delta Height")
815
 #endif
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
 #endif
818
 #endif
819
 #ifndef MSG_DELTA_HEIGHT
819
 #ifndef MSG_DELTA_HEIGHT
820
   #define MSG_DELTA_HEIGHT                    _UxGT("Height")
820
   #define MSG_DELTA_HEIGHT                    _UxGT("Height")

+ 1
- 1
Marlin/pins_MELZI_CREALITY.h View File

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

+ 9
- 4
Marlin/planner.cpp View File

124
           Planner::inverse_z_fade_height,
124
           Planner::inverse_z_fade_height,
125
           Planner::last_fade_z;
125
           Planner::last_fade_z;
126
   #endif
126
   #endif
127
+#else
128
+  constexpr bool Planner::leveling_active;
127
 #endif
129
 #endif
128
 
130
 
129
 #if ENABLED(SKEW_CORRECTION)
131
 #if ENABLED(SKEW_CORRECTION)
130
   #if ENABLED(SKEW_CORRECTION_GCODE)
132
   #if ENABLED(SKEW_CORRECTION_GCODE)
131
-    // Initialized by settings.load()
132
     float Planner::xy_skew_factor;
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
   #endif
141
   #endif
137
 #endif
142
 #endif
138
 
143
 

+ 26
- 21
Marlin/stepper.cpp View File

83
 // private:
83
 // private:
84
 
84
 
85
 uint8_t Stepper::last_direction_bits = 0;        // The next stepping-bits to be output
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
 #if ENABLED(X_DUAL_ENDSTOPS)
88
 #if ENABLED(X_DUAL_ENDSTOPS)
89
   bool Stepper::locked_x_motor = false, Stepper::locked_x2_motor = false;
89
   bool Stepper::locked_x_motor = false, Stepper::locked_x2_motor = false;
381
 
381
 
382
   uint16_t ocr_val;
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
   #if DISABLED(LIN_ADVANCE)
387
   #if DISABLED(LIN_ADVANCE)
388
     // Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars)
388
     // Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars)
393
 
393
 
394
   #define _SPLIT(L) (ocr_val = (uint16_t)L)
394
   #define _SPLIT(L) (ocr_val = (uint16_t)L)
395
   #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
395
   #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
396
+
396
     #define SPLIT(L) _SPLIT(L)
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
     static uint32_t step_remaining = 0;
401
     static uint32_t step_remaining = 0;
402
+
399
     #define SPLIT(L) do { \
403
     #define SPLIT(L) do { \
400
       _SPLIT(L); \
404
       _SPLIT(L); \
401
       if (ENDSTOPS_ENABLED && L > ENDSTOP_NOMINAL_OCR_VAL) { \
405
       if (ENDSTOPS_ENABLED && L > ENDSTOP_NOMINAL_OCR_VAL) { \
407
 
411
 
408
     if (step_remaining && ENDSTOPS_ENABLED) {   // Just check endstops - not yet time for a step
412
     if (step_remaining && ENDSTOPS_ENABLED) {   // Just check endstops - not yet time for a step
409
       endstops.update();
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
       _NEXT_ISR(ocr_val);
418
       _NEXT_ISR(ocr_val);
420
-
421
       NOLESS(OCR1A, TCNT1 + 16);
419
       NOLESS(OCR1A, TCNT1 + 16);
422
-
423
       _ENABLE_ISRs(); // re-enable ISRs
420
       _ENABLE_ISRs(); // re-enable ISRs
424
       return;
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
   if (cleaning_buffer_counter) {
429
   if (cleaning_buffer_counter) {
429
-    --cleaning_buffer_counter;
430
     current_block = NULL;
430
     current_block = NULL;
431
     planner.discard_current_block();
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
     return;
442
     return;
438
   }
443
   }
439
 
444
 

+ 1
- 1
Marlin/stepper.h View File

104
   private:
104
   private:
105
 
105
 
106
     static uint8_t last_direction_bits;        // The next stepping-bits to be output
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
     #if ENABLED(X_DUAL_ENDSTOPS)
109
     #if ENABLED(X_DUAL_ENDSTOPS)
110
       static bool locked_x_motor, locked_x2_motor;
110
       static bool locked_x_motor, locked_x2_motor;

+ 93
- 1
Marlin/temperature.cpp View File

1273
    * their target temperature by a configurable margin.
1273
    * their target temperature by a configurable margin.
1274
    * This is called when the temperature is set. (M104, M109)
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
     #if HOTENDS == 1
1277
     #if HOTENDS == 1
1278
       UNUSED(e);
1278
       UNUSED(e);
1279
     #endif
1279
     #endif
2186
   in_temp_isr = false;
2186
   in_temp_isr = false;
2187
   SBI(TIMSK0, OCIE0B); //re-enable Temperature ISR
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
     static int16_t degTargetBed() { return target_temperature_bed; }
370
     static int16_t degTargetBed() { return target_temperature_bed; }
371
 
371
 
372
     #if WATCH_HOTENDS
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
     #endif
374
     #endif
375
 
375
 
376
     #if WATCH_THE_BED
376
     #if WATCH_THE_BED
377
       static void start_watching_bed();
377
       static void start_watching_bed();
378
     #endif
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
       #if HOTENDS == 1
381
       #if HOTENDS == 1
382
         UNUSED(e);
382
         UNUSED(e);
383
       #endif
383
       #endif
455
 
455
 
456
     #if ENABLED(BABYSTEPPING)
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
         if (axis_known_position[axis]) {
459
         if (axis_known_position[axis]) {
460
           #if IS_CORE
460
           #if IS_CORE
461
             #if ENABLED(BABYSTEP_XY)
461
             #if ENABLED(BABYSTEP_XY)
539
       #endif
539
       #endif
540
     #endif
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
   private:
556
   private:
543
 
557
 
544
     static void set_current_temp_raw();
558
     static void set_current_temp_raw();

+ 8
- 4
Marlin/ubl.h View File

81
         static int  g29_grid_size;
81
         static int  g29_grid_size;
82
       #endif
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
       static bool g29_parameter_parsing();
92
       static bool g29_parameter_parsing();
87
       static void find_mean_mesh_height();
93
       static void find_mean_mesh_height();
88
       static void shift_mesh_height();
94
       static void shift_mesh_height();
89
       static void probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
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
       static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
96
       static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
92
       static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
97
       static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
93
       static void g29_what_command();
98
       static void g29_what_command();
94
       static void g29_eeprom_dump();
99
       static void g29_eeprom_dump();
95
       static void g29_compare_current_mesh_to_stored_mesh();
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
       static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
101
       static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
98
       static void smart_fill_mesh();
102
       static void smart_fill_mesh();
99
 
103
 

+ 128
- 121
Marlin/ubl_G29.cpp View File

24
 
24
 
25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
26
 
26
 
27
+  //#define UBL_DEVEL_DEBUGGING
28
+
27
   #include "ubl.h"
29
   #include "ubl.h"
28
   #include "Marlin.h"
30
   #include "Marlin.h"
29
   #include "hex_print_routines.h"
31
   #include "hex_print_routines.h"
43
 
45
 
44
   #if ENABLED(NEWPANEL)
46
   #if ENABLED(NEWPANEL)
45
     void lcd_return_to_status();
47
     void lcd_return_to_status();
46
-    void lcd_mesh_edit_setup(float initial);
48
+    void lcd_mesh_edit_setup(const float initial);
47
     float lcd_mesh_edit();
49
     float lcd_mesh_edit();
48
     void lcd_z_offset_edit_setup(float);
50
     void lcd_z_offset_edit_setup(float);
49
     extern void _lcd_ubl_output_map_lcd();
51
     extern void _lcd_ubl_output_map_lcd();
55
   extern float probe_pt(const float &rx, const float &ry, const bool, const uint8_t, const bool=true);
57
   extern float probe_pt(const float &rx, const float &ry, const bool, const uint8_t, const bool=true);
56
   extern bool set_probe_deployed(bool);
58
   extern bool set_probe_deployed(bool);
57
   extern void set_bed_leveling_enabled(bool);
59
   extern void set_bed_leveling_enabled(bool);
60
+
58
   typedef void (*screenFunc_t)();
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
   #define SIZE_OF_LITTLE_RAISE 1
64
   #define SIZE_OF_LITTLE_RAISE 1
62
   #define BIG_RAISE_NOT_NEEDED 0
65
   #define BIG_RAISE_NOT_NEEDED 0
642
               SERIAL_ECHOPAIR(" J ", y);
645
               SERIAL_ECHOPAIR(" J ", y);
643
               SERIAL_ECHOPGM(" Z ");
646
               SERIAL_ECHOPGM(" Z ");
644
               SERIAL_ECHO_F(z_values[x][y], 6);
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
               SERIAL_EOL();
650
               SERIAL_EOL();
648
             }
651
             }
649
         return;
652
         return;
728
           z_values[x][y] += g29_constant;
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
   #if HAS_BED_PROBE
758
   #if HAS_BED_PROBE
732
     /**
759
     /**
733
      * Probe all invalidated locations of the mesh that can be reached by the probe.
760
      * Probe all invalidated locations of the mesh that can be reached by the probe.
753
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
780
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
754
             lcd_quick_feedback();
781
             lcd_quick_feedback();
755
             STOW_PROBE();
782
             STOW_PROBE();
756
-            while (is_lcd_clicked()) idle();
783
+            wait_for_release();
757
             lcd_external_control = false;
784
             lcd_external_control = false;
758
             restore_ubl_active_state_and_leave();
785
             restore_ubl_active_state_and_leave();
759
-            safe_delay(50);  // Debounce the Encoder wheel
760
             return;
786
             return;
761
           }
787
           }
762
         #endif
788
         #endif
774
           z_values[location.x_index][location.y_index] = measured_z;
800
           z_values[location.x_index][location.y_index] = measured_z;
775
         }
801
         }
776
 
802
 
777
-
778
       } while (location.x_index >= 0 && --max_iterations);
803
       } while (location.x_index >= 0 && --max_iterations);
779
 
804
 
780
       STOW_PROBE();
805
       STOW_PROBE();
889
         }
914
         }
890
       }
915
       }
891
     }
916
     }
917
+
892
   #endif // HAS_BED_PROBE
918
   #endif // HAS_BED_PROBE
893
 
919
 
894
   #if ENABLED(NEWPANEL)
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
         idle();
925
         idle();
904
         if (encoder_diff) {
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
           encoder_diff = 0;
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
       KEEPALIVE_STATE(IN_HANDLER);
936
       KEEPALIVE_STATE(IN_HANDLER);
910
       return current_position[Z_AXIS];
937
       return current_position[Z_AXIS];
911
     }
938
     }
912
 
939
 
913
     static void echo_and_take_a_measurement() { SERIAL_PROTOCOLLNPGM(" and take a measurement."); }
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
       lcd_external_control = true;
943
       lcd_external_control = true;
917
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
944
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
918
 
945
 
945
         SERIAL_PROTOCOLLNPGM("mm thick.");
972
         SERIAL_PROTOCOLLNPGM("mm thick.");
946
       }
973
       }
947
 
974
 
948
-      in_height = current_position[Z_AXIS]; // do manual probing at lower height
949
-
950
       lcd_external_control = false;
975
       lcd_external_control = false;
951
 
976
 
952
       restore_ubl_active_state_and_leave();
977
       restore_ubl_active_state_and_leave();
954
       return thickness;
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
     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) {
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
       lcd_external_control = true;
992
       lcd_external_control = true;
989
         const float z_step = 0.01;                                        // existing behavior: 0.01mm per click, occasionally step
1022
         const float z_step = 0.01;                                        // existing behavior: 0.01mm per click, occasionally step
990
         //const float z_step = 1.0 / planner.axis_steps_per_mm[Z_AXIS];   // approx one step each click
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
         z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - thick;
1036
         z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - thick;
1152
     return UBL_OK;
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
     ubl_state_at_invocation = planner.leveling_active;
1185
     ubl_state_at_invocation = planner.leveling_active;
1171
     set_bed_leveling_enabled(false);
1186
     set_bed_leveling_enabled(false);
1172
   }
1187
   }
1173
 
1188
 
1174
   void unified_bed_leveling::restore_ubl_active_state_and_leave() {
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
     set_bed_leveling_enabled(ubl_state_at_invocation);
1200
     set_bed_leveling_enabled(ubl_state_at_invocation);
1186
   }
1201
   }
1187
 
1202
 
1253
     SERIAL_EOL();
1268
     SERIAL_EOL();
1254
     safe_delay(50);
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
     if (!sanity_check()) {
1296
     if (!sanity_check()) {
1280
       echo_name();
1297
       echo_name();
1344
         z_values[x][y] -= tmp_z_values[x][y];
1361
         z_values[x][y] -= tmp_z_values[x][y];
1345
   }
1362
   }
1346
 
1363
 
1347
-
1348
   mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
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
     mesh_index_pair out_mesh;
1368
     mesh_index_pair out_mesh;
1353
     out_mesh.x_index = out_mesh.y_index = -1;
1369
     out_mesh.x_index = out_mesh.y_index = -1;
1354
     out_mesh.distance = -99999.99;
1370
     out_mesh.distance = -99999.99;
1356
     for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1372
     for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1357
       for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
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
           const float mx = mesh_index_to_xpos(i),
1377
           const float mx = mesh_index_to_xpos(i),
1362
                       my = mesh_index_to_ypos(j);
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
             continue;
1381
             continue;
1366
 
1382
 
1367
           found_a_NAN = true;
1383
           found_a_NAN = true;
1443
 
1459
 
1444
           float distance = HYPOT(px - mx, py - my);
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
           if (distance < best_so_far) {
1465
           if (distance < best_so_far) {
1451
             best_so_far = distance;   // We found a closer location with
1466
             best_so_far = distance;   // We found a closer location with
1452
             out_mesh.x_index = i;     // the specified type of mesh value.
1467
             out_mesh.x_index = i;     // the specified type of mesh value.
1462
 
1477
 
1463
   #if ENABLED(NEWPANEL)
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
     void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {
1486
     void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {
1466
       if (!parser.seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
1487
       if (!parser.seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
1467
         g29_repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
1488
         g29_repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
1495
 
1516
 
1496
         if (location.x_index < 0) break; // stop when we can't find any more reachable points.
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
         const float rawx = mesh_index_to_xpos(location.x_index),
1522
         const float rawx = mesh_index_to_xpos(location.x_index),
1502
                     rawy = mesh_index_to_ypos(location.y_index);
1523
                     rawy = mesh_index_to_ypos(location.y_index);
1504
         if (!position_is_reachable(rawx, rawy)) // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
1525
         if (!position_is_reachable(rawx, rawy)) // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
1505
           break;
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
         do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point
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
         KEEPALIVE_STATE(PAUSED_FOR_USER);
1530
         KEEPALIVE_STATE(PAUSED_FOR_USER);
1517
         lcd_external_control = true;
1531
         lcd_external_control = true;
1518
 
1532
 
1520
 
1534
 
1521
         lcd_refresh();
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
         lcd_mesh_edit_setup(new_z);
1541
         lcd_mesh_edit_setup(new_z);
1524
 
1542
 
1525
-        do {
1543
+        while (!is_lcd_clicked()) {
1526
           new_z = lcd_mesh_edit();
1544
           new_z = lcd_mesh_edit();
1527
           #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1545
           #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1528
             do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
1546
             do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
1529
           #endif
1547
           #endif
1530
           idle();
1548
           idle();
1531
-        } while (!is_lcd_clicked());
1549
+        }
1532
 
1550
 
1533
         if (!lcd_map_control) lcd_return_to_status();
1551
         if (!lcd_map_control) lcd_return_to_status();
1534
 
1552
 
1540
         // this sequence to detect an is_lcd_clicked() debounce it and leave if it is
1558
         // this sequence to detect an is_lcd_clicked() debounce it and leave if it is
1541
         // a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp).   This
1559
         // a Press and Hold is repeated in a lot of places (including G26_Mesh_Validation.cpp).   This
1542
         // should be redone and compressed.
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
         safe_delay(20);                       // We don't want any switch noise.
1564
         safe_delay(20);                       // We don't want any switch noise.
1558
 
1565
 

+ 34
- 31
Marlin/ultralcd.cpp View File

57
 #endif
57
 #endif
58
 
58
 
59
 #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
59
 #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
60
-  bool lcd_external_control;
60
+  bool lcd_external_control; // = false
61
 #endif
61
 #endif
62
 
62
 
63
 // Initialized by settings.load()
63
 // Initialized by settings.load()
64
 int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
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
 #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
66
 #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
71
   millis_t previous_lcd_status_ms = 0;
67
   millis_t previous_lcd_status_ms = 0;
72
 #endif
68
 #endif
92
   uint8_t filename_scroll_pos, filename_scroll_max, filename_scroll_hash;
88
   uint8_t filename_scroll_pos, filename_scroll_max, filename_scroll_hash;
93
 #endif
89
 #endif
94
 
90
 
91
+#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
92
+  uint8_t progress_bar_percent;
93
+#endif
94
+
95
 #if ENABLED(DOGLCD)
95
 #if ENABLED(DOGLCD)
96
   #include "ultralcd_impl_DOGM.h"
96
   #include "ultralcd_impl_DOGM.h"
97
   #include <U8glib.h>
97
   #include <U8glib.h>
259
   //////////// Menu System Macros ////////////
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
    * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
263
    * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
268
    *
264
    *
734
    * Audio feedback for controller clicks
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
     #if ENABLED(LCD_USE_I2C_BUZZER)
734
     #if ENABLED(LCD_USE_I2C_BUZZER)
739
       lcd.buzz(duration, freq);
735
       lcd.buzz(duration, freq);
740
     #elif PIN_EXISTS(BEEPER)
736
     #elif PIN_EXISTS(BEEPER)
1180
       return mesh_edit_value;
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
       mesh_edit_value = mesh_edit_accumulator = initial;
1180
       mesh_edit_value = mesh_edit_accumulator = initial;
1185
       lcd_goto_screen(_lcd_mesh_edit_NOP);
1181
       lcd_goto_screen(_lcd_mesh_edit_NOP);
1186
     }
1182
     }
1332
     #if FAN_COUNT > 0
1328
     #if FAN_COUNT > 0
1333
       #if HAS_FAN0
1329
       #if HAS_FAN0
1334
         MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fanSpeeds[0], 0, 255);
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
           MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fanSpeeds[0], 3, 255);
1332
           MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fanSpeeds[0], 3, 255);
1337
-       #endif
1333
+        #endif
1338
       #endif
1334
       #endif
1339
       #if HAS_FAN1
1335
       #if HAS_FAN1
1340
         MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 2", &fanSpeeds[1], 0, 255);
1336
         MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 2", &fanSpeeds[1], 0, 255);
1836
     /**
1832
     /**
1837
      * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
1833
      * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
1838
      */
1834
      */
1839
-
1840
     void _lcd_level_bed_moving() {
1835
     void _lcd_level_bed_moving() {
1841
       if (lcdDrawUpdate) {
1836
       if (lcdDrawUpdate) {
1842
         char msg[10];
1837
         char msg[10];
2306
 
2301
 
2307
     void _lcd_ubl_map_homing() {
2302
     void _lcd_ubl_map_homing() {
2308
       defer_return_to_status = true;
2303
       defer_return_to_status = true;
2309
-      ubl.lcd_map_control = true; // Return to the map screen
2310
       if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT < 3 ? 0 : (LCD_HEIGHT > 4 ? 2 : 1), PSTR(MSG_LEVEL_BED_HOMING));
2304
       if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT < 3 ? 0 : (LCD_HEIGHT > 4 ? 2 : 1), PSTR(MSG_LEVEL_BED_HOMING));
2311
       lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
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
         lcd_goto_screen(_lcd_ubl_output_map_lcd);
2308
         lcd_goto_screen(_lcd_ubl_output_map_lcd);
2309
+      }
2314
     }
2310
     }
2315
 
2311
 
2316
     /**
2312
     /**
2648
 
2644
 
2649
     void lcd_move_z();
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
       #if HAS_LEVELING
2648
       #if HAS_LEVELING
2653
         reset_bed_level(); // After calibration bed-level data is no longer valid
2649
         reset_bed_level(); // After calibration bed-level data is no longer valid
2654
       #endif
2650
       #endif
2711
     void lcd_delta_settings() {
2707
     void lcd_delta_settings() {
2712
       START_MENU();
2708
       START_MENU();
2713
       MENU_BACK(MSG_DELTA_CALIBRATE);
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
       MENU_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10.0, delta_height + 10.0, recalc_delta_settings);
2711
       MENU_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10.0, delta_height + 10.0, recalc_delta_settings);
2716
       MENU_ITEM_EDIT_CALLBACK(float43, "Ex", &delta_endstop_adj[A_AXIS], -5.0, 5.0, recalc_delta_settings);
2712
       MENU_ITEM_EDIT_CALLBACK(float43, "Ex", &delta_endstop_adj[A_AXIS], -5.0, 5.0, recalc_delta_settings);
2717
       MENU_ITEM_EDIT_CALLBACK(float43, "Ey", &delta_endstop_adj[B_AXIS], -5.0, 5.0, recalc_delta_settings);
2713
       MENU_ITEM_EDIT_CALLBACK(float43, "Ey", &delta_endstop_adj[B_AXIS], -5.0, 5.0, recalc_delta_settings);
2784
         manual_move_offset = 0.0;
2780
         manual_move_offset = 0.0;
2785
         manual_move_axis = (int8_t)NO_AXIS;
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
         processing_manual_move = true;
2784
         processing_manual_move = true;
2792
         prepare_move_to_destination(); // will call set_current_from_destination()
2785
         prepare_move_to_destination(); // will call set_current_from_destination()
2793
         processing_manual_move = false;
2786
         processing_manual_move = false;
2867
             #if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
2860
             #if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
2868
               max = soft_endstop_max[Z_AXIS];
2861
               max = soft_endstop_max[Z_AXIS];
2869
             #endif
2862
             #endif
2870
-            break;
2871
           default: break;
2863
           default: break;
2872
         }
2864
         }
2873
       #endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS
2865
       #endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS
3141
     MENU_ITEM(submenu, MSG_FILAMENT, lcd_control_filament_menu);
3133
     MENU_ITEM(submenu, MSG_FILAMENT, lcd_control_filament_menu);
3142
 
3134
 
3143
     #if HAS_LCD_CONTRAST
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
     #endif
3137
     #endif
3146
     #if ENABLED(FWRETRACT)
3138
     #if ENABLED(FWRETRACT)
3147
       MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);
3139
       MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);
4338
     } \
4330
     } \
4339
     typedef void _name
4331
     typedef void _name
4340
 
4332
 
4333
+  DEFINE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01);
4341
   DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1);
4334
   DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1);
4342
   DEFINE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1);
4335
   DEFINE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1);
4343
   DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
4336
   DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
4347
   DEFINE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10.0);
4340
   DEFINE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10.0);
4348
   DEFINE_MENU_EDIT_TYPE(float, float52, ftostr52sign, 100.0);
4341
   DEFINE_MENU_EDIT_TYPE(float, float52, ftostr52sign, 100.0);
4349
   DEFINE_MENU_EDIT_TYPE(float, float62, ftostr62rj, 100.0);
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
 
4602
 
4611
   #if ENABLED(ULTIPANEL)
4603
   #if ENABLED(ULTIPANEL)
4612
     static millis_t return_to_status_ms = 0;
4604
     static millis_t return_to_status_ms = 0;
4605
+
4606
+    // Handle any queued Move Axis motion
4613
     manage_manual_move();
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
     lcd_buttons_update();
4612
     lcd_buttons_update();
4616
 
4613
 
4617
     #if ENABLED(AUTO_BED_LEVELING_UBL)
4614
     #if ENABLED(AUTO_BED_LEVELING_UBL)
4946
     #define encrot3 1
4943
     #define encrot3 1
4947
   #endif
4944
   #endif
4948
 
4945
 
4949
-  #define GET_BUTTON_STATES(DST) \
4946
+  #define GET_SHIFT_BUTTON_STATES(DST) \
4950
     uint8_t new_##DST = 0; \
4947
     uint8_t new_##DST = 0; \
4951
     WRITE(SHIFT_LD, LOW); \
4948
     WRITE(SHIFT_LD, LOW); \
4952
     WRITE(SHIFT_LD, HIGH); \
4949
     WRITE(SHIFT_LD, HIGH); \
4965
    */
4962
    */
4966
   void lcd_buttons_update() {
4963
   void lcd_buttons_update() {
4967
     static uint8_t lastEncoderBits;
4964
     static uint8_t lastEncoderBits;
4968
-    millis_t now = millis();
4965
+    const millis_t now = millis();
4969
     if (ELAPSED(now, next_button_update_ms)) {
4966
     if (ELAPSED(now, next_button_update_ms)) {
4970
 
4967
 
4971
       #if ENABLED(NEWPANEL)
4968
       #if ENABLED(NEWPANEL)
5046
 
5043
 
5047
         #elif ENABLED(REPRAPWORLD_KEYPAD)
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
         #endif
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
     } // next_button_update_ms
5056
     } // next_button_update_ms
5058
 
5057
 
5111
 
5110
 
5112
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
5111
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
5113
     bool is_lcd_clicked() { return LCD_CLICKED; }
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
   #endif
5117
   #endif
5115
 
5118
 
5116
 #endif // ULTIPANEL
5119
 #endif // ULTIPANEL

+ 6
- 3
Marlin/ultralcd.h View File

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

Loading…
Cancel
Save