Browse Source

Common method for scaled fan speed

pull/1/head
Scott Lahteine 6 years ago
parent
commit
a8d68b7c8a
  1. 2
      Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp
  2. 2
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  3. 4
      Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
  4. 2
      Marlin/src/lcd/extensible_ui/ui_api.cpp
  5. 4
      Marlin/src/module/planner.cpp
  6. 3
      Marlin/src/module/temperature.cpp
  7. 8
      Marlin/src/module/temperature.h

2
Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp

@ -886,7 +886,7 @@ void MarlinUI::draw_status_screen() {
uint16_t spd = thermalManager.fan_speed[0];
if (blink) c = 'F';
#if ENABLED(ADAPTIVE_FAN_SLOWING)
else { c = '*'; spd = (spd * thermalManager.fan_speed_scaler[0]) >> 7; }
else { c = '*'; spd = thermalManager.scaledFanSpeed(0, spd); }
#endif
per = thermalManager.fanPercent(spd);
}

2
Marlin/src/lcd/dogm/status_screen_DOGM.cpp

@ -423,7 +423,7 @@ void MarlinUI::draw_status_screen() {
if (spd) {
#if ENABLED(ADAPTIVE_FAN_SLOWING)
if (!blink && thermalManager.fan_speed_scaler[0] < 128) {
spd = (spd * thermalManager.fan_speed_scaler[0]) >> 7;
spd = thermalManager.scaledFanSpeed(0, spd);
c = '*';
}
#endif

4
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp

@ -684,7 +684,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
// them only during blinks we gain a bit of stability.
const bool blink = ui.get_blink();
const uint16_t feedrate_perc = feedrate_percentage;
const uint16_t fs = (thermalManager.fan_speed[0] * uint16_t(thermalManager.fan_speed_scaler[0])) >> 7;
const uint16_t fs = thermalManager.scaledFanSpeed(0);
const int16_t extruder_1_target = thermalManager.degTargetHotend(0);
#if HOTENDS > 1
const int16_t extruder_2_target = thermalManager.degTargetHotend(1);
@ -734,7 +734,7 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
#if ENABLED(ADAPTIVE_FAN_SLOWING)
if (!blink && thermalManager.fan_speed_scaler[0] < 128)
spd = (spd * thermalManager.fan_speed_scaler[0]) >> 7;
spd = thermalManager.scaledFanSpeed(0, spd);
#endif
draw_fan_speed(thermalManager.fanPercent(spd));

2
Marlin/src/lcd/extensible_ui/ui_api.cpp

@ -246,7 +246,7 @@ namespace ExtUI {
}
float getActualFan_percent(const fan_t fan) {
return thermalManager.fanPercent((thermalManager.fan_speed[fan - FAN0] * uint16_t(thermalManager.fan_speed_scaler[fan - FAN0])) >> 7);
return thermalManager.fanPercent(thermalManager.scaledFanSpeed(fan - FAN0));
}
float getAxisPosition_mm(const axis_t axis) {

4
Marlin/src/module/planner.cpp

@ -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)

3
Marlin/src/module/temperature.cpp

@ -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);

8
Marlin/src/module/temperature.h

@ -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)

Loading…
Cancel
Save