Explorar el Código

Adjust axis homed / trusted methods (#20323)

Scott Lahteine hace 3 años
padre
commit
8fd8772a6f
No account linked to committer's email address

+ 4
- 5
Marlin/src/gcode/calibrate/G28.cpp Ver fichero

@@ -319,15 +319,14 @@ void GcodeSuite::G28() {
319 319
 
320 320
     #endif
321 321
 
322
-    const float z_homing_height =
323
-      ENABLED(UNKNOWN_Z_NO_RAISE) && !TEST(axis_known_position, Z_AXIS)
324
-        ? 0
325
-        : (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT);
322
+    const float z_homing_height = TERN1(UNKNOWN_Z_NO_RAISE, axis_is_trusted(Z_AXIS))
323
+                                  ? (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT)
324
+                                  : 0;
326 325
 
327 326
     if (z_homing_height && (doX || doY || TERN0(Z_SAFE_HOMING, doZ))) {
328 327
       // Raise Z before homing any other axes and z is not already high enough (never lower z)
329 328
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
330
-      do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE));
329
+      do_z_clearance(z_homing_height, axis_is_trusted(Z_AXIS), DISABLED(UNKNOWN_Z_NO_RAISE));
331 330
     }
332 331
 
333 332
     #if ENABLED(QUICK_HOME)

+ 1
- 1
Marlin/src/gcode/calibrate/G34.cpp Ver fichero

