From 501b8374fdc56f8c583955ee050fa8572ace2b62 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 28 Sep 2018 19:19:45 -0500 Subject: [PATCH] Fix garbled M119 output, honor NUM_RUNOUT_SENSORS --- Marlin/endstops.cpp | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index 3480e9828b..39fbc80134 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -358,37 +358,23 @@ void _O2 Endstops::M119() { print_es_state(READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING, PSTR(MSG_Z_PROBE)); #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) - #define FRS_COUNT (1 + PIN_EXISTS(FIL_RUNOUT2) + PIN_EXISTS(FIL_RUNOUT3) + PIN_EXISTS(FIL_RUNOUT4) + PIN_EXISTS(FIL_RUNOUT5)) - #if FRS_COUNT == 1 - print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, MSG_FILAMENT_RUNOUT_SENSOR); + #if NUM_RUNOUT_SENSORS == 1 + print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, PSTR(MSG_FILAMENT_RUNOUT_SENSOR)); #else - for (uint8_t i = 1; i <= - #if FRS_COUNT == 5 - 5 - #elif FRS_COUNT == 4 - 4 - #elif FRS_COUNT == 3 - 3 - #elif FRS_COUNT == 2 - 2 - #endif - ; i++ - ) { + for (uint8_t i = 1; i <= NUM_RUNOUT_SENSORS; i++) { pin_t pin; switch (i) { default: continue; case 1: pin = FIL_RUNOUT_PIN; break; - #if PIN_EXISTS(FIL_RUNOUT2) - case 2: pin = FIL_RUNOUT2_PIN; break; - #endif - #if PIN_EXISTS(FIL_RUNOUT3) + case 2: pin = FIL_RUNOUT2_PIN; break; + #if NUM_RUNOUT_SENSORS > 2 case 3: pin = FIL_RUNOUT3_PIN; break; - #endif - #if PIN_EXISTS(FIL_RUNOUT4) - case 4: pin = FIL_RUNOUT4_PIN; break; - #endif - #if PIN_EXISTS(FIL_RUNOUT5) - case 5: pin = FIL_RUNOUT5_PIN; break; + #if NUM_RUNOUT_SENSORS > 3 + case 4: pin = FIL_RUNOUT4_PIN; break; + #if NUM_RUNOUT_SENSORS > 4 + case 5: pin = FIL_RUNOUT5_PIN; break; + #endif + #endif #endif } SERIAL_PROTOCOLPGM(MSG_FILAMENT_RUNOUT_SENSOR);