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

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