Support more filament runout sensors in M119 (#11851)
This commit is contained in:
		@@ -139,25 +139,25 @@
 | 
				
			|||||||
#define MSG_RESEND                          "Resend: "
 | 
					#define MSG_RESEND                          "Resend: "
 | 
				
			||||||
#define MSG_UNKNOWN_COMMAND                 "Unknown command: \""
 | 
					#define MSG_UNKNOWN_COMMAND                 "Unknown command: \""
 | 
				
			||||||
#define MSG_ACTIVE_EXTRUDER                 "Active Extruder: "
 | 
					#define MSG_ACTIVE_EXTRUDER                 "Active Extruder: "
 | 
				
			||||||
#define MSG_X_MIN                           "x_min: "
 | 
					#define MSG_X_MIN                           "x_min"
 | 
				
			||||||
#define MSG_X_MAX                           "x_max: "
 | 
					#define MSG_X_MAX                           "x_max"
 | 
				
			||||||
#define MSG_X2_MIN                          "x2_min: "
 | 
					#define MSG_X2_MIN                          "x2_min"
 | 
				
			||||||
#define MSG_X2_MAX                          "x2_max: "
 | 
					#define MSG_X2_MAX                          "x2_max"
 | 
				
			||||||
#define MSG_Y_MIN                           "y_min: "
 | 
					#define MSG_Y_MIN                           "y_min"
 | 
				
			||||||
#define MSG_Y_MAX                           "y_max: "
 | 
					#define MSG_Y_MAX                           "y_max"
 | 
				
			||||||
#define MSG_Y2_MIN                          "y2_min: "
 | 
					#define MSG_Y2_MIN                          "y2_min"
 | 
				
			||||||
#define MSG_Y2_MAX                          "y2_max: "
 | 
					#define MSG_Y2_MAX                          "y2_max"
 | 
				
			||||||
#define MSG_Z_MIN                           "z_min: "
 | 
					#define MSG_Z_MIN                           "z_min"
 | 
				
			||||||
#define MSG_Z_MAX                           "z_max: "
 | 
					#define MSG_Z_MAX                           "z_max"
 | 
				
			||||||
#define MSG_Z2_MIN                          "z2_min: "
 | 
					#define MSG_Z2_MIN                          "z2_min"
 | 
				
			||||||
#define MSG_Z2_MAX                          "z2_max: "
 | 
					#define MSG_Z2_MAX                          "z2_max"
 | 
				
			||||||
#define MSG_Z3_MIN                          "z3_min: "
 | 
					#define MSG_Z3_MIN                          "z3_min"
 | 
				
			||||||
#define MSG_Z3_MAX                          "z3_max: "
 | 
					#define MSG_Z3_MAX                          "z3_max"
 | 
				
			||||||
#define MSG_Z_PROBE                         "z_probe: "
 | 
					#define MSG_Z_PROBE                         "z_probe"
 | 
				
			||||||
 | 
					#define MSG_FILAMENT_RUNOUT_SENSOR          "filament"
 | 
				
			||||||
#define MSG_PROBE_Z_OFFSET                  "Probe Z Offset"
 | 
					#define MSG_PROBE_Z_OFFSET                  "Probe Z Offset"
 | 
				
			||||||
#define MSG_SKEW_MIN                        "min_skew_factor: "
 | 
					#define MSG_SKEW_MIN                        "min_skew_factor: "
 | 
				
			||||||
#define MSG_SKEW_MAX                        "max_skew_factor: "
 | 
					#define MSG_SKEW_MAX                        "max_skew_factor: "
 | 
				
			||||||
#define MSG_FILAMENT_RUNOUT_SENSOR          "filament: "
 | 
					 | 
				
			||||||
#define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
 | 
					#define MSG_ERR_MATERIAL_INDEX              "M145 S<index> out of range (0-1)"
 | 
				
			||||||
#define MSG_ERR_M355_NONE                   "No case light"
 | 
					#define MSG_ERR_M355_NONE                   "No case light"
 | 
				
			||||||
#define MSG_ERR_M421_PARAMETERS             "M421 incorrect parameter usage"
 | 
					#define MSG_ERR_M421_PARAMETERS             "M421 incorrect parameter usage"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -358,12 +358,16 @@ void Endstops::event_handler() {
 | 
				
			|||||||
  prev_hit_state = hit_state;
 | 
					  prev_hit_state = hit_state;
 | 
				
			||||||
} // Endstops::report_state
 | 
					} // Endstops::report_state
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Endstops::M119() {
 | 
					static void print_es_state(const bool is_hit, const char * const label=NULL) {
 | 
				
			||||||
 | 
					  if (label) serialprintPGM(label);
 | 
				
			||||||
 | 
					  SERIAL_PROTOCOLPGM(": ");
 | 
				
			||||||
 | 
					  serialprintPGM(is_hit ? PSTR(MSG_ENDSTOP_HIT) : PSTR(MSG_ENDSTOP_OPEN));
 | 
				
			||||||
 | 
					  SERIAL_EOL();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void _O2 Endstops::M119() {
 | 
				
			||||||
  SERIAL_PROTOCOLLNPGM(MSG_M119_REPORT);
 | 
					  SERIAL_PROTOCOLLNPGM(MSG_M119_REPORT);
 | 
				
			||||||
  #define ES_REPORT(AXIS) do{ \
 | 
					  #define ES_REPORT(S) print_es_state(READ(S##_PIN) == S##_ENDSTOP_INVERTING, PSTR(MSG_##S))
 | 
				
			||||||
    SERIAL_PROTOCOLPGM(MSG_##AXIS); \
 | 
					 | 
				
			||||||
    SERIAL_PROTOCOLLN(((READ(AXIS##_PIN)^AXIS##_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); \
 | 
					 | 
				
			||||||
  }while(0)
 | 
					 | 
				
			||||||
  #if HAS_X_MIN
 | 
					  #if HAS_X_MIN
 | 
				
			||||||
    ES_REPORT(X_MIN);
 | 
					    ES_REPORT(X_MIN);
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
@@ -407,12 +411,52 @@ void Endstops::M119() {
 | 
				
			|||||||
    ES_REPORT(Z3_MAX);
 | 
					    ES_REPORT(Z3_MAX);
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
  #if ENABLED(Z_MIN_PROBE_ENDSTOP)
 | 
					  #if ENABLED(Z_MIN_PROBE_ENDSTOP)
 | 
				
			||||||
    SERIAL_PROTOCOLPGM(MSG_Z_PROBE);
 | 
					    print_es_state(READ(Z_MIN_PROBE_PIN) == Z_MIN_PROBE_ENDSTOP_INVERTING, PSTR(MSG_Z_PROBE));
 | 
				
			||||||
    SERIAL_PROTOCOLLN(((READ(Z_MIN_PROBE_PIN)^Z_MIN_PROBE_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
 | 
					 | 
				
			||||||
  #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 FRS_COUNT == 1
 | 
				
			||||||
 | 
					      print_es_state(READ(FIL_RUNOUT_PIN) == FIL_RUNOUT_INVERTING, MSG_FILAMENT_RUNOUT_SENSOR);
 | 
				
			||||||
 | 
					    #else
 | 
				
			||||||
 | 
					      for (uint8_t i = 1; 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;
 | 
				
			||||||
 | 
					        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 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;
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					          #if PIN_EXISTS(FIL_RUNOUT6)
 | 
				
			||||||
 | 
					            case 6: pin = FIL_RUNOUT6_PIN; break;
 | 
				
			||||||
 | 
					          #endif
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        SERIAL_PROTOCOLPGM(MSG_FILAMENT_RUNOUT_SENSOR);
 | 
					        SERIAL_PROTOCOLPGM(MSG_FILAMENT_RUNOUT_SENSOR);
 | 
				
			||||||
    SERIAL_PROTOCOLLN(((READ(FIL_RUNOUT_PIN)^FIL_RUNOUT_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
 | 
					        if (i > 1) { SERIAL_CHAR(' '); SERIAL_CHAR('0' + i); }
 | 
				
			||||||
 | 
					        print_es_state(digitalRead(pin) == FIL_RUNOUT_INVERTING);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    #endif
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
} // Endstops::M119
 | 
					} // Endstops::M119
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -467,6 +467,21 @@
 | 
				
			|||||||
#if PIN_EXISTS(FIL_RUNOUT)
 | 
					#if PIN_EXISTS(FIL_RUNOUT)
 | 
				
			||||||
  REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT_PIN)
 | 
					  REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT_PIN)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					#if PIN_EXISTS(FIL_RUNOUT2)
 | 
				
			||||||
 | 
					  REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT2_PIN)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if PIN_EXISTS(FIL_RUNOUT3)
 | 
				
			||||||
 | 
					  REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT3_PIN)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if PIN_EXISTS(FIL_RUNOUT4)
 | 
				
			||||||
 | 
					  REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT4_PIN)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if PIN_EXISTS(FIL_RUNOUT5)
 | 
				
			||||||
 | 
					  REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT5_PIN)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#if PIN_EXISTS(FIL_RUNOUT6)
 | 
				
			||||||
 | 
					  REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT6_PIN)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#if PIN_EXISTS(HEATER_0)
 | 
					#if PIN_EXISTS(HEATER_0)
 | 
				
			||||||
  REPORT_NAME_DIGITAL(__LINE__, HEATER_0_PIN)
 | 
					  REPORT_NAME_DIGITAL(__LINE__, HEATER_0_PIN)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user