Prusa MINI Firmware overview
|
#include <endstops.h>
◆ esbits_t
◆ Endstops()
◆ init()
Initialize the endstop pins
Class and Instance Methods
97 #if ENABLED(ENDSTOPPULLUP_XMIN)
99 #elif ENABLED(ENDSTOPPULLDOWN_XMIN)
107 #if ENABLED(ENDSTOPPULLUP_XMIN)
109 #elif ENABLED(ENDSTOPPULLDOWN_XMIN)
117 #if ENABLED(ENDSTOPPULLUP_YMIN)
119 #elif ENABLED(ENDSTOPPULLDOWN_YMIN)
127 #if ENABLED(ENDSTOPPULLUP_YMIN)
129 #elif ENABLED(ENDSTOPPULLDOWN_YMIN)
137 #if ENABLED(ENDSTOPPULLUP_ZMIN)
139 #elif ENABLED(ENDSTOPPULLDOWN_ZMIN)
147 #if ENABLED(ENDSTOPPULLUP_ZMIN)
149 #elif ENABLED(ENDSTOPPULLDOWN_ZMIN)
157 #if ENABLED(ENDSTOPPULLUP_ZMIN)
159 #elif ENABLED(ENDSTOPPULLDOWN_ZMIN)
167 #if ENABLED(ENDSTOPPULLUP_XMAX)
169 #elif ENABLED(ENDSTOPPULLDOWN_XMAX)
177 #if ENABLED(ENDSTOPPULLUP_XMAX)
179 #elif ENABLED(ENDSTOPPULLDOWN_XMAX)
187 #if ENABLED(ENDSTOPPULLUP_YMAX)
189 #elif ENABLED(ENDSTOPPULLDOWN_YMAX)
197 #if ENABLED(ENDSTOPPULLUP_YMAX)
199 #elif ENABLED(ENDSTOPPULLDOWN_YMAX)
207 #if ENABLED(ENDSTOPPULLUP_ZMAX)
209 #elif ENABLED(ENDSTOPPULLDOWN_ZMAX)
217 #if ENABLED(ENDSTOPPULLUP_ZMAX)
219 #elif ENABLED(ENDSTOPPULLDOWN_ZMAX)
227 #if ENABLED(ENDSTOPPULLUP_ZMAX)
229 #elif ENABLED(ENDSTOPPULLDOWN_ZMAX)
236 #if HAS_CALIBRATION_PIN
237 #if ENABLED(CALIBRATION_PIN_PULLUP)
239 #elif ENABLED(CALIBRATION_PIN_PULLDOWN)
246 #if HAS_CUSTOM_PROBE_PIN
247 #if ENABLED(ENDSTOPPULLUP_ZMIN_PROBE)
249 #elif ENABLED(ENDSTOPPULLDOWN_ZMIN_PROBE)
256 #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
262 #
if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
◆ abort_enabled()
Are endstops or the probe set to abort the move?
◆ global_enabled()
static bool Endstops::global_enabled |
( |
| ) |
|
|
static |
89 {
return enabled_globally; }
◆ poll()
Periodic call to poll endstops if required. Called from temperature ISR
274 #if ENABLED(PINS_DEBUGGING)
278 #if DISABLED(ENDSTOP_INTERRUPTS_FEATURE)
280 #elif ENDSTOP_NOISE_THRESHOLD
281 if (endstop_poll_count)
update();
◆ update()
void Endstops::update |
( |
| ) |
|
|
static |
Update endstops bits from the pins. Apply filtering to get a verified state. If abort_enabled() and moving towards a triggered switch, abort the current move. Called from ISR contexts.
Check and update endstops
498 #if !ENDSTOP_NOISE_THRESHOLD
502 #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
503 #define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT))
505 #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ)
511 #if ENABLED(DUAL_X_CARRIAGE)
512 #define E0_ACTIVE stepper.movement_extruder() == 0
513 #define X_MIN_TEST ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE))
514 #define X_MAX_TEST ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE))
516 #define X_MIN_TEST true
517 #define X_MAX_TEST true
521 #if CORE_IS_XY || CORE_IS_XZ
522 #define X_AXIS_HEAD X_HEAD
524 #define X_AXIS_HEAD X_AXIS
526 #if CORE_IS_XY || CORE_IS_YZ
527 #define Y_AXIS_HEAD Y_HEAD
529 #define Y_AXIS_HEAD Y_AXIS
531 #if CORE_IS_XZ || CORE_IS_YZ
532 #define Z_AXIS_HEAD Z_HEAD
534 #define Z_AXIS_HEAD Z_AXIS
540 #if HAS_X_MIN && !X_SPI_SENSORLESS
542 #if ENABLED(X_DUAL_ENDSTOPS)
551 #if HAS_X_MAX && !X_SPI_SENSORLESS
553 #if ENABLED(X_DUAL_ENDSTOPS)
562 #if HAS_Y_MIN && !Y_SPI_SENSORLESS
564 #if ENABLED(Y_DUAL_ENDSTOPS)
573 #if HAS_Y_MAX && !Y_SPI_SENSORLESS
575 #if ENABLED(Y_DUAL_ENDSTOPS)
584 #if HAS_Z_MIN && !Z_SPI_SENSORLESS
592 #if ENABLED(Z_TRIPLE_ENDSTOPS)
603 #if HAS_CUSTOM_PROBE_PIN
607 #if HAS_Z_MAX && !Z_SPI_SENSORLESS
616 #if ENABLED(Z_TRIPLE_ENDSTOPS)
623 #elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN
629 #if ENDSTOP_NOISE_THRESHOLD
642 if (old_live_state != live_state) {
643 endstop_poll_count = ENDSTOP_NOISE_THRESHOLD;
644 old_live_state = live_state;
646 else if (endstop_poll_count && !--endstop_poll_count)
647 validated_live_state = live_state;
654 #define TEST_ENDSTOP(ENDSTOP) (TEST(state(), ENDSTOP))
657 #define _ENDSTOP_HIT(AXIS, MINMAX) SBI(hit_state, _ENDSTOP(AXIS, MINMAX))
660 #define PROCESS_ENDSTOP(AXIS,MINMAX) do { \
661 if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX))) { \
662 _ENDSTOP_HIT(AXIS, MINMAX); \
663 planner.endstop_triggered(_AXIS(AXIS)); \
668 #define PROCESS_DUAL_ENDSTOP(AXIS1, AXIS2, MINMAX) do { \
669 const byte dual_hit = TEST_ENDSTOP(_ENDSTOP(AXIS1, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(AXIS2, MINMAX)) << 1); \
671 _ENDSTOP_HIT(AXIS1, MINMAX); \
673 if (!stepper.separate_multi_axis || dual_hit == 0b11) \
674 planner.endstop_triggered(_AXIS(AXIS1)); \
678 #define PROCESS_TRIPLE_ENDSTOP(AXIS1, AXIS2, AXIS3, MINMAX) do { \
679 const byte triple_hit = TEST_ENDSTOP(_ENDSTOP(AXIS1, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(AXIS2, MINMAX)) << 1) | (TEST_ENDSTOP(_ENDSTOP(AXIS3, MINMAX)) << 2); \
681 _ENDSTOP_HIT(AXIS1, MINMAX); \
683 if (!stepper.separate_multi_axis || triple_hit == 0b111) \
684 planner.endstop_triggered(_AXIS(AXIS1)); \
688 #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ)
689 #if ENABLED(G38_PROBE_AWAY)
690 #define _G38_OPEN_STATE (G38_move >= 4)
692 #define _G38_OPEN_STATE LOW
699 G38_did_trigger =
true;
706 #if HAS_X_MIN || (X_SPI_SENSORLESS && X_HOME_DIR < 0)
707 #if ENABLED(X_DUAL_ENDSTOPS)
715 #if HAS_X_MAX || (X_SPI_SENSORLESS && X_HOME_DIR > 0)
716 #if ENABLED(X_DUAL_ENDSTOPS)
727 #if HAS_Y_MIN || (Y_SPI_SENSORLESS && Y_HOME_DIR < 0)
728 #if ENABLED(Y_DUAL_ENDSTOPS)
736 #if HAS_Y_MAX || (Y_SPI_SENSORLESS && Y_HOME_DIR > 0)
737 #if ENABLED(Y_DUAL_ENDSTOPS)
748 #if HAS_Z_MIN || (Z_SPI_SENSORLESS && Z_HOME_DIR < 0)
749 #if ENABLED(Z_TRIPLE_ENDSTOPS)
751 #elif ENABLED(Z_DUAL_ENDSTOPS)
754 #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
756 #elif HAS_CUSTOM_PROBE_PIN
765 #if HAS_CUSTOM_PROBE_PIN
770 #if HAS_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_DIR > 0)
771 #if ENABLED(Z_TRIPLE_ENDSTOPS)
773 #elif ENABLED(Z_DUAL_ENDSTOPS)
775 #elif !HAS_CUSTOM_PROBE_PIN || Z_MAX_PIN != Z_MIN_PROBE_PIN
◆ trigger_state()
Get Endstop hit state.
106 {
return hit_state; }
◆ state()
Get current endstops state
113 #if ENDSTOP_NOISE_THRESHOLD
◆ event_handler()
void Endstops::event_handler |
( |
| ) |
|
|
static |
Report endstop hits to serial. Called from loop().
343 if (hit_state && hit_state != prev_hit_state) {
345 char chrX =
' ', chrY =
' ', chrZ =
' ', chrP =
' ';
346 #define _SET_STOP_CHAR(A,C) (chr## A = C)
348 #define _SET_STOP_CHAR(A,C) ;
351 #define _ENDSTOP_HIT_ECHO(A,C) do{ \
352 SERIAL_ECHOPAIR(" " STRINGIFY(A) ":", planner.triggered_position_mm(_AXIS(A))); \
353 _SET_STOP_CHAR(A,C); }while(0)
355 #define _ENDSTOP_HIT_TEST(A,C) \
356 if (TEST(hit_state, A ##_MIN) || TEST(hit_state, A ##_MAX)) \
357 _ENDSTOP_HIT_ECHO(A,C)
359 #define ENDSTOP_HIT_TEST_X() _ENDSTOP_HIT_TEST(X,'X')
360 #define ENDSTOP_HIT_TEST_Y() _ENDSTOP_HIT_TEST(Y,'Y')
361 #define ENDSTOP_HIT_TEST_Z() _ENDSTOP_HIT_TEST(Z,'Z')
369 #if HAS_CUSTOM_PROBE_PIN
370 #define P_AXIS Z_AXIS
376 ui.status_printf_P(0,
PSTR(
S_FMT " %c %c %c %c"),
GET_TEXT(MSG_LCD_ENDSTOPS), chrX, chrY, chrZ, chrP);
379 #if BOTH(SD_ABORT_ON_ENDSTOP_HIT, SDSUPPORT)
380 if (
planner.abort_on_endstop_hit) {
388 prev_hit_state = hit_state;
◆ M119()
Report endstop positions in response to M119
403 #define ES_REPORT(S) print_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING, PSTR(MSG_##S))
446 #if HAS_CUSTOM_PROBE_PIN
449 #if HAS_FILAMENT_SENSOR
450 #if NUM_RUNOUT_SENSORS == 1
459 #if NUM_RUNOUT_SENSORS > 2
460 case 3: pin = FIL_RUNOUT3_PIN;
break;
461 #if NUM_RUNOUT_SENSORS > 3
462 case 4: pin = FIL_RUNOUT4_PIN;
break;
463 #if NUM_RUNOUT_SENSORS > 4
464 case 5: pin = FIL_RUNOUT5_PIN;
break;
465 #if NUM_RUNOUT_SENSORS > 5
466 case 6: pin = FIL_RUNOUT6_PIN;
break;
482 #if ENABLED(JOYSTICK_DEBUG)
◆ enable_globally()
void Endstops::enable_globally |
( |
const bool |
onoff = true | ) |
|
|
static |
286 enabled_globally = enabled = onoff;
◆ enable()
void Endstops::enable |
( |
const bool |
onoff = true | ) |
|
|
static |
◆ not_homing()
void Endstops::not_homing |
( |
| ) |
|
|
static |
298 enabled = enabled_globally;
◆ validate_homing_move()
◆ hit_on_purpose()
◆ resync()
void Endstops::resync |
( |
| ) |
|
|
static |
321 #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
326 #if ENDSTOP_NOISE_THRESHOLD
◆ z2_endstop_adj
float Endstops::z2_endstop_adj |
|
static |
#define GET_TEXT(MSG)
Definition: multi_language.h:72
#define SERIAL_CHAR(x)
Definition: serial.h:69
Definition: endstops.h:36
static void resync()
Definition: endstops.cpp:318
#define _ENDSTOP(AXIS, MINMAX)
Definition: endstops.cpp:491
#define PROCESS_ENDSTOP(AXIS, MINMAX)
#define _ENDSTOP_HIT_ECHO(A, C)
#define MSG_Z_PROBE
Definition: language.h:198
static FORCE_INLINE bool abort_enabled()
Definition: endstops.h:81
#define SET_INPUT_PULLDOWN(IO)
set pin as input with pulldown wrapper
Definition: fastio.h:95
static FORCE_INLINE bool axis_is_moving(const AxisEnum axis)
Definition: stepper.h:381
Stepper stepper
Definition: stepper.cpp:82
#define MIN(a, b)
Definition: usbd_def.h:265
Stopwatch print_job_timer
Definition: printcounter.cpp:63
Definition: endstops.h:36
#define MSG_ENDSTOPS_HIT
Definition: language.h:241
#define extDigitalRead(IO)
Definition: fastio.h:92
static FORCE_INLINE bool motor_direction(const AxisEnum axis)
Definition: stepper.h:378
Definition: endstops.h:32
Definition: endstops.h:33
uint8_t i
Definition: screen_test_graph.c:72
Definition: endstops.h:33
Definition: L6470_Marlin.h:30
#define FIL_RUNOUT2_PIN
Definition: pins_GT2560_V3.h:83
Definition: endstops.h:35
#define X_MIN_PIN
Definition: pins_ESP32.h:45
static FORCE_INLINE void _reset_SW_mode()
Definition: bltouch.h:82
#define PROCESS_TRIPLE_ENDSTOP(AXIS1, AXIS2, AXIS3, MINMAX)
#define SERIAL_ECHO_START()
Definition: serial.h:179
static bool stop()
Stop the stopwatch.
Definition: stopwatch.cpp:36
static void endstop_triggered(const AxisEnum axis)
Definition: planner.cpp:1508
Definition: L6470_Marlin.h:30
#define _ENDSTOP_HIT(AXIS, MINMAX)
#define MAX(a, b)
Definition: usbd_def.h:266
Definition: L6470_Marlin.h:30
static FORCE_INLINE void _set_SW_mode()
Definition: bltouch.h:81
#define SET_INPUT_PULLUP(IO)
Definition: fastio.h:100
Definition: endstops.h:35
int8_t pin_t
Definition: HAL.h:65
#define UPDATE_ENDSTOP_BIT(AXIS, MINMAX)
Definition: endstops.h:37
#define PSTR(str)
Definition: pgmspace.h:31
#define SET_INPUT(IO)
Definition: fastio.h:99
Definition: endstops.h:32
Definition: L6470_Marlin.h:30
static void print_es_state(const bool is_hit, PGM_P const label=nullptr)
Definition: endstops.cpp:391
Definition: endstops.h:34
#define Y_MIN_PIN
Definition: pins_ESP32.h:46
#define Y_MAX_PIN
Definition: pins_RAMPS_LINUX.h:78
#define ENDSTOP_HIT_TEST_Y()
#define SERIAL_ECHOPGM(S)
Definition: serial.h:173
#define Z_MIN_PROBE_ENDSTOP_INVERTING
Definition: Configuration_A3ides_2209_MINI.h:611
#define ENDSTOP_HIT_TEST_Z()
#define NUM_RUNOUT_SENSORS
Definition: pins_FORMBOT_TREX3.h:132
static void disable_all_heaters()
Definition: temperature.cpp:1926
const uint8_t[]
Definition: 404_html.c:3
Definition: L6470_Marlin.h:30
#define MSG_FILAMENT_RUNOUT_SENSOR
Definition: language.h:199
#define FIL_RUNOUT_PIN
Definition: pins_RAMPS_LINUX.h:216
#define HAS_BED_PROBE
Definition: Conditionals_LCD.h:500
#define X_MAX_PIN
Definition: pins_RAMPS_LINUX.h:75
#define Z_MIN_PROBE_PIN
Definition: pins_RAMPS_LINUX.h:86
#define Z_MIN_PIN
Definition: pins_ESP32.h:47
Definition: endstops.h:32
#define COPY_LIVE_STATE(SRC_BIT, DST_BIT)
static void enable_globally(const bool onoff=true)
Definition: endstops.cpp:285
#define SERIAL_EOL()
Definition: serial.h:181
#define ENDSTOP_HIT_TEST_X()
void quickstop_stepper()
Definition: Marlin.cpp:272
Definition: endstops.h:34
#define TEST(n, b)
Definition: macros.h:81
void safe_delay(millis_t ms)
Definition: utility.cpp:28
static void update()
Definition: endstops.cpp:496
#define PROCESS_DUAL_ENDSTOP(AXIS1, AXIS2, MINMAX)
Definition: endstops.h:33
Definition: endstops.h:37
#define S_FMT
Definition: macros.h:68
#define SERIAL_ECHOLNPGM(S)
Definition: serial.h:174
uint16_t esbits_t
Definition: endstops.h:43
Definition: L6470_Marlin.h:30
#define TEST_ENDSTOP(ENDSTOP)
#define READ(IO)
Definition: fastio.h:95
Definition: L6470_Marlin.h:30
Definition: endstops.h:32
Temperature thermalManager
Definition: temperature.cpp:89
static FORCE_INLINE void hit_on_purpose()
Definition: endstops.h:148
#define MSG_M119_REPORT
Definition: language.h:212
void setup_endstop_interrupts()
Definition: endstop_interrupts.h:105
#define ENABLED(V...)
Definition: macros.h:177
Planner planner
Definition: planner.cpp:111
#define Z_MAX_PIN
Definition: pins_RAMPS_LINUX.h:80