Scott Lahteine 3 лет назад
Родитель
Сommit
fd99ea09ec

+ 1
- 1
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp Просмотреть файл

@@ -944,7 +944,7 @@ void MarlinUI::draw_status_screen() {
944 944
               #if ENABLED(ADAPTIVE_FAN_SLOWING)
945 945
                 else { c = '*'; spd = thermalManager.scaledFanSpeed(0, spd); }
946 946
               #endif
947
-              per = thermalManager.fanPercent(spd);
947
+              per = thermalManager.pwmToPercent(spd);
948 948
             }
949 949
             else
950 950
           #endif

+ 3
- 4
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp Просмотреть файл

@@ -750,7 +750,7 @@ void MarlinUI::draw_status_screen() {
750 750
     #if HOTENDS > 2
751 751
       _draw_heater_status(H_E2, "HE3", blink); // Hotend 3 Temperature
752 752
     #endif
753
-  #endif // HOTENDS <= 1
753
+  #endif
754 754
 
755 755
   #if HAS_HEATED_BED
756 756
     #if HAS_LEVELING
@@ -758,16 +758,15 @@ void MarlinUI::draw_status_screen() {
758 758
     #else
759 759
       _draw_heater_status(H_BED, "BED", blink);
760 760
     #endif
761
-  #endif // HAS_HEATED_BED
761
+  #endif
762 762
 
763 763
   #if HAS_FAN
764 764
     uint16_t spd = thermalManager.fan_speed[0];
765
-
766 765
     #if ENABLED(ADAPTIVE_FAN_SLOWING)
767 766
       if (!blink) spd = thermalManager.scaledFanSpeed(0, spd);
768 767
     #endif
768
+    uint16_t per = thermalManager.pwmToPercent(spd);
769 769
 
770
-    uint16_t per = thermalManager.fanPercent(spd);
771 770
     #if HOTENDS < 2
772 771
       #define FANX 11
773 772
     #else

+ 1
- 1
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Просмотреть файл

@@ -696,7 +696,7 @@ void MarlinUI::draw_status_screen() {
696 696
               c = '*';
697 697
             }
698 698
           #endif
699
-          lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.fanPercent(spd)));
699
+          lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.pwmToPercent(spd)));
700 700
           lcd_put_wchar(c);
701 701
         }
702 702
       }

+ 2
- 4
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp Просмотреть файл

@@ -733,14 +733,12 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
733 733
     TERN_(HAS_MULTI_HOTEND, draw_extruder_2_temp(extruder_2_temp, extruder_2_target, forceUpdate));
734 734
     TERN_(HAS_HEATED_BED, draw_bed_temp(bed_temp, bed_target, forceUpdate));
735 735
 
736
-    uint16_t spd = thermalManager.fan_speed[0];
737
-
736
+    uint8_t spd = thermalManager.fan_speed[0];
738 737
     #if ENABLED(ADAPTIVE_FAN_SLOWING)
739 738
       if (!blink && thermalManager.fan_speed_scaler[0] < 128)
740 739
         spd = thermalManager.scaledFanSpeed(0, spd);
741 740
     #endif
742
-
743
-    draw_fan_speed(thermalManager.fanPercent(spd));
741
+    draw_fan_speed(thermalManager.pwmToPercent(spd));
744 742
 
745 743
     // Draw elapsed/remaining time
746 744
     const bool show_remaining = ENABLED(SHOW_REMAINING_TIME) && (DISABLED(ROTATE_PROGRESS_DISPLAY) || blink);

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp Просмотреть файл

@@ -236,7 +236,7 @@ void disp_bed_temp() {
236 236
 }
237 237
 
238 238
 void disp_fan_speed() {
239
-  sprintf_P(public_buf_l, PSTR("%d%%"), thermalManager.fanPercent(thermalManager.fan_speed[0]));
239
+  sprintf_P(public_buf_l, PSTR("%d%%"), thermalManager.fanSpeedPercent(0));
240 240
   lv_label_set_text(labelFan, public_buf_l);
241 241
 }
242 242
 

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp Просмотреть файл

@@ -241,7 +241,7 @@ void lv_draw_ready_print() {
241 241
       lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
242 242
     #endif
243 243
 
244
-    sprintf_P(buf, PSTR("%d%%"), thermalManager.fanPercent(thermalManager.fan_speed[0]));
244
+    sprintf_P(buf, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0));
245 245
     lv_label_set_text(labelFan, buf);
246 246
     lv_obj_align(labelFan, buttonFanstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
247 247
   }

+ 2
- 2
Marlin/src/lcd/extui/ui_api.cpp Просмотреть файл

