♻️ Minimize endstop bits
This commit is contained in:
committed by
Scott Lahteine
parent
18b1ccda27
commit
02f904dbf9
@@ -56,12 +56,12 @@ Endstops endstops;
|
||||
// private:
|
||||
|
||||
bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.load()
|
||||
volatile uint8_t Endstops::hit_state;
|
||||
|
||||
Endstops::esbits_t Endstops::live_state = 0;
|
||||
volatile Endstops::endstop_mask_t Endstops::hit_state;
|
||||
Endstops::endstop_mask_t Endstops::live_state = 0;
|
||||
|
||||
#if ENDSTOP_NOISE_THRESHOLD
|
||||
Endstops::esbits_t Endstops::validated_live_state;
|
||||
Endstops::endstop_mask_t Endstops::validated_live_state;
|
||||
uint8_t Endstops::endstop_poll_count;
|
||||
#endif
|
||||
|
||||
@@ -356,7 +356,7 @@ void Endstops::resync() {
|
||||
#endif
|
||||
|
||||
void Endstops::event_handler() {
|
||||
static uint8_t prev_hit_state; // = 0
|
||||
static endstop_mask_t prev_hit_state; // = 0
|
||||
if (hit_state == prev_hit_state) return;
|
||||
prev_hit_state = hit_state;
|
||||
if (hit_state) {
|
||||
@@ -364,15 +364,14 @@ void Endstops::event_handler() {
|
||||
char chrX = ' ', chrY = ' ', chrZ = ' ', chrP = ' ';
|
||||
#define _SET_STOP_CHAR(A,C) (chr## A = C)
|
||||
#else
|
||||
#define _SET_STOP_CHAR(A,C) ;
|
||||
#define _SET_STOP_CHAR(A,C) NOOP
|
||||
#endif
|
||||
|
||||
#define _ENDSTOP_HIT_ECHO(A,C) do{ \
|
||||
SERIAL_ECHOPAIR(" " STRINGIFY(A) ":", planner.triggered_position_mm(_AXIS(A))); \
|
||||
_SET_STOP_CHAR(A,C); }while(0)
|
||||
SERIAL_ECHOPAIR(" " STRINGIFY(A) ":", planner.triggered_position_mm(_AXIS(A))); _SET_STOP_CHAR(A,C); }while(0)
|
||||
|
||||
#define _ENDSTOP_HIT_TEST(A,C) \
|
||||
if (TEST(hit_state, A ##_MIN) || TEST(hit_state, A ##_MAX)) \
|
||||
if (TERN0(HAS_##A##_MIN, TEST(hit_state, A##_MIN)) || TERN0(HAS_##A##_MAX, TEST(hit_state, A##_MAX))) \
|
||||
_ENDSTOP_HIT_ECHO(A,C)
|
||||
|
||||
#define ENDSTOP_HIT_TEST_X() _ENDSTOP_HIT_TEST(X,'X')
|
||||
@@ -659,7 +658,7 @@ void Endstops::update() {
|
||||
* still exist. The only way to reduce them further is to increase the number of samples.
|
||||
* To reduce the chance to 1% (1/128th) requires 7 samples (adding 7ms of delay).
|
||||
*/
|
||||
static esbits_t old_live_state;
|
||||
static endstop_mask_t old_live_state;
|
||||
if (old_live_state != live_state) {
|
||||
endstop_poll_count = ENDSTOP_NOISE_THRESHOLD;
|
||||
old_live_state = live_state;
|
||||
|
||||
Reference in New Issue
Block a user