My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bedlevel.h 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. #include "../../inc/MarlinConfigPre.h"
  24. #if EITHER(RESTORE_LEVELING_AFTER_G28, ENABLE_LEVELING_AFTER_G28)
  25. #define CAN_SET_LEVELING_AFTER_G28 1
  26. #endif
  27. #if ENABLED(PROBE_MANUALLY)
  28. extern bool g29_in_progress;
  29. #else
  30. constexpr bool g29_in_progress = false;
  31. #endif
  32. bool leveling_is_valid();
  33. void set_bed_leveling_enabled(const bool enable=true);
  34. void reset_bed_level();
  35. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  36. void set_z_fade_height(const_float_t zfh, const bool do_report=true);
  37. #endif
  38. #if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY)
  39. void _manual_goto_xy(const xy_pos_t &pos);
  40. #endif
  41. /**
  42. * A class to save and change the bed leveling state,
  43. * then restore it when it goes out of scope.
  44. */
  45. class TemporaryBedLevelingState {
  46. bool saved;
  47. public:
  48. TemporaryBedLevelingState(const bool enable);
  49. ~TemporaryBedLevelingState() { set_bed_leveling_enabled(saved); }
  50. };
  51. #define TEMPORARY_BED_LEVELING_STATE(enable) const TemporaryBedLevelingState tbls(enable)
  52. #if HAS_MESH
  53. typedef float bed_mesh_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
  54. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  55. #include "abl/bbl.h"
  56. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  57. #include "ubl/ubl.h"
  58. #elif ENABLED(MESH_BED_LEVELING)
  59. #include "mbl/mesh_bed_leveling.h"
  60. #endif
  61. #if EITHER(AUTO_BED_LEVELING_BILINEAR, MESH_BED_LEVELING)
  62. #include <stdint.h>
  63. typedef float (*element_2d_fn)(const uint8_t, const uint8_t);
  64. /**
  65. * Print calibration results for plotting or manual frame adjustment.
  66. */
  67. void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, const float *values);
  68. #endif
  69. struct mesh_index_pair {
  70. xy_int8_t pos;
  71. float distance; // When populated, the distance from the search location
  72. void invalidate() { pos = -1; }
  73. bool valid() const { return pos.x >= 0 && pos.y >= 0; }
  74. #if ENABLED(AUTO_BED_LEVELING_UBL)
  75. xy_pos_t meshpos() {
  76. return { bedlevel.get_mesh_x(pos.x), bedlevel.get_mesh_y(pos.y) };
  77. }
  78. #endif
  79. operator xy_int8_t&() { return pos; }
  80. operator const xy_int8_t&() const { return pos; }
  81. };
  82. #endif