Kaynağa Gözat

Common method for scaled fan speed

Scott Lahteine 6 yıl önce
ebeveyn
işleme
a8d68b7c8a

+ 1
- 1
Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp Dosyayı Görüntüle

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

+ 1
- 1
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Dosyayı Görüntüle

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

+ 2
- 2
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp Dosyayı Görüntüle

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

+ 1
- 1
Marlin/src/lcd/extensible_ui/ui_api.cpp Dosyayı Görüntüle

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

+ 2
- 2
Marlin/src/module/planner.cpp Dosyayı Görüntüle

@@ -1184,7 +1184,7 @@ void Planner::check_axes_activity() {
1184 1184
   if (has_blocks_queued()) {
1185 1185
     #if FAN_COUNT > 0
1186 1186
       FANS_LOOP(i)
1187
-        tail_fan_speed[i] = (block_buffer[block_buffer_tail].fan_speed[i] * uint16_t(thermalManager.fan_speed_scaler[i])) >> 7;
1187
+        tail_fan_speed[i] = thermalManager.scaledFanSpeed(i, block_buffer[block_buffer_tail].fan_speed[i]);
1188 1188
     #endif
1189 1189
 
1190 1190
     block_t* block;
@@ -1207,7 +1207,7 @@ void Planner::check_axes_activity() {
1207 1207
   else {
1208 1208
     #if FAN_COUNT > 0
1209 1209
       FANS_LOOP(i)
1210
-        tail_fan_speed[i] = (thermalManager.fan_speed[i] * uint16_t(thermalManager.fan_speed_scaler[i])) >> 7;
1210
+        tail_fan_speed[i] = thermalManager.scaledFanSpeed(i);
1211 1211
     #endif
1212 1212
 
1213 1213
     #if ENABLED(BARICUDA)

+ 3
- 0
Marlin/src/module/temperature.cpp Dosyayı Görüntüle

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

+ 6
- 2
Marlin/src/module/temperature.h Dosyayı Görüntüle

@@ -472,8 +472,12 @@ class Temperature {
472 472
         static constexpr uint8_t fan_speed_scaler[FAN_COUNT] = ARRAY_N(FAN_COUNT, 128, 128, 128, 128, 128, 128);
473 473
       #endif
474 474
 
475
-      static inline uint8_t lcd_fanSpeedActual(const uint8_t target) {
476
-        return (fan_speed[target] * uint16_t(fan_speed_scaler[target])) >> 7;
475
+      static inline uint8_t scaledFanSpeed(const uint8_t target) {
476
+        return (fs * uint16_t(fan_speed_scaler[target])) >> 7;
477
+      }
478
+
479
+      static inline uint8_t scaledFanSpeed(const uint8_t target, const uint8_t fs) {
480
+        return scaledFanSpeed(target, fan_speed[target]);
477 481
       }
478 482
 
479 483
       #if ENABLED(EXTRA_FAN_SPEED)

Loading…
İptal
Kaydet