Fix interrupt-based endstop detection
This commit is contained in:
parent
d2f8971045
commit
3a4a229721
9 changed files with 332 additions and 283 deletions
|
|
@ -29,12 +29,28 @@
|
|||
|
||||
#include "MarlinConfig.h"
|
||||
|
||||
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;
|
||||
static volatile char endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
|
||||
static volatile uint8_t endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
|
||||
typedef uint16_t esbits_t;
|
||||
|
|
@ -51,23 +67,26 @@ class Endstops {
|
|||
typedef byte esbits_t;
|
||||
#endif
|
||||
|
||||
static esbits_t current_endstop_bits, old_endstop_bits;
|
||||
static esbits_t current_endstop_bits;
|
||||
|
||||
Endstops() {
|
||||
enable_globally(
|
||||
#if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
|
||||
true
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
);
|
||||
};
|
||||
Endstops() {};
|
||||
|
||||
/**
|
||||
* Initialize the endstop pins
|
||||
*/
|
||||
static void init();
|
||||
|
||||
/**
|
||||
* A change was detected or presumed to be in endstops pins. Find out what
|
||||
* changed, if anything. Called from ISR contexts
|
||||
*/
|
||||
static void check_possible_change();
|
||||
|
||||
/**
|
||||
* Periodic call to poll endstops if required. Called from temperature ISR
|
||||
*/
|
||||
static void poll();
|
||||
|
||||
/**
|
||||
* Update the endstops bits from the pins
|
||||
*/
|
||||
|
|
@ -84,21 +103,28 @@ class Endstops {
|
|||
static void M119();
|
||||
|
||||
// Enable / disable endstop checking globally
|
||||
static void enable_globally(bool onoff=true) { enabled_globally = enabled = onoff; }
|
||||
static void enable_globally(const bool onoff=true);
|
||||
|
||||
// Enable / disable endstop checking
|
||||
static void enable(bool onoff=true) { enabled = onoff; }
|
||||
static void enable(const bool onoff=true);
|
||||
|
||||
// Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
|
||||
static void not_homing() { enabled = enabled_globally; }
|
||||
static void not_homing();
|
||||
|
||||
// Clear endstops (i.e., they were hit intentionally) to suppress the report
|
||||
static void hit_on_purpose() { endstop_hit_bits = 0; }
|
||||
static void hit_on_purpose();
|
||||
|
||||
// Enable / disable endstop z-probe checking
|
||||
#if HAS_BED_PROBE
|
||||
static volatile bool z_probe_enabled;
|
||||
static void enable_z_probe(bool onoff=true) { z_probe_enabled = onoff; }
|
||||
static void enable_z_probe(bool onoff=true);
|
||||
#endif
|
||||
|
||||
// Debugging of endstops
|
||||
#if ENABLED(PINS_DEBUGGING)
|
||||
static bool monitor_flag;
|
||||
static void monitor();
|
||||
static void run_monitor();
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
@ -116,10 +142,4 @@ class Endstops {
|
|||
|
||||
extern Endstops endstops;
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#define ENDSTOPS_ENABLED (endstops.enabled || endstops.z_probe_enabled)
|
||||
#else
|
||||
#define ENDSTOPS_ENABLED endstops.enabled
|
||||
#endif
|
||||
|
||||
#endif // __ENDSTOPS_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue