Skip to content

Commit

Permalink
Integrate TEMP_SENSOR_BOARD into CONTROLLER_FAN.
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbro committed Jul 1, 2021
1 parent f93e327 commit f92d343
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
24 changes: 15 additions & 9 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,22 @@
*/
//#define USE_CONTROLLER_FAN
#if ENABLED(USE_CONTROLLER_FAN)
//#define CONTROLLER_FAN_PIN -1 // Set a custom pin for the controller fan
//#define CONTROLLER_FAN_USE_Z_ONLY // With this option only the Z axis is considered
//#define CONTROLLER_FAN_IGNORE_Z // Ignore Z stepper. Useful when stepper timeout is disabled.
#define CONTROLLERFAN_SPEED_MIN 0 // (0-255) Minimum speed. (If set below this value the fan is turned off.)
#define CONTROLLERFAN_SPEED_ACTIVE 255 // (0-255) Active speed, used when any motor is enabled
#define CONTROLLERFAN_SPEED_IDLE 0 // (0-255) Idle speed, used when motors are disabled
#define CONTROLLERFAN_IDLE_TIME 60 // (seconds) Extra time to keep the fan running after disabling motors
//#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings
//#define CONTROLLER_FAN_PIN -1 // Set a custom pin for the controller fan
//#define CONTROLLER_FAN_USE_Z_ONLY // With this option only the Z axis is considered
//#define CONTROLLER_FAN_IGNORE_Z // Ignore Z stepper. Useful when stepper timeout is disabled.
#define CONTROLLERFAN_SPEED_MIN 0 // (0-255) Minimum speed. (If set below this value the fan is turned off.)
#define CONTROLLERFAN_SPEED_ACTIVE 255 // (0-255) Active speed, used when any motor is enabled
#define CONTROLLERFAN_SPEED_IDLE 0 // (0-255) Idle speed, used when motors are disabled
#define CONTROLLERFAN_IDLE_TIME 60 // (seconds) Extra time to keep the fan running after disabling motors

//#define CONTROLLER_FAN_USE_BOARD_TEMP // Use TEMP_SENSOR_BOARD as a trigger for enabling the controller fan
#if ENABLED(CONTROLLER_FAN_USE_BOARD_TEMP)
#define CONTROLLER_FAN_TRIGGER_TEMP 30 // (°C) Enable the fan when the temperature reaches this temperature
#endif

//#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings
#if ENABLED(CONTROLLER_FAN_EDITABLE)
#define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu
#define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu
#endif
#endif

Expand Down
15 changes: 13 additions & 2 deletions Marlin/src/feature/controllerfan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,21 @@ void ControllerFan::update() {
)
);

// If any of the drivers or the heated bed are enabled...
if (motor_on || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0))
#if ENABLED(CONTROLLER_FAN_USE_BOARD_TEMP)
#define BOARD_TEMP_TRIGGER 1
#endif

// If any triggers for the controller fan are true...
// - any of the drivers are enabled
// - the heated bed is enabled
// - TEMP_SENSOR_BOARD is reporting >= CONTROLLER_FAN_TRIGGER_TEMP
if ( motor_on
|| TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0)
|| TERN0(BOARD_TEMP_TRIGGER, thermalManager.wholeDegBoard() >= CONTROLLER_FAN_TRIGGER_TEMP)
)
lastMotorOn = ms; //... set time to NOW so the fan will turn on


// Fan Settings. Set fan > 0:
// - If AutoMode is on and steppers have been enabled for CONTROLLERFAN_IDLE_TIME seconds.
// - If System is on idle and idle fan speed settings is activated.
Expand Down
8 changes: 8 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif
#endif

#if ENABLED(CONTROLLER_FAN_USE_BOARD_TEMP)
#if DISABLED(HAS_TEMP_BOARD)
#error "CONTROLLERFAN_USE_BOARD_TEMP requires TEMP_SENSOR_BOARD."
#elif !defined(CONTROLLER_FAN_TRIGGER_TEMP)
#define CONTROLLER_FAN_TRIGGER_TEMP 30
#endif
#endif

#if ENABLED(LASER_COOLANT_FLOW_METER) && !(PIN_EXISTS(FLOWMETER) && ENABLED(LASER_FEATURE))
#error "LASER_COOLANT_FLOW_METER requires FLOWMETER_PIN and LASER_FEATURE."
#endif
Expand Down

0 comments on commit f92d343

Please sign in to comment.