From 7b66e05f6743de79c121c1b1a37e9f19a5f03dbc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 10 Nov 2020 23:50:27 -0600 Subject: [PATCH] =?UTF-8?q?Final=20touches,=20surely=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/DUE/fastio.h | 3 +++ Marlin/src/HAL/ESP32/fastio.h | 3 +++ Marlin/src/feature/runout.h | 20 ++++++++++---------- Marlin/src/inc/Conditionals_LCD.h | 1 + 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Marlin/src/HAL/DUE/fastio.h b/Marlin/src/HAL/DUE/fastio.h index 119d0005af..5fb8b4d015 100644 --- a/Marlin/src/HAL/DUE/fastio.h +++ b/Marlin/src/HAL/DUE/fastio.h @@ -163,6 +163,9 @@ #define SET_INPUT(IO) _SET_INPUT(IO) // Set pin as input with pullup (wrapper) #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0) +// Set pin as input with pulldown (substitution) +#define SET_INPUT_PULLDOWN SET_INPUT + // Set pin as output (wrapper) - reads the pin and sets the output to that value #define SET_OUTPUT(IO) _SET_OUTPUT(IO) // Set pin as PWM diff --git a/Marlin/src/HAL/ESP32/fastio.h b/Marlin/src/HAL/ESP32/fastio.h index 2ded3a5f62..8db89dca12 100644 --- a/Marlin/src/HAL/ESP32/fastio.h +++ b/Marlin/src/HAL/ESP32/fastio.h @@ -52,6 +52,9 @@ // Set pin as input with pullup wrapper #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0) +// Set pin as input with pulldown (substitution) +#define SET_INPUT_PULLDOWN SET_INPUT + // Set pin as output wrapper #define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); }while(0) diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index dbb6e8a77f..aa1ccc9cc5 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -149,31 +149,31 @@ class FilamentSensorBase { public: static inline void setup() { - #define _INIT_RUNOUT_PIN(N,P) do{ if (DISABLED(FIL_RUNOUT##N##_PULL)) SET_INPUT(P) else if (FIL_RUNOUT##N##_STATE) SET_INPUT_PULLDOWN(P); else SET_INPUT_PULLUP(P); }while(0) - #define INIT_RUNOUT_PIN(N,P) _INIT_RUNOUT_PIN(N,P) + #define _INIT_RUNOUT_PIN(P,S,U) do{ if (DISABLED(U)) SET_INPUT(P); else if (S) SET_INPUT_PULLDOWN(P); else SET_INPUT_PULLUP(P); }while(0) + #define INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULL) #if NUM_RUNOUT_SENSORS >= 1 - INIT_RUNOUT_PIN(1, P) + INIT_RUNOUT_PIN(1); #endif #if NUM_RUNOUT_SENSORS >= 2 - INIT_RUNOUT_PIN(2, P) + INIT_RUNOUT_PIN(2); #endif #if NUM_RUNOUT_SENSORS >= 3 - INIT_RUNOUT_PIN(3, P) + INIT_RUNOUT_PIN(3); #endif #if NUM_RUNOUT_SENSORS >= 4 - INIT_RUNOUT_PIN(4, P) + INIT_RUNOUT_PIN(4); #endif #if NUM_RUNOUT_SENSORS >= 5 - INIT_RUNOUT_PIN(5, P) + INIT_RUNOUT_PIN(5); #endif #if NUM_RUNOUT_SENSORS >= 6 - INIT_RUNOUT_PIN(6, P) + INIT_RUNOUT_PIN(6); #endif #if NUM_RUNOUT_SENSORS >= 7 - INIT_RUNOUT_PIN(7, P) + INIT_RUNOUT_PIN(7); #endif #if NUM_RUNOUT_SENSORS >= 8 - INIT_RUNOUT_PIN(8, P) + INIT_RUNOUT_PIN(8); #endif #undef _INIT_RUNOUT_PIN #undef INIT_RUNOUT_PIN diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 865365c0ee..c14731172a 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -677,6 +677,7 @@ #if ENABLED(FILAMENT_RUNOUT_SENSOR) #if NUM_RUNOUT_SENSORS >= 1 + #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN #ifndef FIL_RUNOUT1_STATE #define FIL_RUNOUT1_STATE FIL_RUNOUT_STATE #endif