Przeglądaj źródła

Common method for scaled fan speed

Scott Lahteine 6 lat temu
rodzic
commit
a8d68b7c8a

+ 1
- 1
Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp Wyświetl plik

886
               uint16_t spd = thermalManager.fan_speed[0];
886
               uint16_t spd = thermalManager.fan_speed[0];
887
               if (blink) c = 'F';
887
               if (blink) c = 'F';
888
               #if ENABLED(ADAPTIVE_FAN_SLOWING)
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
               #endif
890
               #endif
891
               per = thermalManager.fanPercent(spd);
891
               per = thermalManager.fanPercent(spd);
892
             }
892
             }

+ 1
- 1
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Wyświetl plik

423
         if (spd) {
423
         if (spd) {
424
           #if ENABLED(ADAPTIVE_FAN_SLOWING)
424
           #if ENABLED(ADAPTIVE_FAN_SLOWING)
425
             if (!blink && thermalManager.fan_speed_scaler[0] < 128) {
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
               c = '*';
427
               c = '*';
428
             }
428
             }
429
           #endif
429
           #endif

+ 2
- 2
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp Wyświetl plik

684
   // them only during blinks we gain a bit of stability.
684
   // them only during blinks we gain a bit of stability.
685
   const bool       blink             = ui.get_blink();
685
   const bool       blink             = ui.get_blink();
686
   const uint16_t   feedrate_perc     = feedrate_percentage;
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
   const int16_t    extruder_1_target = thermalManager.degTargetHotend(0);
688
   const int16_t    extruder_1_target = thermalManager.degTargetHotend(0);
689
   #if HOTENDS > 1
689
   #if HOTENDS > 1
690
     const int16_t  extruder_2_target = thermalManager.degTargetHotend(1);
690
     const int16_t  extruder_2_target = thermalManager.degTargetHotend(1);
734
 
734
 
735
     #if ENABLED(ADAPTIVE_FAN_SLOWING)
735
     #if ENABLED(ADAPTIVE_FAN_SLOWING)
736
       if (!blink && thermalManager.fan_speed_scaler[0] < 128)
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
     #endif
738
     #endif
739
 
739
 
740
     draw_fan_speed(thermalManager.fanPercent(spd));
740
     draw_fan_speed(thermalManager.fanPercent(spd));

+ 1
- 1
Marlin/src/lcd/extensible_ui/ui_api.cpp Wyświetl plik

246
   }
246
   }
247
 
247
 
248
   float getActualFan_percent(const fan_t fan) {
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
   float getAxisPosition_mm(const axis_t axis) {
252
   float getAxisPosition_mm(const axis_t axis) {

+ 2
- 2
Marlin/src/module/planner.cpp Wyświetl plik

1184
   if (has_blocks_queued()) {
1184
   if (has_blocks_queued()) {
1185
     #if FAN_COUNT > 0
1185
     #if FAN_COUNT > 0
1186
       FANS_LOOP(i)
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
     #endif
1188
     #endif
1189
 
1189
 
1190
     block_t* block;
1190
     block_t* block;
1207
   else {
1207
   else {
1208
     #if FAN_COUNT > 0
1208
     #if FAN_COUNT > 0
1209
       FANS_LOOP(i)
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
     #endif
1211
     #endif
1212
 
1212
 
1213
     #if ENABLED(BARICUDA)
1213
     #if ENABLED(BARICUDA)

+ 3
- 0
Marlin/src/module/temperature.cpp Wyświetl plik

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

+ 6
- 2
Marlin/src/module/temperature.h Wyświetl plik

472
         static constexpr uint8_t fan_speed_scaler[FAN_COUNT] = ARRAY_N(FAN_COUNT, 128, 128, 128, 128, 128, 128);
472
         static constexpr uint8_t fan_speed_scaler[FAN_COUNT] = ARRAY_N(FAN_COUNT, 128, 128, 128, 128, 128, 128);
473
       #endif
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
       #if ENABLED(EXTRA_FAN_SPEED)
483
       #if ENABLED(EXTRA_FAN_SPEED)

Ładowanie…
Anuluj
Zapisz