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.

endstops.h 3.1KB

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