0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-02-02 07:00:42 +00:00

FAN_KICKSTART_LINEAR (#27072)

This commit is contained in:
Vovodroid 2024-07-05 05:22:16 +03:00 committed by GitHub
parent b303bb1e56
commit 10ffb9cb68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 9 deletions

View file

@ -604,6 +604,8 @@
*/
//#define FAN_KICKSTART_TIME 100 // (ms)
//#define FAN_KICKSTART_POWER 180 // 64-255
//#define FAN_KICKSTART_LINEAR // Set kickstart time linearly based on the speed, e.g., for 20% (51) it will be FAN_KICKSTART_TIME * 0.2.
// Useful for quick speed up to low speed. Kickstart power must be set to 255.
// Some coolers may require a non-zero "off" state.
//#define FAN_OFF_PWM 1

View file

@ -2757,7 +2757,7 @@
// Fan Kickstart
#if FAN_KICKSTART_TIME && !defined(FAN_KICKSTART_POWER)
#define FAN_KICKSTART_POWER 180
#define FAN_KICKSTART_POWER TERN(FAN_KICKSTART_LINEAR, 255, 180)
#endif
// Servos

View file

@ -1009,8 +1009,12 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
#endif
// Fan Kickstart power
#if FAN_KICKSTART_TIME && !WITHIN(FAN_KICKSTART_POWER, 64, 255)
#error "FAN_KICKSTART_POWER must be an integer from 64 to 255."
#if FAN_KICKSTART_TIME
#if ENABLED(FAN_KICKSTART_LINEAR) && FAN_KICKSTART_POWER != 255
#error "FAN_KICKSTART_LINEAR requires a FAN_KICKSTART_POWER of 255."
#elif !WITHIN(FAN_KICKSTART_POWER, 64, 255)
#error "FAN_KICKSTART_POWER must be an integer from 64 to 255."
#endif
#endif
/**

View file

@ -1201,16 +1201,20 @@ void Planner::recalculate(const_float_t safe_exit_speed_sqr) {
void Planner::kickstart_fan(uint8_t (&fan_speed)[FAN_COUNT], const millis_t &ms, const uint8_t f) {
static millis_t fan_kick_end[FAN_COUNT] = { 0 };
#if ENABLED(FAN_KICKSTART_LINEAR)
static uint8_t set_fan_speed[FAN_COUNT] = { 0 };
#endif
if (fan_speed[f] > FAN_OFF_PWM) {
if (fan_kick_end[f] == 0) {
fan_kick_end[f] = ms + FAN_KICKSTART_TIME;
const bool first_kick = fan_kick_end[f] == 0 && TERN1(FAN_KICKSTART_LINEAR, fan_speed[f] > set_fan_speed[f]);
if (first_kick)
fan_kick_end[f] = ms + (FAN_KICKSTART_TIME) TERN_(FAN_KICKSTART_LINEAR, * (fan_speed[f] - set_fan_speed[f]) / 255);
if (first_kick || PENDING(ms, fan_kick_end[f])) {
fan_speed[f] = FAN_KICKSTART_POWER;
return;
}
else if (PENDING(ms, fan_kick_end[f]))
fan_speed[f] = FAN_KICKSTART_POWER;
}
else
fan_kick_end[f] = 0;
fan_kick_end[f] = 0;
TERN_(FAN_KICKSTART_LINEAR, set_fan_speed[f] = fan_speed[f]);
}
#endif