Proper pullup/pulldown configurability (#20242)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
Kurt Haenen
2020-11-22 00:56:56 +01:00
committed by GitHub
parent 7a04df47f2
commit ca83e1a26f
9 changed files with 102 additions and 39 deletions

View File

@ -120,12 +120,10 @@ class PrintJobRecovery {
static inline void setup() {
#if PIN_EXISTS(POWER_LOSS)
#if ENABLED(POWER_LOSS_PULL)
#if POWER_LOSS_STATE == LOW
SET_INPUT_PULLUP(POWER_LOSS_PIN);
#else
SET_INPUT_PULLDOWN(POWER_LOSS_PIN);
#endif
#if ENABLED(POWER_LOSS_PULLUP)
SET_INPUT_PULLUP(POWER_LOSS_PIN);
#elif ENABLED(POWER_LOSS_PULLDOWN)
SET_INPUT_PULLDOWN(POWER_LOSS_PIN);
#else
SET_INPUT(POWER_LOSS_PIN);
#endif

View File

@ -149,8 +149,8 @@ class FilamentSensorBase {
public:
static inline void setup() {
#define _INIT_RUNOUT_PIN(P,S,U) do{ if (DISABLED(U)) SET_INPUT(P); else if (S) SET_INPUT_PULLUP(P); else SET_INPUT_PULLDOWN(P); }while(0)
#define INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULL)
#define _INIT_RUNOUT_PIN(P,S,U,D) do{ if (ENABLED(U)) SET_INPUT_PULLUP(P); else if (ENABLED(D)) SET_INPUT_PULLDOWN(P); else SET_INPUT(P); }while(0)
#define INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULLUP, FIL_RUNOUT##N##_PULLDOWN)
#if NUM_RUNOUT_SENSORS >= 1
INIT_RUNOUT_PIN(1);
#endif

View File

@ -708,64 +708,88 @@
#ifndef FIL_RUNOUT1_STATE
#define FIL_RUNOUT1_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT1_PULL
#define FIL_RUNOUT1_PULL FIL_RUNOUT_PULL
#ifndef FIL_RUNOUT1_PULLUP
#define FIL_RUNOUT1_PULLUP FIL_RUNOUT_PULLUP
#endif
#ifndef FIL_RUNOUT1_PULLDOWN
#define FIL_RUNOUT1_PULLDOWN FIL_RUNOUT_PULLDOWN
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 2
#ifndef FIL_RUNOUT2_STATE
#define FIL_RUNOUT2_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT2_PULL
#define FIL_RUNOUT2_PULL FIL_RUNOUT_PULL
#ifndef FIL_RUNOUT2_PULLUP
#define FIL_RUNOUT2_PULLUP FIL_RUNOUT_PULLUP
#endif
#ifndef FIL_RUNOUT2_PULLDOWN
#define FIL_RUNOUT2_PULLDOWN FIL_RUNOUT_PULLDOWN
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 3
#ifndef FIL_RUNOUT3_STATE
#define FIL_RUNOUT3_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT3_PULL
#define FIL_RUNOUT3_PULL FIL_RUNOUT_PULL
#ifndef FIL_RUNOUT3_PULLUP
#define FIL_RUNOUT3_PULLUP FIL_RUNOUT_PULLUP
#endif
#ifndef FIL_RUNOUT3_PULLDOWN
#define FIL_RUNOUT3_PULLDOWN FIL_RUNOUT_PULLDOWN
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 4
#ifndef FIL_RUNOUT4_STATE
#define FIL_RUNOUT4_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT4_PULL
#define FIL_RUNOUT4_PULL FIL_RUNOUT_PULL
#ifndef FIL_RUNOUT4_PULLUP
#define FIL_RUNOUT4_PULLUP FIL_RUNOUT_PULLUP
#endif
#ifndef FIL_RUNOUT4_PULLDOWN
#define FIL_RUNOUT4_PULLDOWN FIL_RUNOUT_PULLDOWN
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 5
#ifndef FIL_RUNOUT5_STATE
#define FIL_RUNOUT5_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT5_PULL
#define FIL_RUNOUT5_PULL FIL_RUNOUT_PULL
#ifndef FIL_RUNOUT5_PULLUP
#define FIL_RUNOUT5_PULLUP FIL_RUNOUT_PULLUP
#endif
#ifndef FIL_RUNOUT5_PULLDOWN
#define FIL_RUNOUT5_PULLDOWN FIL_RUNOUT_PULLDOWN
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 6
#ifndef FIL_RUNOUT6_STATE
#define FIL_RUNOUT6_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT6_PULL
#define FIL_RUNOUT6_PULL FIL_RUNOUT_PULL
#ifndef FIL_RUNOUT6_PULLUP
#define FIL_RUNOUT6_PULLUP FIL_RUNOUT_PULLUP
#endif
#ifndef FIL_RUNOUT6_PULLDOWN
#define FIL_RUNOUT6_PULLDOWN FIL_RUNOUT_PULLDOWN
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 7
#ifndef FIL_RUNOUT7_STATE
#define FIL_RUNOUT7_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT7_PULL
#define FIL_RUNOUT7_PULL FIL_RUNOUT_PULL
#ifndef FIL_RUNOUT7_PULLUP
#define FIL_RUNOUT7_PULLUP FIL_RUNOUT_PULLUP
#endif
#ifndef FIL_RUNOUT7_PULLDOWN
#define FIL_RUNOUT7_PULLDOWN FIL_RUNOUT_PULLDOWN
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 8
#ifndef FIL_RUNOUT8_STATE
#define FIL_RUNOUT8_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT8_PULL
#define FIL_RUNOUT8_PULL FIL_RUNOUT_PULL
#ifndef FIL_RUNOUT8_PULLUP
#define FIL_RUNOUT8_PULLUP FIL_RUNOUT_PULLUP
#endif
#ifndef FIL_RUNOUT8_PULLDOWN
#define FIL_RUNOUT8_PULLDOWN FIL_RUNOUT_PULLDOWN
#endif
#endif
#endif // FILAMENT_RUNOUT_SENSOR

View File

@ -111,7 +111,7 @@
#elif defined(FILAMENT_SENSOR)
#error "FILAMENT_SENSOR is now FILAMENT_WIDTH_SENSOR."
#elif defined(ENDSTOPPULLUP_FIL_RUNOUT)
#error "ENDSTOPPULLUP_FIL_RUNOUT is now FIL_RUNOUT_PULL."
#error "ENDSTOPPULLUP_FIL_RUNOUT is now FIL_RUNOUT_PULLUP."
#elif defined(DISABLE_MAX_ENDSTOPS) || defined(DISABLE_MIN_ENDSTOPS)
#error "DISABLE_MAX_ENDSTOPS and DISABLE_MIN_ENDSTOPS deprecated. Use individual USE_*_PLUG options instead."
#elif defined(LANGUAGE_INCLUDE)
@ -525,6 +525,8 @@
#error "EVENT_GCODE_SD_STOP is now EVENT_GCODE_SD_ABORT."
#elif defined(GRAPHICAL_TFT_ROTATE_180)
#error "GRAPHICAL_TFT_ROTATE_180 is now TFT_ROTATION set to TFT_ROTATE_180."
#elif defined(POWER_LOSS_PULL)
#error "POWER_LOSS_PULL is now specifically POWER_LOSS_PULL(UP|DOWN)."
#elif defined(FIL_RUNOUT_INVERTING)
#if FIL_RUNOUT_INVERTING
#error "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_STATE HIGH."
@ -653,6 +655,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#if BOTH(ENDSTOPPULLUPS, ENDSTOPPULLDOWNS)
#error "Enable only one of ENDSTOPPULLUPS or ENDSTOPPULLDOWNS."
#elif BOTH(FIL_RUNOUT_PULLUP, FIL_RUNOUT_PULLDOWN)
#error "Enable only one of FIL_RUNOUT_PULLUP or FIL_RUNOUT_PULLDOWN."
#elif BOTH(ENDSTOPPULLUP_XMAX, ENDSTOPPULLDOWN_XMAX)
#error "Enable only one of ENDSTOPPULLUP_X_MAX or ENDSTOPPULLDOWN_X_MAX."
#elif BOTH(ENDSTOPPULLUP_YMAX, ENDSTOPPULLDOWN_YMAX)
@ -823,6 +827,22 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "FIL_RUNOUT7_PIN is required with NUM_RUNOUT_SENSORS >= 7."
#elif NUM_RUNOUT_SENSORS >= 8 && !PIN_EXISTS(FIL_RUNOUT8)
#error "FIL_RUNOUT8_PIN is required with NUM_RUNOUT_SENSORS >= 8."
#elif BOTH(FIL_RUNOUT1_PULLUP, FIL_RUNOUT1_PULLDOWN)
#error "You can't enable FIL_RUNOUT1_PULLUP and FIL_RUNOUT1_PULLDOWN at the same time."
#elif BOTH(FIL_RUNOUT2_PULLUP, FIL_RUNOUT2_PULLDOWN)
#error "You can't enable FIL_RUNOUT2_PULLUP and FIL_RUNOUT2_PULLDOWN at the same time."
#elif BOTH(FIL_RUNOUT3_PULLUP, FIL_RUNOUT3_PULLDOWN)
#error "You can't enable FIL_RUNOUT3_PULLUP and FIL_RUNOUT3_PULLDOWN at the same time."
#elif BOTH(FIL_RUNOUT4_PULLUP, FIL_RUNOUT4_PULLDOWN)
#error "You can't enable FIL_RUNOUT4_PULLUP and FIL_RUNOUT4_PULLDOWN at the same time."
#elif BOTH(FIL_RUNOUT5_PULLUP, FIL_RUNOUT5_PULLDOWN)
#error "You can't enable FIL_RUNOUT5_PULLUP and FIL_RUNOUT5_PULLDOWN at the same time."
#elif BOTH(FIL_RUNOUT6_PULLUP, FIL_RUNOUT6_PULLDOWN)
#error "You can't enable FIL_RUNOUT6_PULLUP and FIL_RUNOUT6_PULLDOWN at the same time."
#elif BOTH(FIL_RUNOUT7_PULLUP, FIL_RUNOUT7_PULLDOWN)
#error "You can't enable FIL_RUNOUT7_PULLUP and FIL_RUNOUT7_PULLDOWN at the same time."
#elif BOTH(FIL_RUNOUT8_PULLUP, FIL_RUNOUT8_PULLDOWN)
#error "You can't enable FIL_RUNOUT8_PULLUP and FIL_RUNOUT8_PULLDOWN at the same time."
#elif FILAMENT_RUNOUT_DISTANCE_MM < 0
#error "FILAMENT_RUNOUT_DISTANCE_MM must be greater than or equal to zero."
#elif DISABLED(ADVANCED_PAUSE_FEATURE)
@ -2824,6 +2844,10 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
#error "BACKUP_POWER_SUPPLY requires a POWER_LOSS_PIN."
#endif
#if BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN)
#error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time."
#endif
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
#if NUM_Z_STEPPER_DRIVERS <= 1
#error "Z_STEPPER_AUTO_ALIGN requires NUM_Z_STEPPER_DRIVERS greater than 1."

View File

@ -77,7 +77,7 @@ namespace Anycubic {
// Filament runout is handled by Marlin settings in Configuration.h
// opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present.
// opt_enable FIL_RUNOUT_PULL
// opt_enable FIL_RUNOUT_PULLUP
TFTSer.begin(115200);