diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 24d7c46a6..986b9efb6 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2275,6 +2275,10 @@ // @section extras +// Set number of user-controlled fans. Disable to use all board-defined fans. +// :[1,2,3,4,5,6,7,8] +//#define NUM_M106_FANS 1 + // Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino //#define FAST_PWM_FAN diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 29ab2cfc2..5d7322753 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1876,12 +1876,28 @@ #undef AUTO_POWER_CHAMBER_FAN #endif -// Other fans +// Print Cooling fans (limit) +#ifdef NUM_M106_FANS + #define MAX_FANS NUM_M106_FANS +#else + #define MAX_FANS 8 // Max supported fans +#endif + +#define _NOT_E_AUTO(N,F) (E##N##_AUTO_FAN_PIN != FAN##F##_PIN) +#define _HAS_FAN(F) (PIN_EXISTS(FAN##F) \ + && CONTROLLER_FAN_PIN != FAN##F##_PIN \ + && _NOT_E_AUTO(0,F) \ + && _NOT_E_AUTO(1,F) \ + && _NOT_E_AUTO(2,F) \ + && _NOT_E_AUTO(3,F) \ + && _NOT_E_AUTO(4,F) \ + && _NOT_E_AUTO(5,F) \ + && _NOT_E_AUTO(6,F) \ + && _NOT_E_AUTO(7,F) \ + && F < MAX_FANS) #if PIN_EXISTS(FAN) #define HAS_FAN0 1 #endif -#define _NOT_E_AUTO(N,F) (E##N##_AUTO_FAN_PIN != FAN##F##_PIN) -#define _HAS_FAN(F) (PIN_EXISTS(FAN##F) && CONTROLLER_FAN_PIN != FAN##F##_PIN && _NOT_E_AUTO(0,F) && _NOT_E_AUTO(1,F) && _NOT_E_AUTO(2,F) && _NOT_E_AUTO(3,F) && _NOT_E_AUTO(4,F) && _NOT_E_AUTO(5,F) && _NOT_E_AUTO(6,F) && _NOT_E_AUTO(7,F)) #if _HAS_FAN(1) #define HAS_FAN1 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 6fcd86798..d31a82677 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1106,6 +1106,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "FANMUX0_PIN and FANMUX1_PIN must be set before FANMUX2_PIN can be set." #endif +/** + * Limited user-controlled fans + */ +#if NUM_M106_FANS > FAN_COUNT + #error "The selected board doesn't support enough user-controlled fans. Reduce NUM_M106_FANS." +#endif + /** * Limited number of servos */ diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a217fc9ab..1208e4e99 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -195,7 +195,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #endif #if ENABLED(ADAPTIVE_FAN_SLOWING) - uint8_t Temperature::fan_speed_scaler[FAN_COUNT] = ARRAY_N(FAN_COUNT, 128, 128, 128, 128, 128, 128); + uint8_t Temperature::fan_speed_scaler[FAN_COUNT] = ARRAY_N(FAN_COUNT, 128, 128, 128, 128, 128, 128, 128, 128); #endif /** diff --git a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h index b977ad1ab..a2094bee4 100644 --- a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h +++ b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h @@ -92,7 +92,7 @@ // // Fans // -//#define FAN0_PIN 8 +//#define FAN_PIN 8 // // Auto fans