From a6fea31697b0799220ca2a8171485d3350a25ebc Mon Sep 17 00:00:00 2001 From: X-Dron Date: Fri, 6 Nov 2020 07:49:12 +0300 Subject: [PATCH] LED Switch and minor config update --- Marlin/Configuration.h | 2 +- Marlin/Configuration_adv.h | 6 ++--- Marlin/src/MarlinCore.cpp | 23 +++++++++++++++++++ Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h | 7 +++++- .../src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 7 +++++- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 403e281b42..d2504207ec 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1162,7 +1162,7 @@ // Travel limits (mm) after homing, corresponding to endstop positions. #define X_MIN_POS 0 -#define Y_MIN_POS -4 +#define Y_MIN_POS -2 #define Z_MIN_POS 0 #define X_MAX_POS X_BED_SIZE + X_MIN_POS #define Y_MAX_POS Y_BED_SIZE + Y_MIN_POS diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index c68605cd27..0c4e2a1f52 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1612,9 +1612,9 @@ #define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement). //#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA! #define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way - //#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps - #define BABYSTEP_MULTIPLICATOR_Z 10 // (steps or mm) Steps or millimeter distance for each Z babystep - #define BABYSTEP_MULTIPLICATOR_XY 10 // (steps or mm) Steps or millimeter distance for each XY babystep + #define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps + #define BABYSTEP_MULTIPLICATOR_Z 0.01 // (steps or mm) Steps or millimeter distance for each Z babystep + //#define BABYSTEP_MULTIPLICATOR_XY 10 // (steps or mm) Steps or millimeter distance for each XY babystep #define DOUBLECLICK_FOR_Z_BABYSTEPPING // Double-click on the Status Screen for Z Babystepping. #if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 5cea9cb58f..1141740efb 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -268,6 +268,11 @@ bool wait_for_heatup = true; * ******************************** FUNCTIONS ******************************** * *************************************************************************** */ +#ifdef LED_SW_PIN + void setup_LED_SW_pin() { + SET_INPUT_PULLDOWN(LED_SW_PIN); + } +#endif void setup_killpin() { #if HAS_KILL @@ -559,6 +564,20 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { } #endif + #ifdef LED_SW_PIN + static int LedSw_Count = 0; // make the inactivity button a bit less responsive + const int LED_SW_DELAY = 100; + bool led_pin_status = !READ(LED_SW_PIN); + if (led_pin_status && LedSw_Count <= LED_SW_DELAY) + LedSw_Count++; + else if (!led_pin_status) + LedSw_Count = 0; + if (LedSw_Count == LED_SW_DELAY){ + caselight.on = !caselight.on; + caselight.update(true); + } + #endif + #if HAS_HOME // Handle a standalone HOME button constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL; @@ -1001,6 +1020,10 @@ void setup() { #endif SETUP_RUN(setup_killpin()); + + #ifdef LED_SW_PIN + SETUP_RUN(setup_LED_SW_pin()); + #endif #if HAS_TMC220x SETUP_RUN(tmc_serial_begin()); diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index 1e23089e74..c22b2df5d4 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -168,7 +168,12 @@ BlTouch //#define POWER_LOSS_PIN PA2 // PW_DET //#define PS_ON_PIN PB2 // PW_OFF #define FIL_RUNOUT_PIN PA4 - #define FIL_RUNOUT2_PIN PE6 + #ifdef CASE_LED_INSTEAD_E1 + //#define LED_SW_PIN PE6 + #endif + #ifndef LED_SW_PIN + #define FIL_RUNOUT2_PIN PE6 + #endif #endif // diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 3fa07f1a5d..5fde0b0d0f 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -236,7 +236,12 @@ https://easyeda.com/sst78rust/fb4s-led-control //#define POWER_LOSS_PIN PA2 // PW_DET //#define PS_ON_PIN PB2 // PW_OFF #define FIL_RUNOUT_PIN PA4 - #define FIL_RUNOUT2_PIN PE6 + #ifdef CASE_LED_INSTEAD_E1 + #define LED_SW_PIN PE6 + #endif + #ifndef LED_SW_PIN + #define FIL_RUNOUT2_PIN PE6 + #endif #endif #define SERVO0_PIN PA8 // Enable BLTOUCH