@@ -39,7 +39,7 @@
39 39
 void GcodeSuite::G34() {
40 40
 
41 41
   // Home before the alignment procedure
42
-  if (!all_axes_known()) home_all_axes();
42
+  if (!all_axes_trusted()) home_all_axes();
43 43
 
44 44
   SET_SOFT_ENDSTOP_LOOSE(true);
45 45
   TEMPORARY_BED_LEVELING_STATE(false);

+ 1
- 1
Marlin/src/gcode/calibrate/G34_M422.cpp Ver fichero

@@ -167,7 +167,7 @@ void GcodeSuite::G34() {
167 167
       );
168 168
 
169 169
       // Home before the alignment procedure
170
-      if (!all_axes_known()) home_all_axes();
170
+      if (!all_axes_trusted()) home_all_axes();
171 171
 
172 172
       // Move the Z coordinate realm towards the positive - dirty trick
173 173
       current_position.z += z_probe * 0.5f;

+ 1
- 1
Marlin/src/gcode/feature/pause/M600.cpp Ver fichero

@@ -102,7 +102,7 @@ void GcodeSuite::M600() {
102 102
 
103 103
   #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
104 104
     // If needed, home before parking for filament change
105
-    if (!all_axes_known()) home_all_axes();
105
+    if (!all_axes_trusted()) home_all_axes();
106 106
   #endif
107 107
 
108 108
   #if HAS_MULTI_EXTRUDER

+ 4
- 8
Marlin/src/gcode/feature/pause/M701_M702.cpp Ver fichero

@@ -59,10 +59,8 @@
59 59
 void GcodeSuite::M701() {
60 60
   xyz_pos_t park_point = NOZZLE_PARK_POINT;
61 61
 
62
-  #if ENABLED(NO_MOTION_BEFORE_HOMING)
63
-    // Don't raise Z if the machine isn't homed
64
-    if (axes_should_home()) park_point.z = 0;
65
-  #endif
62
+  // Don't raise Z if the machine isn't homed
63
+  if (TERN0(NO_MOTION_BEFORE_HOMING, axes_should_home())) park_point.z = 0;
66 64
 
67 65
   #if ENABLED(MIXING_EXTRUDER)
68 66
     const int8_t target_e_stepper = get_target_e_stepper_from_command();
@@ -147,10 +145,8 @@ void GcodeSuite::M701() {
147 145
 void GcodeSuite::M702() {
148 146
   xyz_pos_t park_point = NOZZLE_PARK_POINT;
149 147
 
150
-  #if ENABLED(NO_MOTION_BEFORE_HOMING)
151
-    // Don't raise Z if the machine isn't homed
152
-    if (axes_should_home()) park_point.z = 0;
153
-  #endif
148
+  // Don't raise Z if the machine isn't homed
149
+  if (TERN0(NO_MOTION_BEFORE_HOMING, axes_should_home())) park_point.z = 0;
154 150
 
155 151
   #if ENABLED(MIXING_EXTRUDER)
156 152
     const uint8_t old_mixing_tool = mixer.get_current_vtool();

+ 6
- 12
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp Ver fichero

@@ -506,18 +506,12 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
506 506
   lcd_put_wchar('X' + uint8_t(axis));
507 507
   if (blink)
508 508
     lcd_put_u8str(value);
509
-  else {
510
-    if (!TEST(axis_homed, axis))
511
-      while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
512
-    else {
513
-      #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
514
-        if (!TEST(axis_known_position, axis))
515
-          lcd_put_u8str_P(axis == Z_AXIS ? PSTR("       ") : PSTR("    "));
516
-        else
517
-      #endif
518
-          lcd_put_u8str(value);
519
-    }
520
-  }
509
+  else if (axis_should_home(axis))
510
+    while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
511
+  else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
512
+    lcd_put_u8str_P(axis == Z_AXIS ? PSTR("       ") : PSTR("    "));
513
+  else
514
+    lcd_put_u8str(value);
521 515
 }
522 516
 
523 517
 FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {

+ 6
- 12
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp Ver fichero

@@ -422,18 +422,12 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
422 422
   lcd.write('X' + uint8_t(axis));
423 423
   if (blink)
424 424
     lcd.print(value);
425
-  else {
426
-    if (!TEST(axis_homed, axis))
427
-      while (const char c = *value++) lcd.write(c <= '.' ? c : '?');
428
-    else {
429
-      #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
430
-        if (!TEST(axis_known_position, axis))
431
-          lcd_put_u8str_P(axis == Z_AXIS ? PSTR("       ") : PSTR("    "));
432
-        else
433
-      #endif
434
-          lcd_put_u8str(value);
435
-    }
436
-  }
425
+  else if (axis_should_home(axis))
426
+    while (const char c = *value++) lcd.write(c <= '.' ? c : '?');
427
+  else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
428
+    lcd_put_u8str_P(axis == Z_AXIS ? PSTR("       ") : PSTR("    "));
429
+  else
430
+    lcd_put_u8str(value);
437 431
 }
438 432
 
439 433
 FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *prefix, const bool blink) {

+ 6
- 12
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Ver fichero

@@ -384,18 +384,12 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
384 384
 
385 385
   if (blink)
386 386
     lcd_put_u8str(value);
387
-  else {
388
-    if (!TEST(axis_homed, axis))
389
-      while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
390
-    else {
391
-      #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
392
-        if (!TEST(axis_known_position, axis))
393
-          lcd_put_u8str_P(axis == Z_AXIS ? PSTR("       ") : PSTR("    "));
394
-        else
395
-      #endif
396
-          lcd_put_u8str(value);
397
-    }
398
-  }
387
+  else if (axis_should_home(axis))
388
+    while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
389
+  else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
390
+    lcd_put_u8str_P(axis == Z_AXIS ? PSTR("       ") : PSTR("    "));
391
+  else
392
+    lcd_put_u8str(value);
399 393
 }
400 394
 
401 395
 /**

+ 5
- 6
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp Ver fichero

@@ -659,13 +659,13 @@ void ST7920_Lite_Status_Screen::draw_status_message() {
659 659
   #endif
660 660
 }
661 661
 
662
-void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool position_known) {
662
+void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool position_trusted) {
663 663
   char str[7];
664 664
   set_ddram_address(DDRAM_LINE_4);
665 665
   begin_data();
666 666
 
667 667
   // If position is unknown, flash the labels.
668
-  const unsigned char alt_label = position_known ? 0 : (ui.get_blink() ? ' ' : 0);
668
+  const unsigned char alt_label = position_trusted ? 0 : (ui.get_blink() ? ' ' : 0);
669 669
 
670 670
   if (TERN1(LCD_SHOW_E_TOTAL, !printingIsActive())) {
671 671
     write_byte(alt_label ? alt_label : 'X');
@@ -831,9 +831,8 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) {
831 831
       }
832 832
     }
833 833
 
834
-    if (countdown == 0 && (forceUpdate || position_changed()
835
-      || TERN(DISABLE_REDUCED_ACCURACY_WARNING, 0, blink_changed())
836
-    )) draw_position(current_position, TERN(DISABLE_REDUCED_ACCURACY_WARNING, 1, all_axes_known()));
834
+    if (countdown == 0 && (forceUpdate || position_changed() || TERN(DISABLE_REDUCED_ACCURACY_WARNING, 0, blink_changed())))
835
+      draw_position(current_position, TERN(DISABLE_REDUCED_ACCURACY_WARNING, 1, all_axes_trusted()));
837 836
   #endif
838 837
 }
839 838
 
@@ -855,7 +854,7 @@ void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) {
855 854
 
856 855
     UNUSED(forceUpdate);
857 856
 
858
-  #endif // LCD_SET_PROGRESS_MANUALLY || SDSUPPORT
857
+  #endif
859 858
 }
860 859
 
861 860
 void ST7920_Lite_Status_Screen::update(const bool forceUpdate) {

+ 1
- 2
Marlin/src/lcd/dwin/e3v2/dwin.cpp Ver fichero

@@ -1281,8 +1281,7 @@ void HMI_Move_Z() {
1281 1281
       last_zoffset = dwin_zoffset;
1282 1282
       dwin_zoffset = HMI_ValueStruct.offset_value / 100.0f;
1283 1283
       #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP)
1284
-        if ( (ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_known()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()) )
1285
-          babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset);
1284
+        if (BABYSTEP_ALLOWED()) babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset);
1286 1285
       #endif
1287 1286
       DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(zoff_line), HMI_ValueStruct.offset_value);
1288 1287
       DWIN_UpdateLCD();

+ 6
- 6
Marlin/src/lcd/extui/ui_api.cpp Ver fichero

@@ -356,9 +356,9 @@ namespace ExtUI {
356 356
   bool canMove(const axis_t axis) {
357 357
     switch (axis) {
358 358
       #if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
359
-        case X: return TEST(axis_homed, X_AXIS);
360
-        case Y: return TEST(axis_homed, Y_AXIS);
361
-        case Z: return TEST(axis_homed, Z_AXIS);
359
+        case X: return axis_should_home(X_AXIS);
360
+        case Y: return axis_should_home(Y_AXIS);
361
+        case Z: return axis_should_home(Z_AXIS);
362 362
       #else
363 363
         case X: case Y: case Z: return true;
364 364
       #endif
@@ -889,9 +889,9 @@ namespace ExtUI {
889 889
 
890 890
   bool commandsInQueue() { return (planner.movesplanned() || queue.has_commands_queued()); }
891 891
 
892
-  bool isAxisPositionKnown(const axis_t axis) { return TEST(axis_known_position, axis); }
893
-  bool isAxisPositionKnown(const extruder_t) { return TEST(axis_known_position, E_AXIS); }
894
-  bool isPositionKnown() { return all_axes_known(); }
892
+  bool isAxisPositionKnown(const axis_t axis) { return axis_is_trusted((AxisEnum)axis); }
893
+  bool isAxisPositionKnown(const extruder_t) { return axis_is_trusted(E_AXIS); }
894
+  bool isPositionKnown() { return all_axes_trusted(); }
895 895
   bool isMachineHomed() { return all_axes_homed(); }
896 896
 
897 897
   PGM_P getFirmwareName_str() {

+ 1
- 2
Marlin/src/lcd/menu/menu.cpp Ver fichero

@@ -188,8 +188,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
188 188
           doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
189 189
       }
190 190
       else if (screen == status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
191
-        if ( (ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_known())
192
-          && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()) )
191
+        if (BABYSTEP_ALLOWED())
193 192
           screen = TERN(BABYSTEP_ZPROBE_OFFSET, lcd_babystep_zoffset, lcd_babystep_z);
194 193
         else {
195 194
           #if ENABLED(MOVE_Z_WHEN_IDLE)

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_corners.cpp Ver fichero

@@ -230,7 +230,7 @@ static inline void _lcd_level_bed_corners_homing() {
230 230
 
231 231
 void _lcd_level_bed_corners() {
232 232
   ui.defer_status_screen();
233
-  if (!all_axes_known()) {
233
+  if (!all_axes_trusted()) {
234 234
     set_all_unhomed();
235 235
     queue.inject_P(G28_STR);
236 236
   }

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_leveling.cpp Ver fichero

@@ -237,7 +237,7 @@
237 237
  *    Save Settings       (Req: EEPROM_SETTINGS)
238 238
  */
239 239
 void menu_bed_leveling() {
240
-  const bool is_homed = all_axes_known(),
240
+  const bool is_homed = all_axes_trusted(),
241 241
              is_valid = leveling_is_valid();
242 242
 
243 243
   START_MENU();

+ 1
- 1
Marlin/src/lcd/menu/menu_configuration.cpp Ver fichero

@@ -164,7 +164,7 @@ void menu_advanced_settings();
164 164
   void menu_tool_offsets() {
165 165
 
166 166
     auto _recalc_offsets = []{
167
-      if (active_extruder && all_axes_known()) {  // For the 2nd extruder re-home so the next tool-change gets the new offsets.
167
+      if (active_extruder && all_axes_trusted()) {  // For the 2nd extruder re-home so the next tool-change gets the new offsets.
168 168
         queue.inject_P(G28_STR); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
169 169
         active_extruder = 0;
170 170
       }

+ 1
- 1
Marlin/src/lcd/menu/menu_ubl.cpp Ver fichero

@@ -524,7 +524,7 @@ void _ubl_map_screen_homing() {
524 524
  */
525 525
 void _ubl_goto_map_screen() {
526 526
   if (planner.movesplanned()) return;     // The ACTION_ITEM will do nothing
527
-  if (!all_axes_known()) {
527
+  if (!all_axes_trusted()) {
528 528
     set_all_unhomed();
529 529
     queue.inject_P(G28_STR);
530 530
   }

+ 13
- 18
Marlin/src/lcd/tft/ui_320x240.cpp Ver fichero

@@ -257,42 +257,37 @@ void MarlinUI::draw_status_screen() {
257 257
   tft.set_background(COLOR_BACKGROUND);
258 258
   tft.add_rectangle(0, 0, 312, 24, COLOR_AXIS_HOMED);
259 259
 
260
-  uint16_t color;
261
-  uint16_t offset;
262
-  bool is_homed;
263
-
264 260
   tft.add_text( 10, 3, COLOR_AXIS_HOMED , "X");
265 261
   tft.add_text(127, 3, COLOR_AXIS_HOMED , "Y");
266 262
   tft.add_text(219, 3, COLOR_AXIS_HOMED , "Z");
267 263
 
268
-  is_homed = TEST(axis_homed, X_AXIS);
269
-  tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
270
-  tft.add_text( 68 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
264
+  bool not_homed = axis_should_home(X_AXIS);
265
+  tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
266
+  tft.add_text( 68 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
271 267
 
272
-  is_homed = TEST(axis_homed, Y_AXIS);
273
-  tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
274
-  tft.add_text(185 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
268
+  not_homed = axis_should_home(Y_AXIS);
269
+  tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
270
+  tft.add_text(185 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
275 271
 
276
-  is_homed = TEST(axis_homed, Z_AXIS);
277
-  if (blink & !is_homed) {
272
+  not_homed = axis_should_home(Z_AXIS);
273
+  uint16_t offset = 25;
274
+  if (blink && not_homed)
278 275
     tft_string.set("?");
279
-    offset = 25; // ".00"
280
-  }
281 276
   else {
282 277
     const float z = LOGICAL_Z_POSITION(current_position.z);
283 278
     tft_string.set(ftostr52sp((int16_t)z));
284 279
     tft_string.rtrim();
285
-    offset = tft_string.width();
280
+    offset += tft_string.width();
286 281
 
287 282
     tft_string.set(ftostr52sp(z));
288
-    offset += 25 - tft_string.width();
283
+    offset -= tft_string.width();
289 284
   }
290
-  tft.add_text(301 - tft_string.width() - offset, 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
285
+  tft.add_text(301 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
291 286
 
292 287
   // feed rate
293 288
   tft.canvas(70, 136, 80, 32);
294 289
   tft.set_background(COLOR_BACKGROUND);
295
-  color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
290
+  uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
296 291
   tft.add_image(0, 0, imgFeedRate, color);
297 292
   tft_string.set(i16tostr3rj(feedrate_percentage));
298 293
   tft_string.add('%');

+ 13
- 18
Marlin/src/lcd/tft/ui_480x320.cpp Ver fichero

@@ -262,43 +262,38 @@ void MarlinUI::draw_status_screen() {
262 262
   tft.set_background(COLOR_BACKGROUND);
263 263
   tft.add_rectangle(0, 0, TFT_WIDTH - 8, 34, COLOR_AXIS_HOMED);
264 264
 
265
-  uint16_t color;
266
-  uint16_t offset;
267
-  bool is_homed;
268
-
269 265
   tft.add_text( 16, 3, COLOR_AXIS_HOMED , "X");
270 266
   tft.add_text(192, 3, COLOR_AXIS_HOMED , "Y");
271 267
   tft.add_text(330, 3, COLOR_AXIS_HOMED , "Z");
272 268
 
273
-  is_homed = TEST(axis_homed, X_AXIS);
274
-  tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
275
-  tft.add_text(102 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
269
+  bool not_homed = axis_should_home(X_AXIS);
270
+  tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
271
+  tft.add_text(102 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
276 272
 
277
-  is_homed = TEST(axis_homed, Y_AXIS);
278
-  tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
279
-  tft.add_text(280 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
273
+  not_homed = axis_should_home(Y_AXIS);
274
+  tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
275
+  tft.add_text(280 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
280 276
 
281
-  is_homed = TEST(axis_homed, Z_AXIS);
282
-  if (blink & !is_homed) {
277
+  uint16_t offset = 32;
278
+  not_homed = axis_should_home(Z_AXIS);
279
+  if (blink && not_homed)
283 280
     tft_string.set("?");
284
-    offset = 32; // ".00"
285
-  }
286 281
   else {
287 282
     const float z = LOGICAL_Z_POSITION(current_position.z);
288 283
     tft_string.set(ftostr52sp((int16_t)z));
289 284
     tft_string.rtrim();
290
-    offset = tft_string.width();
285
+    offset += tft_string.width();
291 286
 
292 287
     tft_string.set(ftostr52sp(z));
293
-    offset += 32 - tft_string.width();
288
+    offset -= tft_string.width();
294 289
   }
295
-  tft.add_text(455 - tft_string.width() - offset, 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
290
+  tft.add_text(455 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
296 291
   TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, 132, TFT_WIDTH - 8, 34));
297 292
 
298 293
   // feed rate
299 294
   tft.canvas(96, 180, 100, 32);
300 295
   tft.set_background(COLOR_BACKGROUND);
301
-  color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
296
+  uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
302 297
   tft.add_image(0, 0, imgFeedRate, color);
303 298
   tft_string.set(i16tostr3rj(feedrate_percentage));
304 299
   tft_string.add('%');

+ 18
- 17
Marlin/src/module/motion.cpp Ver fichero

@@ -79,11 +79,11 @@
79 79
  *   Flags that each linear axis was homed.
80 80
  *   XYZ on cartesian, ABC on delta, ABZ on SCARA.
81 81
  *
82
- * axis_known_position
83
- *   Flags that the position is known in each linear axis. Set when homed.
82
+ * axis_trusted
83
+ *   Flags that the position is trusted in each linear axis. Set when homed.
84 84
  *   Cleared whenever a stepper powers off, potentially losing its position.
85 85
  */
86
-uint8_t axis_homed, axis_known_position; // = 0
86
+uint8_t axis_homed, axis_trusted; // = 0
87 87
 
88 88
 // Relative Mode. Enable with G91, disable with G90.
89 89
 bool relative_mode; // = false;
@@ -506,8 +506,8 @@ void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRat
506 506
   do_blocking_move_to(raw.x, raw.y, z, fr_mm_s);
507 507
 }
508 508
 
509
-void do_z_clearance(const float &zclear, const bool z_known/*=true*/, const bool raise_on_unknown/*=true*/, const bool lower_allowed/*=false*/) {
510
-  const bool rel = raise_on_unknown && !z_known;
509
+void do_z_clearance(const float &zclear, const bool z_trusted/*=true*/, const bool raise_on_untrusted/*=true*/, const bool lower_allowed/*=false*/) {
510
+  const bool rel = raise_on_untrusted && !z_trusted;
511 511
   float zdest = zclear + (rel ? current_position.z : 0.0f);
512 512
   if (!lower_allowed) NOLESS(zdest, current_position.z);
513 513
   do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), MMM_TO_MMS(TERN(HAS_BED_PROBE, Z_PROBE_SPEED_FAST, HOMING_FEEDRATE_Z)));
@@ -649,7 +649,7 @@ void restore_feedrate_and_scaling() {
649 649
         constexpr xy_pos_t offs{0};
650 650
       #endif
651 651
 
652
-      if (TERN1(IS_SCARA, TEST(axis_homed, X_AXIS) && TEST(axis_homed, Y_AXIS))) {
652
+      if (TERN1(IS_SCARA, axis_was_homed(X_AXIS) && axis_was_homed(Y_AXIS))) {
653 653
         const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y);
654 654
         if (dist_2 > delta_max_radius_2)
655 655
           target *= float(delta_max_radius / SQRT(dist_2)); // 200 / 300 = 0.66
@@ -657,7 +657,7 @@ void restore_feedrate_and_scaling() {
657 657
 
658 658
     #else
659 659
 
660
-      if (TEST(axis_homed, X_AXIS)) {
660
+      if (axis_was_homed(X_AXIS)) {
661 661
         #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_X)
662 662
           NOLESS(target.x, soft_endstop.min.x);
663 663
         #endif
@@ -666,7 +666,7 @@ void restore_feedrate_and_scaling() {
666 666
         #endif
667 667
       }
668 668
 
669
-      if (TEST(axis_homed, Y_AXIS)) {
669
+      if (axis_was_homed(Y_AXIS)) {
670 670
         #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
671 671
           NOLESS(target.y, soft_endstop.min.y);
672 672
         #endif
@@ -677,7 +677,7 @@ void restore_feedrate_and_scaling() {
677 677
 
678 678
     #endif
679 679
 
680
-    if (TEST(axis_homed, Z_AXIS)) {
680
+    if (axis_was_homed(Z_AXIS)) {
681 681
       #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
682 682
         NOLESS(target.z, soft_endstop.min.z);
683 683
       #endif
@@ -1124,10 +1124,11 @@ void prepare_line_to_destination() {
1124 1124
 }
1125 1125
 
1126 1126
 uint8_t axes_should_home(uint8_t axis_bits/*=0x07*/) {
1127
+  #define SHOULD_HOME(A) TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(A)
1127 1128
   // Clear test bits that are trusted
1128
-  if (TEST(axis_bits, X_AXIS) && TEST(axis_homed, X_AXIS)) CBI(axis_bits, X_AXIS);
1129
-  if (TEST(axis_bits, Y_AXIS) && TEST(axis_homed, Y_AXIS)) CBI(axis_bits, Y_AXIS);
1130
-  if (TEST(axis_bits, Z_AXIS) && TEST(axis_homed, Z_AXIS)) CBI(axis_bits, Z_AXIS);
1129
+  if (TEST(axis_bits, X_AXIS) && SHOULD_HOME(X_AXIS)) CBI(axis_bits, X_AXIS);
1130
+  if (TEST(axis_bits, Y_AXIS) && SHOULD_HOME(Y_AXIS)) CBI(axis_bits, Y_AXIS);
1131
+  if (TEST(axis_bits, Z_AXIS) && SHOULD_HOME(Z_AXIS)) CBI(axis_bits, Z_AXIS);
1131 1132
   return axis_bits;
1132 1133
 }
1133 1134
 
@@ -1388,7 +1389,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
1388 1389
  *
1389 1390
  * DELTA should wait until all homing is done before setting the XYZ
1390 1391
  * current_position to home, because homing is a single operation.
1391
- * In the case where the axis positions are already known and previously
1392
+ * In the case where the axis positions are trusted and previously
1392 1393
  * homed, DELTA could home to X or Y individually by moving either one
1393 1394
  * to the center. However, homing Z always homes XY and Z.
1394 1395
  *
@@ -1401,8 +1402,8 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
1401 1402
 void set_axis_is_at_home(const AxisEnum axis) {
1402 1403
   if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", axis_codes[axis], ")");
1403 1404
 
1404
-  SBI(axis_known_position, axis);
1405
-  SBI(axis_homed, axis);
1405
+  set_axis_trusted(axis);
1406
+  set_axis_homed(axis);
1406 1407
 
1407 1408
   #if ENABLED(DUAL_X_CARRIAGE)
1408 1409
     if (axis == X_AXIS && (active_extruder == 1 || dual_x_carriage_mode == DXC_DUPLICATION_MODE)) {
@@ -1462,8 +1463,8 @@ void set_axis_is_at_home(const AxisEnum axis) {
1462 1463
 void set_axis_never_homed(const AxisEnum axis) {
1463 1464
   if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", axis_codes[axis], ")");
1464 1465
 
1465
-  CBI(axis_known_position, axis);
1466
-  CBI(axis_homed, axis);
1466
+  set_axis_untrusted(axis);
1467
+  set_axis_unhomed(axis);
1467 1468
 
1468 1469
   if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", axis_codes[axis], ")");
1469 1470
 

+ 23
- 17
Marlin/src/module/motion.h Ver fichero

@@ -34,19 +34,6 @@
34 34
   #include "scara.h"
35 35
 #endif
36 36
 
37
-// Axis homed and known-position states
38
-extern uint8_t axis_homed, axis_known_position;
39
-constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
40
-FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
41
-FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; }
42
-FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; }
43
-FORCE_INLINE void set_all_homed() { axis_homed = axis_known_position = xyz_bits; }
44
-FORCE_INLINE void set_all_unhomed() { axis_homed = axis_known_position = 0; }
45
-
46
-FORCE_INLINE bool homing_needed() {
47
-  return !TERN(HOME_AFTER_DEACTIVATE, all_axes_known, all_axes_homed)();
48
-}
49
-
50 37
 // Error margin to work around float imprecision
51 38
 constexpr float fslop = 0.0001;
52 39
 
@@ -269,23 +256,42 @@ void remember_feedrate_and_scaling();
269 256
 void remember_feedrate_scaling_off();
270 257
 void restore_feedrate_and_scaling();
271 258
 
272
-void do_z_clearance(const float &zclear, const bool z_known=true, const bool raise_on_unknown=true, const bool lower_allowed=false);
259
+void do_z_clearance(const float &zclear, const bool z_trusted=true, const bool raise_on_untrusted=true, const bool lower_allowed=false);
260
+
261
+/**
262
+ * Homing and Trusted Axes
263
+ */
264
+constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
265
+extern uint8_t axis_homed, axis_trusted;
273 266
 
274
-//
275
-// Homing
276
-//
277 267
 void homeaxis(const AxisEnum axis);
278 268
 void set_axis_is_at_home(const AxisEnum axis);
279 269
 void set_axis_never_homed(const AxisEnum axis);
280 270
 uint8_t axes_should_home(uint8_t axis_bits=0x07);
281 271
 bool homing_needed_error(uint8_t axis_bits=0x07);
282 272
 
273
+FORCE_INLINE bool axis_was_homed(const AxisEnum axis)     { return TEST(axis_homed, axis); }
274
+FORCE_INLINE bool axis_is_trusted(const AxisEnum axis)    { return TEST(axis_trusted, axis); }
275
+FORCE_INLINE bool axis_should_home(const AxisEnum axis)   { return (axes_should_home() & _BV(axis)) != 0; }
276
+FORCE_INLINE bool no_axes_homed()                         { return !axis_homed; }
277
+FORCE_INLINE bool all_axes_homed()                        { return xyz_bits == (axis_homed & xyz_bits); }
278
+FORCE_INLINE bool homing_needed()                         { return !all_axes_homed(); }
279
+FORCE_INLINE bool all_axes_trusted()                      { return xyz_bits == (axis_trusted & xyz_bits); }
280
+FORCE_INLINE void set_axis_homed(const AxisEnum axis)     { SBI(axis_homed, axis); }
281
+FORCE_INLINE void set_axis_unhomed(const AxisEnum axis)   { CBI(axis_homed, axis); }
282
+FORCE_INLINE void set_axis_trusted(const AxisEnum axis)   { SBI(axis_trusted, axis); }
283
+FORCE_INLINE void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); }
284
+FORCE_INLINE void set_all_homed()                         { axis_homed = axis_trusted = xyz_bits; }
285
+FORCE_INLINE void set_all_unhomed()                       { axis_homed = axis_trusted = 0; }
286
+
283 287
 #if ENABLED(NO_MOTION_BEFORE_HOMING)
284 288
   #define MOTION_CONDITIONS (IsRunning() && !homing_needed_error())
285 289
 #else
286 290
   #define MOTION_CONDITIONS IsRunning()
287 291
 #endif
288 292
 
293
+#define BABYSTEP_ALLOWED() ((ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_trusted()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()))
294
+
289 295
 /**
290 296
  * Workspace offsets
291 297
  */

+ 2
- 2
Marlin/src/module/probe.cpp Ver fichero

@@ -350,7 +350,7 @@ bool Probe::set_deployed(const bool deploy) {
350 350
 
351 351
   // For beds that fall when Z is powered off only raise for trusted Z
352 352
   #if ENABLED(UNKNOWN_Z_NO_RAISE)
353
-    const bool unknown_condition = TEST(axis_known_position, Z_AXIS);
353
+    const bool unknown_condition = axis_is_trusted(Z_AXIS);
354 354
   #else
355 355
     constexpr float unknown_condition = true;
356 356
   #endif
@@ -510,7 +510,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
510 510
 
511 511
   // Stop the probe before it goes too low to prevent damage.
512 512
   // If Z isn't known then probe to -10mm.
513
-  const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -offset.z + Z_PROBE_LOW_POINT : -10.0;
513
+  const float z_probe_low_point = axis_is_trusted(Z_AXIS) ? -offset.z + Z_PROBE_LOW_POINT : -10.0;
514 514
 
515 515
   // Double-probing does a fast probe followed by a slow probe
516 516
   #if TOTAL_PROBING == 2

+ 3
- 5
Marlin/src/module/stepper/indirection.h Ver fichero

@@ -856,13 +856,11 @@ void reset_stepper_drivers();    // Called by settings.load / settings.reset
856 856
 #endif
857 857
 
858 858
 #define  ENABLE_AXIS_X() if (SHOULD_ENABLE(x))  {  ENABLE_STEPPER_X();  ENABLE_STEPPER_X2(); AFTER_CHANGE(x, true); }
859
-#define DISABLE_AXIS_X() if (SHOULD_DISABLE(x)) { DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); AFTER_CHANGE(x, false); FORGET_AXIS(X_AXIS); }
859
+#define DISABLE_AXIS_X() if (SHOULD_DISABLE(x)) { DISABLE_STEPPER_X(); DISABLE_STEPPER_X2(); AFTER_CHANGE(x, false); set_axis_untrusted(X_AXIS); }
860 860
 #define  ENABLE_AXIS_Y() if (SHOULD_ENABLE(y))  {  ENABLE_STEPPER_Y();  ENABLE_STEPPER_Y2(); AFTER_CHANGE(y, true); }
861
-#define DISABLE_AXIS_Y() if (SHOULD_DISABLE(y)) { DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); AFTER_CHANGE(y, false); FORGET_AXIS(Y_AXIS); }
861
+#define DISABLE_AXIS_Y() if (SHOULD_DISABLE(y)) { DISABLE_STEPPER_Y(); DISABLE_STEPPER_Y2(); AFTER_CHANGE(y, false); set_axis_untrusted(Y_AXIS); }
862 862
 #define  ENABLE_AXIS_Z() if (SHOULD_ENABLE(z))  {  ENABLE_STEPPER_Z();  ENABLE_STEPPER_Z2();  ENABLE_STEPPER_Z3();  ENABLE_STEPPER_Z4(); AFTER_CHANGE(z, true); }
863
-#define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); FORGET_AXIS(Z_AXIS); Z_RESET(); }
864
-
865
-#define FORGET_AXIS(A) TERN(HOME_AFTER_DEACTIVATE, set_axis_never_homed(A), CBI(axis_known_position, A))
863
+#define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); set_axis_untrusted(Z_AXIS); Z_RESET(); }
866 864
 
867 865
 #ifdef Z_AFTER_DEACTIVATE
868 866
   #define Z_RESET() do{ current_position.z = Z_AFTER_DEACTIVATE; sync_plan_position(); }while(0)

Loading…
Cancelar
Guardar