Fix garbled M119 output. Honor NUM_RUNOUT_SENSORS (#11948)

This commit is contained in:
InsanityAutomation 2018-09-28 20:00:11 -04:00 committed by Scott Lahteine
parent 1667ed9d1c
commit 23114aeb81

View file

@ -422,43 +422,27 @@ void _O2 Endstops::M119() {
print_es_state(READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING, PSTR(MSG_Z_PROBE)); print_es_state(READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING, PSTR(MSG_Z_PROBE));
#endif #endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR) #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) + PIN_EXISTS(FIL_RUNOUT6)) #if NUM_RUNOUT_SENSORS == 1
#if FRS_COUNT == 1 print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, PSTR(MSG_FILAMENT_RUNOUT_SENSOR));
print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, MSG_FILAMENT_RUNOUT_SENSOR);
#else #else
for (uint8_t i = 1; i <= for (uint8_t i = 1; i <= NUM_RUNOUT_SENSORS; i++) {
#if FRS_COUNT == 6
6
#elif FRS_COUNT == 5
5
#elif FRS_COUNT == 4
4
#elif FRS_COUNT == 3
3
#elif FRS_COUNT == 2
2
#endif
; i++
) {
pin_t pin; pin_t pin;
switch (i) { switch (i) {
default: continue; default: continue;
case 1: pin = FIL_RUNOUT_PIN; break; case 1: pin = FIL_RUNOUT_PIN; break;
#if PIN_EXISTS(FIL_RUNOUT2)
case 2: pin = FIL_RUNOUT2_PIN; break; case 2: pin = FIL_RUNOUT2_PIN; break;
#endif #if NUM_RUNOUT_SENSORS > 2
#if PIN_EXISTS(FIL_RUNOUT3)
case 3: pin = FIL_RUNOUT3_PIN; break; case 3: pin = FIL_RUNOUT3_PIN; break;
#endif #if NUM_RUNOUT_SENSORS > 3
#if PIN_EXISTS(FIL_RUNOUT4)
case 4: pin = FIL_RUNOUT4_PIN; break; case 4: pin = FIL_RUNOUT4_PIN; break;
#endif #if NUM_RUNOUT_SENSORS > 4
#if PIN_EXISTS(FIL_RUNOUT5)
case 5: pin = FIL_RUNOUT5_PIN; break; case 5: pin = FIL_RUNOUT5_PIN; break;
#endif #if NUM_RUNOUT_SENSORS > 5
#if PIN_EXISTS(FIL_RUNOUT6)
case 6: pin = FIL_RUNOUT6_PIN; break; case 6: pin = FIL_RUNOUT6_PIN; break;
#endif #endif
#endif
#endif
#endif
} }
SERIAL_PROTOCOLPGM(MSG_FILAMENT_RUNOUT_SENSOR); SERIAL_PROTOCOLPGM(MSG_FILAMENT_RUNOUT_SENSOR);
if (i > 1) { SERIAL_CHAR(' '); SERIAL_CHAR('0' + i); } if (i > 1) { SERIAL_CHAR(' '); SERIAL_CHAR('0' + i); }