️ Controller Fan software PWM (etc.) (#23102)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Mike La Spina
2021-11-14 05:55:31 -06:00
committed by Scott Lahteine
parent 49e233e06f
commit e0c439fe91
8 changed files with 76 additions and 80 deletions

View File

@ -41,6 +41,10 @@
#include "../feature/spindle_laser.h"
#endif
#if ENABLED(USE_CONTROLLER_FAN)
#include "../feature/controllerfan.h"
#endif
#if ENABLED(EMERGENCY_PARSER)
#include "motion.h"
#endif
@ -302,6 +306,10 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
uint8_t Temperature::coolerfan_speed; // = 0
#endif
#if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN)
uint8_t Temperature::soft_pwm_controller_speed;
#endif
// Init fans according to whether they're native PWM or Software PWM
#ifdef BOARD_OPENDRAIN_MOSFETS
#define _INIT_SOFT_FAN(P) OUT_WRITE_OD(P, FAN_INVERTING ? LOW : HIGH)
@ -3021,6 +3029,10 @@ void Temperature::isr() {
static SoftPWM soft_pwm_cooler;
#endif
#if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN)
static SoftPWM soft_pwm_controller;
#endif
#define WRITE_FAN(n, v) WRITE(FAN##n##_PIN, (v) ^ FAN_INVERTING)
#if DISABLED(SLOW_PWM_HEATERS)
@ -3056,6 +3068,10 @@ void Temperature::isr() {
_PWM_MOD(COOLER, soft_pwm_cooler, temp_cooler);
#endif
#if BOTH(USE_CONTROLLER_FAN, FAN_SOFT_PWM)
WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, soft_pwm_controller_speed));
#endif
#if ENABLED(FAN_SOFT_PWM)
#define _FAN_PWM(N) do{ \
uint8_t &spcf = soft_pwm_count_fan[N]; \
@ -3132,6 +3148,9 @@ void Temperature::isr() {
#if HAS_FAN7
if (soft_pwm_count_fan[7] <= pwm_count_tmp) WRITE_FAN(7, LOW);
#endif
#if ENABLED(USE_CONTROLLER_FAN)
if (soft_pwm_controller.count <= pwm_count_tmp) WRITE(CONTROLLER_FAN_PIN, LOW);
#endif
#endif
}

View File

@ -387,6 +387,10 @@ class Temperature {
soft_pwm_count_fan[FAN_COUNT];
#endif
#if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN)
static uint8_t soft_pwm_controller_speed;
#endif
#if ENABLED(PREVENT_COLD_EXTRUSION)
static bool allow_cold_extrude;
static celsius_t extrude_min_temp;