@@ -297,7 +297,7 @@ namespace ExtUI {
297 297
 
298 298
   float getTargetFan_percent(const fan_t fan) {
299 299
     #if HAS_FAN
300
-      return thermalManager.fanPercent(thermalManager.fan_speed[fan - FAN0]);
300
+      return thermalManager.fanSpeedPercent(fan - FAN0);
301 301
     #else
302 302
       UNUSED(fan);
303 303
       return 0;
@@ -306,7 +306,7 @@ namespace ExtUI {
306 306
 
307 307
   float getActualFan_percent(const fan_t fan) {
308 308
     #if HAS_FAN
309
-      return thermalManager.fanPercent(thermalManager.scaledFanSpeed(fan - FAN0));
309
+      return thermalManager.scaledFanSpeedPercent(fan - FAN0);
310 310
     #else
311 311
       UNUSED(fan);
312 312
       return 0;

+ 10
- 10
Marlin/src/module/temperature.cpp Просмотреть файл

@@ -315,34 +315,34 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
315 315
   /**
316 316
    * Set the print fan speed for a target extruder
317 317
    */
318
-  void Temperature::set_fan_speed(uint8_t target, uint16_t speed) {
318
+  void Temperature::set_fan_speed(uint8_t fan, uint16_t speed) {
319 319
 
320 320
     NOMORE(speed, 255U);
321 321
 
322 322
     #if ENABLED(SINGLENOZZLE_STANDBY_FAN)
323
-      if (target != active_extruder) {
324
-        if (target < EXTRUDERS) singlenozzle_fan_speed[target] = speed;
323
+      if (fan != active_extruder) {
324
+        if (fan < EXTRUDERS) singlenozzle_fan_speed[fan] = speed;
325 325
         return;
326 326
       }
327 327
     #endif
328 328
 
329
-    TERN_(SINGLENOZZLE, target = 0); // Always use fan index 0 with SINGLENOZZLE
329
+    TERN_(SINGLENOZZLE, fan = 0); // Always use fan index 0 with SINGLENOZZLE
330 330
 
331
-    if (target >= FAN_COUNT) return;
331
+    if (fan >= FAN_COUNT) return;
332 332
 
333
-    fan_speed[target] = speed;
333
+    fan_speed[fan] = speed;
334 334
 
335
-    TERN_(REPORT_FAN_CHANGE, report_fan_speed(target));
335
+    TERN_(REPORT_FAN_CHANGE, report_fan_speed(fan));
336 336
   }
337 337
 
338 338
   #if ENABLED(REPORT_FAN_CHANGE)
339 339
     /**
340 340
      * Report print fan speed for a target extruder
341 341
      */
342
-    void Temperature::report_fan_speed(const uint8_t target) {
343
-      if (target >= FAN_COUNT) return;
342
+    void Temperature::report_fan_speed(const uint8_t fan) {
343
+      if (fan >= FAN_COUNT) return;
344 344
       PORT_REDIRECT(SerialMask::All);
345
-      SERIAL_ECHOLNPAIR("M106 P", target, " S", fan_speed[target]);
345
+      SERIAL_ECHOLNPAIR("M106 P", fan, " S", fan_speed[fan]);
346 346
     }
347 347
   #endif
348 348
 

+ 11
- 9
Marlin/src/module/temperature.h Просмотреть файл

@@ -553,10 +553,10 @@ class Temperature {
553 553
       static uint8_t fan_speed[FAN_COUNT];
554 554
       #define FANS_LOOP(I) LOOP_L_N(I, FAN_COUNT)
555 555
 
556
-      static void set_fan_speed(const uint8_t target, const uint16_t speed);
556
+      static void set_fan_speed(const uint8_t fan, const uint16_t speed);
557 557
 
558 558
       #if ENABLED(REPORT_FAN_CHANGE)
559
-        static void report_fan_speed(const uint8_t target);
559
+        static void report_fan_speed(const uint8_t fan);
560 560
       #endif
561 561
 
562 562
       #if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE)
@@ -564,21 +564,23 @@ class Temperature {
564 564
         static uint8_t saved_fan_speed[FAN_COUNT];
565 565
       #endif
566 566
 
567
-      static constexpr inline uint8_t fanPercent(const uint8_t speed) { return ui8_to_percent(speed); }
568
-
569 567
       #if ENABLED(ADAPTIVE_FAN_SLOWING)
570 568
         static uint8_t fan_speed_scaler[FAN_COUNT];
571 569
       #endif
572 570
 
573
-      static inline uint8_t scaledFanSpeed(const uint8_t target, const uint8_t fs) {
574
-        UNUSED(target); // Potentially unused!
575
-        return (fs * uint16_t(TERN(ADAPTIVE_FAN_SLOWING, fan_speed_scaler[target], 128))) >> 7;
571
+      static inline uint8_t scaledFanSpeed(const uint8_t fan, const uint8_t fs) {
572
+        UNUSED(fan); // Potentially unused!
573
+        return (fs * uint16_t(TERN(ADAPTIVE_FAN_SLOWING, fan_speed_scaler[fan], 128))) >> 7;
576 574
       }
577 575
 
578
-      static inline uint8_t scaledFanSpeed(const uint8_t target) {
579
-        return scaledFanSpeed(target, fan_speed[target]);
576
+      static inline uint8_t scaledFanSpeed(const uint8_t fan) {
577
+        return scaledFanSpeed(fan, fan_speed[fan]);
580 578
       }
581 579
 
580
+      static constexpr inline uint8_t pwmToPercent(const uint8_t speed) { return ui8_to_percent(speed); }
581
+      static inline uint8_t fanSpeedPercent(const uint8_t fan)          { return ui8_to_percent(fan_speed[fan]); }
582
+      static inline uint8_t scaledFanSpeedPercent(const uint8_t fan)    { return ui8_to_percent(scaledFanSpeed(fan)); }
583
+
582 584
       #if ENABLED(EXTRA_FAN_SPEED)
583 585
         typedef struct { uint8_t saved, speed; } extra_fan_t;
584 586
         static extra_fan_t extra_fan_speed[FAN_COUNT];

Загрузка…
Отмена
Сохранить