My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

menu_bed_corners.cpp 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. //
  23. // Level Bed Corners menu
  24. //
  25. #include "../../inc/MarlinConfigPre.h"
  26. #if HAS_LCD_MENU && ENABLED(LEVEL_BED_CORNERS)
  27. #include "menu.h"
  28. #include "../../module/motion.h"
  29. #include "../../module/planner.h"
  30. #if HAS_LEVELING
  31. #include "../../feature/bedlevel/bedlevel.h"
  32. #endif
  33. #ifndef LEVEL_CORNERS_Z_HOP
  34. #define LEVEL_CORNERS_Z_HOP 4.0
  35. #endif
  36. #ifndef LEVEL_CORNERS_HEIGHT
  37. #define LEVEL_CORNERS_HEIGHT 0.0
  38. #endif
  39. static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration.");
  40. #if HAS_LEVELING
  41. static bool leveling_was_active = false;
  42. #endif
  43. /**
  44. * Level corners, starting in the front-left corner.
  45. */
  46. static int8_t bed_corner;
  47. static inline void _lcd_goto_next_corner() {
  48. constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB;
  49. constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] },
  50. rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] };
  51. line_to_z(LEVEL_CORNERS_Z_HOP);
  52. switch (bed_corner) {
  53. case 0: current_position = lf; break; // copy xy
  54. case 1: current_position.x = rb.x; break;
  55. case 2: current_position.y = rb.y; break;
  56. case 3: current_position.x = lf.x; break;
  57. #if ENABLED(LEVEL_CENTER_TOO)
  58. case 4: current_position.set(X_CENTER, Y_CENTER); break;
  59. #endif
  60. }
  61. line_to_current_position(manual_feedrate_mm_s.x);
  62. line_to_z(LEVEL_CORNERS_HEIGHT);
  63. if (++bed_corner > (3
  64. #if ENABLED(LEVEL_CENTER_TOO)
  65. + 1
  66. #endif
  67. )) bed_corner = 0;
  68. }
  69. static inline void _lcd_level_bed_corners_homing() {
  70. _lcd_draw_homing();
  71. if (all_axes_homed()) {
  72. bed_corner = 0;
  73. ui.goto_screen([]{
  74. MenuItem_confirm::select_screen(
  75. GET_TEXT(MSG_BUTTON_NEXT), GET_TEXT(MSG_BUTTON_DONE),
  76. _lcd_goto_next_corner,
  77. []{
  78. #if HAS_LEVELING
  79. set_bed_leveling_enabled(leveling_was_active);
  80. #endif
  81. ui.goto_previous_screen_no_defer();
  82. },
  83. GET_TEXT(
  84. #if ENABLED(LEVEL_CENTER_TOO)
  85. MSG_LEVEL_BED_NEXT_POINT
  86. #else
  87. MSG_NEXT_CORNER
  88. #endif
  89. ), (PGM_P)nullptr, PSTR("?")
  90. );
  91. });
  92. ui.set_selection(true);
  93. _lcd_goto_next_corner();
  94. }
  95. }
  96. void _lcd_level_bed_corners() {
  97. ui.defer_status_screen();
  98. if (!all_axes_known()) {
  99. set_all_unhomed();
  100. queue.inject_P(G28_STR);
  101. }
  102. // Disable leveling so the planner won't mess with us
  103. #if HAS_LEVELING
  104. leveling_was_active = planner.leveling_active;
  105. set_bed_leveling_enabled(false);
  106. #endif
  107. ui.goto_screen(_lcd_level_bed_corners_homing);
  108. }
  109. #endif // HAS_LCD_MENU && LEVEL_BED_CORNERS