My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #include "../module/planner.h"
  25. class Backlash {
  26. public:
  27. static constexpr uint8_t all_on = 0xFF, all_off = 0x00;
  28. private:
  29. static axis_bits_t last_direction_bits;
  30. static xyz_long_t residual_error;
  31. #if ENABLED(BACKLASH_GCODE)
  32. static uint8_t correction;
  33. static xyz_float_t distance_mm;
  34. #ifdef BACKLASH_SMOOTHING_MM
  35. static float smoothing_mm;
  36. #endif
  37. #else
  38. static constexpr uint8_t correction = (BACKLASH_CORRECTION) * all_on;
  39. static const xyz_float_t distance_mm;
  40. #ifdef BACKLASH_SMOOTHING_MM
  41. static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM;
  42. #endif
  43. #endif
  44. #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
  45. static xyz_float_t measured_mm;
  46. static xyz_uint8_t measured_count;
  47. #endif
  48. class StepAdjuster;
  49. public:
  50. static float get_measurement(const AxisEnum a) {
  51. UNUSED(a);
  52. // Return the measurement averaged over all readings
  53. return TERN(MEASURE_BACKLASH_WHEN_PROBING
  54. , measured_count[a] > 0 ? measured_mm[a] / measured_count[a] : 0
  55. , 0
  56. );
  57. }
  58. static bool has_measurement(const AxisEnum a) {
  59. UNUSED(a);
  60. return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0);
  61. }
  62. static bool has_any_measurement() {
  63. return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS);
  64. }
  65. static void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block);
  66. static int32_t get_applied_steps(const AxisEnum axis);
  67. #if ENABLED(BACKLASH_GCODE)
  68. static void set_correction_uint8(const uint8_t v);
  69. static uint8_t get_correction_uint8() { return correction; }
  70. static void set_correction(const float v) { set_correction_uint8(_MAX(0, _MIN(1.0, v)) * all_on + 0.5f); }
  71. static float get_correction() { return float(get_correction_uint8()) / all_on; }
  72. static void set_distance_mm(const AxisEnum axis, const float v);
  73. static float get_distance_mm(const AxisEnum axis) {return distance_mm[axis];}
  74. #ifdef BACKLASH_SMOOTHING_MM
  75. static void set_smoothing_mm(const float v);
  76. static float get_smoothing_mm() {return smoothing_mm;}
  77. #endif
  78. #endif
  79. #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
  80. static void measure_with_probe();
  81. #endif
  82. };
  83. extern Backlash backlash;