123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- #ifndef __ENDSTOPS_H__
- #define __ENDSTOPS_H__
- #include "MarlinConfig.h"
- #define VALIDATE_HOMING_ENDSTOPS
- enum EndstopEnum : char {
- X_MIN,
- Y_MIN,
- Z_MIN,
- Z_MIN_PROBE,
- X_MAX,
- Y_MAX,
- Z_MAX,
- X2_MIN,
- X2_MAX,
- Y2_MIN,
- Y2_MAX,
- Z2_MIN,
- Z2_MAX
- };
- class Endstops {
- public:
- static bool enabled, enabled_globally;
- #if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
- typedef uint16_t esbits_t;
- #if ENABLED(X_DUAL_ENDSTOPS)
- static float x_endstop_adj;
- #endif
- #if ENABLED(Y_DUAL_ENDSTOPS)
- static float y_endstop_adj;
- #endif
- #if ENABLED(Z_DUAL_ENDSTOPS)
- static float z_endstop_adj;
- #endif
- #else
- typedef uint8_t esbits_t;
- #endif
- private:
- static esbits_t live_state;
- static volatile uint8_t hit_state;
- #if ENABLED(ENDSTOP_NOISE_FILTER)
- static esbits_t validated_live_state;
- static uint8_t endstop_poll_count;
- #endif
- public:
- Endstops() {};
-
- static void init();
-
- FORCE_INLINE static bool abort_enabled() {
- return (enabled
- #if HAS_BED_PROBE
- || z_probe_enabled
- #endif
- );
- }
-
- static void poll();
-
- static void update();
-
- FORCE_INLINE static uint8_t trigger_state() { return hit_state; }
-
- FORCE_INLINE static esbits_t state() {
- return
- #if ENABLED(ENDSTOP_NOISE_FILTER)
- validated_live_state
- #else
- live_state
- #endif
- ;
- }
-
- static void event_handler();
-
- static void M119();
-
- static void enable_globally(const bool onoff=true);
-
- static void enable(const bool onoff=true);
-
- static void not_homing();
- #if ENABLED(VALIDATE_HOMING_ENDSTOPS)
-
- static void validate_homing_move();
- #else
- FORCE_INLINE static void validate_homing_move() { hit_on_purpose(); }
- #endif
-
- FORCE_INLINE static void hit_on_purpose() { hit_state = 0; }
-
- #if HAS_BED_PROBE
- static volatile bool z_probe_enabled;
- static void enable_z_probe(const bool onoff=true);
- #endif
-
- #if ENABLED(PINS_DEBUGGING)
- static bool monitor_flag;
- static void monitor();
- static void run_monitor();
- #endif
- };
- extern Endstops endstops;
- #endif
|