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 3, 2021
1 parent d03cf08 commit 683ee49
Show file tree
Hide file tree
Showing 4 changed files with 37 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 @@ -487,16 +487,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
11 changes: 9 additions & 2 deletions Marlin/src/feature/controllerfan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,17 @@ 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 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(HAS_CONTROLLER_FAN_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
9 changes: 9 additions & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2729,6 +2729,15 @@
#define BED_OR_CHAMBER_OR_FAN 1
#endif

#if HAS_CONTROLLER_FAN
#if ENABLED(CONTROLLER_FAN_USE_BOARD_TEMP)
#define HAS_CONTROLLER_FAN_BOARD_TEMP_TRIGGER 1
#endif
#ifndef CONTROLLER_FAN_TRIGGER_TEMP
#define CONTROLLER_FAN_TRIGGER_TEMP 30
#endif
#endif

// Servos
#if PIN_EXISTS(SERVO0) && NUM_SERVOS > 0
#define HAS_SERVO_0 1
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,10 @@ 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) && DISABLED(HAS_TEMP_BOARD)
#error "CONTROLLER_FAN_USE_BOARD_TEMP requires TEMP_SENSOR_BOARD."
#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 683ee49

Please sign in to comment.