Common method for scaled fan speed

This commit is contained in:
Scott Lahteine
2019-06-28 13:58:40 -05:00
parent 1a09c4dea5
commit a8d68b7c8a
7 changed files with 16 additions and 9 deletions

View File

@ -1184,7 +1184,7 @@ void Planner::check_axes_activity() {
if (has_blocks_queued()) {
#if FAN_COUNT > 0
FANS_LOOP(i)
tail_fan_speed[i] = (block_buffer[block_buffer_tail].fan_speed[i] * uint16_t(thermalManager.fan_speed_scaler[i])) >> 7;
tail_fan_speed[i] = thermalManager.scaledFanSpeed(i, block_buffer[block_buffer_tail].fan_speed[i]);
#endif
block_t* block;
@ -1207,7 +1207,7 @@ void Planner::check_axes_activity() {
else {
#if FAN_COUNT > 0
FANS_LOOP(i)
tail_fan_speed[i] = (thermalManager.fan_speed[i] * uint16_t(thermalManager.fan_speed_scaler[i])) >> 7;
tail_fan_speed[i] = thermalManager.scaledFanSpeed(i);
#endif
#if ENABLED(BARICUDA)

View File

@ -171,6 +171,9 @@ hotend_info_t Temperature::temp_hotend[HOTENDS
#endif
/**
* Set the print fan speed for a target extruder
*/
void Temperature::set_fan_speed(uint8_t target, uint16_t speed) {
NOMORE(speed, 255U);

View File

@ -472,8 +472,12 @@ class Temperature {
static constexpr uint8_t fan_speed_scaler[FAN_COUNT] = ARRAY_N(FAN_COUNT, 128, 128, 128, 128, 128, 128);
#endif
static inline uint8_t lcd_fanSpeedActual(const uint8_t target) {
return (fan_speed[target] * uint16_t(fan_speed_scaler[target])) >> 7;
static inline uint8_t scaledFanSpeed(const uint8_t target) {
return (fs * uint16_t(fan_speed_scaler[target])) >> 7;
}
static inline uint8_t scaledFanSpeed(const uint8_t target, const uint8_t fs) {
return scaledFanSpeed(target, fan_speed[target]);
}
#if ENABLED(EXTRA_FAN_SPEED)