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

endstops.h 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. * endstops.h - manages endstops
  24. */
  25. #ifndef ENDSTOPS_H
  26. #define ENDSTOPS_H
  27. enum EndstopEnum {X_MIN = 0, Y_MIN = 1, Z_MIN = 2, Z_MIN_PROBE = 3, X_MAX = 4, Y_MAX = 5, Z_MAX = 6, Z2_MIN = 7, Z2_MAX = 8};
  28. class Endstops {
  29. public:
  30. volatile char endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
  31. #if ENABLED(Z_DUAL_ENDSTOPS)
  32. uint16_t current_endstop_bits = 0,
  33. old_endstop_bits = 0;
  34. #else
  35. byte current_endstop_bits = 0,
  36. old_endstop_bits = 0;
  37. #endif
  38. bool enabled = true;
  39. bool enabled_globally =
  40. #if ENABLED(ENDSTOPS_ONLY_FOR_HOMING)
  41. false
  42. #else
  43. true
  44. #endif
  45. ;
  46. Endstops();
  47. /**
  48. * Initialize the endstop pins
  49. */
  50. void init();
  51. /**
  52. * Update the endstops bits from the pins
  53. */
  54. void update();
  55. /**
  56. * Print an error message reporting the position when the endstops were last hit.
  57. */
  58. void report_state(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered
  59. /**
  60. * Report endstop positions in response to M119
  61. */
  62. void M119();
  63. // Enable / disable endstop checking globally
  64. FORCE_INLINE void enable_globally(bool onoff=true) { enabled_globally = enabled = onoff; }
  65. // Enable / disable endstop checking
  66. FORCE_INLINE void enable(bool onoff=true) { enabled = onoff; }
  67. // Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
  68. FORCE_INLINE void not_homing() { enabled = enabled_globally; }
  69. // Clear endstops (i.e., they were hit intentionally) to suppress the report
  70. FORCE_INLINE void hit_on_purpose() { endstop_hit_bits = 0; }
  71. // Enable / disable endstop z-probe checking
  72. #if HAS_BED_PROBE
  73. volatile bool z_probe_enabled = false;
  74. FORCE_INLINE void enable_z_probe(bool onoff=true) { z_probe_enabled = onoff; }
  75. #endif
  76. private:
  77. #if ENABLED(Z_DUAL_ENDSTOPS)
  78. void test_dual_z_endstops(EndstopEnum es1, EndstopEnum es2);
  79. #endif
  80. };
  81. extern Endstops endstops;
  82. #endif // ENDSTOPS_H