Bläddra i källkod

Use uint8_t for all fan speeds (#12032)

Scott Lahteine 5 år sedan
förälder
incheckning
d6b0fbd771
Inget konto är kopplat till bidragsgivarens mejladress

+ 4
- 5
Marlin/src/Marlin.cpp Visa fil

@@ -170,14 +170,13 @@ uint8_t axis_homed, axis_known_position; // = 0
170 170
 #endif
171 171
 
172 172
 #if FAN_COUNT > 0
173
-  int16_t fanSpeeds[FAN_COUNT] = { 0 };
173
+  uint8_t fan_speed[FAN_COUNT] = { 0 };
174 174
   #if ENABLED(EXTRA_FAN_SPEED)
175
-    int16_t old_fanSpeeds[FAN_COUNT],
176
-            new_fanSpeeds[FAN_COUNT];
175
+    uint8_t old_fan_speed[FAN_COUNT], new_fan_speed[FAN_COUNT];
177 176
   #endif
178 177
   #if ENABLED(PROBING_FANS_OFF)
179 178
     bool fans_paused; // = false;
180
-    int16_t paused_fanSpeeds[FAN_COUNT] = { 0 };
179
+    uint8_t paused_fan_speed[FAN_COUNT] = { 0 };
181 180
   #endif
182 181
 #endif
183 182
 
@@ -972,7 +971,7 @@ void loop() {
972 971
         print_job_timer.stop();
973 972
         thermalManager.disable_all_heaters();
974 973
         #if FAN_COUNT > 0
975
-          for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
974
+          for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
976 975
         #endif
977 976
         wait_for_heatup = false;
978 977
         #if ENABLED(POWER_LOSS_RECOVERY)

+ 4
- 5
Marlin/src/Marlin.h Visa fil

@@ -208,19 +208,18 @@ extern volatile bool wait_for_heatup;
208 208
 extern millis_t max_inactive_time, stepper_inactive_time;
209 209
 
210 210
 #if FAN_COUNT > 0
211
-  extern int16_t fanSpeeds[FAN_COUNT];
211
+  extern uint8_t fan_speed[FAN_COUNT];
212 212
   #if ENABLED(EXTRA_FAN_SPEED)
213
-    extern int16_t old_fanSpeeds[FAN_COUNT],
214
-                   new_fanSpeeds[FAN_COUNT];
213
+    extern uint8_t old_fan_speed[FAN_COUNT], new_fan_speed[FAN_COUNT];
215 214
   #endif
216 215
   #if ENABLED(PROBING_FANS_OFF)
217 216
     extern bool fans_paused;
218
-    extern int16_t paused_fanSpeeds[FAN_COUNT];
217
+    extern uint8_t paused_fan_speed[FAN_COUNT];
219 218
   #endif
220 219
 #endif
221 220
 
222 221
 #if ENABLED(USE_CONTROLLER_FAN)
223
-  extern uint8_t controllerFanSpeed;
222
+  extern uint8_t controllerfan_speed;
224 223
 #endif
225 224
 
226 225
 #if HAS_POWER_SWITCH

+ 2
- 2
Marlin/src/feature/controllerfan.cpp Visa fil

@@ -27,7 +27,7 @@
27 27
 #include "../module/stepper_indirection.h"
28 28
 #include "../module/temperature.h"
29 29
 
30
-uint8_t controllerFanSpeed;
30
+uint8_t controllerfan_speed;
31 31
 
32 32
 void controllerfan_update() {
33 33
   static millis_t lastMotorOn = 0, // Last time a motor was turned on
@@ -75,7 +75,7 @@ void controllerfan_update() {
75 75
 
76 76
     // Fan off if no steppers have been enabled for CONTROLLERFAN_SECS seconds
77 77
     uint8_t speed = (!lastMotorOn || ELAPSED(ms, lastMotorOn + (CONTROLLERFAN_SECS) * 1000UL)) ? 0 : CONTROLLERFAN_SPEED;
78
-    controllerFanSpeed = speed;
78
+    controllerfan_speed = speed;
79 79
 
80 80
     // allows digital or PWM fan output to be used (see M42 handling)
81 81
     WRITE(CONTROLLER_FAN_PIN, speed);

+ 3
- 3
Marlin/src/feature/power.cpp Visa fil

@@ -39,15 +39,15 @@ millis_t Power::lastPowerOn;
39 39
 
40 40
 bool Power::is_power_needed() {
41 41
   #if ENABLED(AUTO_POWER_FANS)
42
-    for (uint8_t i = 0; i < FAN_COUNT; i++) if (fanSpeeds[i] > 0) return true;
42
+    for (uint8_t i = 0; i < FAN_COUNT; i++) if (fan_speed[i]) return true;
43 43
   #endif
44 44
 
45 45
   #if ENABLED(AUTO_POWER_E_FANS)
46
-    HOTEND_LOOP() if (thermalManager.autofan_speed[e] > 0) return true;
46
+    HOTEND_LOOP() if (thermalManager.autofan_speed[e]) return true;
47 47
   #endif
48 48
 
49 49
   #if ENABLED(AUTO_POWER_CONTROLLERFAN) && HAS_CONTROLLER_FAN && ENABLED(USE_CONTROLLER_FAN)
50
-    if (controllerFanSpeed > 0) return true;
50
+    if (controllerfan_speed) return true;
51 51
   #endif
52 52
 
53 53
   // If any of the drivers or the bed are enabled...

+ 3
- 3
Marlin/src/feature/power_loss_recovery.cpp Visa fil

@@ -82,9 +82,9 @@ extern uint8_t commands_in_queue, cmd_queue_index_r;
82 82
         #endif
83 83
 
84 84
         #if FAN_COUNT
85
-          SERIAL_PROTOCOLPGM("fanSpeeds: ");
85
+          SERIAL_PROTOCOLPGM("fan_speed: ");
86 86
           for (int8_t i = 0; i < FAN_COUNT; i++) {
87
-            SERIAL_PROTOCOL(job_recovery_info.fanSpeeds[i]);
87
+            SERIAL_PROTOCOL(job_recovery_info.fan_speed[i]);
88 88
             if (i < FAN_COUNT - 1) SERIAL_CHAR(',');
89 89
           }
90 90
           SERIAL_EOL();
@@ -264,7 +264,7 @@ void save_job_recovery_info() {
264 264
     #endif
265 265
 
266 266
     #if FAN_COUNT
267
-      COPY(job_recovery_info.fanSpeeds, fanSpeeds);
267
+      COPY(job_recovery_info.fan_speed, fan_speed);
268 268
     #endif
269 269
 
270 270
     #if HAS_LEVELING

+ 1
- 1
Marlin/src/feature/power_loss_recovery.h Visa fil

@@ -52,7 +52,7 @@ typedef struct {
52 52
   #endif
53 53
 
54 54
   #if FAN_COUNT
55
-    int16_t fanSpeeds[FAN_COUNT];
55
+    uint8_t fan_speed[FAN_COUNT];
56 56
   #endif
57 57
 
58 58
   #if HAS_LEVELING

+ 3
- 3
Marlin/src/gcode/control/M42.cpp Visa fil

@@ -52,13 +52,13 @@ void GcodeSuite::M42() {
52 52
   #if FAN_COUNT > 0
53 53
     switch (pin) {
54 54
       #if HAS_FAN0
55
-        case FAN_PIN: fanSpeeds[0] = pin_status; break;
55
+        case FAN_PIN: fan_speed[0] = pin_status; break;
56 56
       #endif
57 57
       #if HAS_FAN1
58
-        case FAN1_PIN: fanSpeeds[1] = pin_status; break;
58
+        case FAN1_PIN: fan_speed[1] = pin_status; break;
59 59
       #endif
60 60
       #if HAS_FAN2
61
-        case FAN2_PIN: fanSpeeds[2] = pin_status; break;
61
+        case FAN2_PIN: fan_speed[2] = pin_status; break;
62 62
       #endif
63 63
     }
64 64
   #endif

+ 2
- 2
Marlin/src/gcode/control/M80_M81.cpp Visa fil

@@ -98,10 +98,10 @@ void GcodeSuite::M81() {
98 98
   planner.finish_and_disable();
99 99
 
100 100
   #if FAN_COUNT > 0
101
-    for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
101
+    for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
102 102
     #if ENABLED(PROBING_FANS_OFF)
103 103
       fans_paused = false;
104
-      ZERO(paused_fanSpeeds);
104
+      ZERO(paused_fan_speed);
105 105
     #endif
106 106
   #endif
107 107
 

+ 1
- 1
Marlin/src/gcode/lcd/M145.cpp Visa fil

@@ -49,7 +49,7 @@ void GcodeSuite::M145() {
49 49
     }
50 50
     if (parser.seenval('F')) {
51 51
       v = parser.value_int();
52
-      lcd_preheat_fan_speed[material] = constrain(v, 0, 255);
52
+      lcd_preheat_fan_speed[material] = (uint8_t)constrain(v, 0, 255);
53 53
     }
54 54
     #if TEMP_SENSOR_BED != 0
55 55
       if (parser.seenval('B')) {

+ 2
- 2
Marlin/src/gcode/parser.h Visa fil

@@ -325,8 +325,8 @@ public:
325 325
   FORCE_INLINE static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort()       : dval; }
326 326
   FORCE_INLINE static int32_t  longval(const char c, const int32_t dval=0)    { return seenval(c) ? value_long()         : dval; }
327 327
   FORCE_INLINE static uint32_t ulongval(const char c, const uint32_t dval=0)  { return seenval(c) ? value_ulong()        : dval; }
328
-  FORCE_INLINE static float    linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; }
329
-  FORCE_INLINE static float    celsiusval(const char c, const float dval=0){ return seenval(c) ? value_celsius()      : dval; }
328
+  FORCE_INLINE static float    linearval(const char c, const float dval=0)    { return seenval(c) ? value_linear_units() : dval; }
329
+  FORCE_INLINE static float    celsiusval(const char c, const float dval=0)   { return seenval(c) ? value_celsius()      : dval; }
330 330
 
331 331
 };
332 332
 

+ 8
- 7
Marlin/src/gcode/temperature/M106_M107.cpp Visa fil

@@ -25,7 +25,7 @@
25 25
 #if FAN_COUNT > 0
26 26
 
27 27
 #include "../gcode.h"
28
-#include "../../Marlin.h" // for fanSpeeds — should move those to Planner
28
+#include "../../Marlin.h" // for fan_speed — should move those to Planner
29 29
 
30 30
 /**
31 31
  * M106: Set Fan Speed
@@ -48,21 +48,22 @@ void GcodeSuite::M106() {
48 48
       if (t > 0) {
49 49
         switch (t) {
50 50
           case 1:
51
-            fanSpeeds[p] = old_fanSpeeds[p];
51
+            fan_speed[p] = old_fan_speed[p];
52 52
             break;
53 53
           case 2:
54
-            old_fanSpeeds[p] = fanSpeeds[p];
55
-            fanSpeeds[p] = new_fanSpeeds[p];
54
+            old_fan_speed[p] = fan_speed[p];
55
+            fan_speed[p] = new_fan_speed[p];
56 56
             break;
57 57
           default:
58
-            new_fanSpeeds[p] = MIN(t, 255);
58
+            new_fan_speed[p] = MIN(t, 255);
59 59
             break;
60 60
         }
61 61
         return;
62
+
62 63
       }
63 64
     #endif // EXTRA_FAN_SPEED
64 65
     const uint16_t s = parser.ushortval('S', 255);
65
-    fanSpeeds[p] = MIN(s, 255U);
66
+    fan_speed[p] = MIN(s, 255U);
66 67
   }
67 68
 }
68 69
 
@@ -71,7 +72,7 @@ void GcodeSuite::M106() {
71 72
  */
72 73
 void GcodeSuite::M107() {
73 74
   const uint16_t p = parser.ushortval('P');
74
-  if (p < FAN_COUNT) fanSpeeds[p] = 0;
75
+  if (p < FAN_COUNT) fan_speed[p] = 0;
75 76
 }
76 77
 
77 78
 #endif // FAN_COUNT > 0

+ 3
- 3
Marlin/src/lcd/dogm/status_screen_DOGM.h Visa fil

@@ -207,7 +207,7 @@ static void lcd_implementation_status_screen() {
207 207
     static uint8_t fan_frame;
208 208
     if (old_blink != blink) {
209 209
       old_blink = blink;
210
-      if (!fanSpeeds[0] || ++fan_frame >= FAN_ANIM_FRAMES) fan_frame = 0;
210
+      if (!fan_speed[0] || ++fan_frame >= FAN_ANIM_FRAMES) fan_frame = 0;
211 211
     }
212 212
   #endif
213 213
 
@@ -245,7 +245,7 @@ static void lcd_implementation_status_screen() {
245 245
             fan_frame == 3 ? status_screen3_bmp :
246 246
           #endif
247 247
         #else
248
-          blink && fanSpeeds[0] ? status_screen1_bmp :
248
+          blink && fan_speed[0] ? status_screen1_bmp :
249 249
         #endif
250 250
       #endif
251 251
       status_screen0_bmp
@@ -269,7 +269,7 @@ static void lcd_implementation_status_screen() {
269 269
     #if HAS_FAN0
270 270
       if (PAGE_CONTAINS(STATUS_SCREEN_FAN_TEXT_Y - 7, STATUS_SCREEN_FAN_TEXT_Y)) {
271 271
         // Fan
272
-        const int16_t per = ((fanSpeeds[0] + 1) * 100) / 256;
272
+        const uint16_t per = (((uint16_t)fan_speed[0] + 1) * 100) / 256;
273 273
         if (per) {
274 274
           lcd_moveto(STATUS_SCREEN_FAN_TEXT_X, STATUS_SCREEN_FAN_TEXT_Y);
275 275
           lcd_put_u8str(itostr3(per));

+ 5
- 5
Marlin/src/lcd/dogm/status_screen_lite_ST7920.h Visa fil

@@ -710,7 +710,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
710 710
   // them only during blinks we gain a bit of stability.
711 711
   const bool       blink             = lcd_blink();
712 712
   const uint16_t   feedrate_perc     = feedrate_percentage;
713
-  const uint8_t    fan_speed         = ((fanSpeeds[0] + 1) * 100) / 256;
713
+  const uint8_t    fs                = (((uint16_t)fan_speed[0] + 1) * 100) / 256;
714 714
   const int16_t    extruder_1_target = thermalManager.degTargetHotend(0);
715 715
   #if HOTENDS > 1
716 716
     const int16_t  extruder_2_target = thermalManager.degTargetHotend(1);
@@ -719,7 +719,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
719 719
     const int16_t  bed_target        = thermalManager.degTargetBed();
720 720
   #endif
721 721
   static uint16_t last_checksum = 0;
722
-  const uint16_t checksum = blink ^ feedrate_perc ^ fan_speed ^ extruder_1_target
722
+  const uint16_t checksum = blink ^ feedrate_perc ^ fs ^ extruder_1_target
723 723
     #if HOTENDS > 1
724 724
       ^ extruder_2_target
725 725
     #endif
@@ -737,7 +737,7 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
737 737
     const bool       blink             = lcd_blink();
738 738
     const duration_t elapsed           = print_job_timer.duration();
739 739
     const uint16_t   feedrate_perc     = feedrate_percentage;
740
-    const uint8_t    fan_speed         = ((fanSpeeds[0] + 1) * 100) / 256;
740
+    const uint8_t    fs                = (((uint16_t)fan_speed[0] + 1) * 100) / 256;
741 741
     const int16_t    extruder_1_temp   = thermalManager.degHotend(0),
742 742
                      extruder_1_target = thermalManager.degTargetHotend(0);
743 743
     #if HOTENDS > 1
@@ -756,12 +756,12 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
756 756
     #if HAS_HEATED_BED
757 757
       draw_bed_temp(bed_temp, bed_target, forceUpdate);
758 758
     #endif
759
-    draw_fan_speed(fan_speed);
759
+    draw_fan_speed(fs);
760 760
     draw_print_time(elapsed);
761 761
     draw_feedrate_percentage(feedrate_perc);
762 762
 
763 763
     // Update the fan and bed animations
764
-    if (fan_speed > 0) draw_fan_icon(blink);
764
+    if (fs) draw_fan_icon(blink);
765 765
     #if HAS_HEATED_BED
766 766
       if (bed_target > 0)
767 767
         draw_heat_icon(blink, true);

+ 1
- 1
Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp Visa fil

@@ -85,7 +85,7 @@ static const uint8_t u8g_dev_st7920_128x64_HAL_init_seq[] PROGMEM = {
85 85
   U8G_ESC_END         // end of sequence
86 86
 };
87 87
 
88
-void clear_graphics_DRAM(u8g_t *u8g, u8g_dev_t *dev){
88
+void clear_graphics_DRAM(u8g_t *u8g, u8g_dev_t *dev) {
89 89
   u8g_SetChipSelect(u8g, dev, 1);
90 90
   u8g_Delay(1);
91 91
   u8g_SetAddress(u8g, dev, 0);         // cmd mode

+ 1
- 1
Marlin/src/lcd/malyanlcd.cpp Visa fil

@@ -255,7 +255,7 @@ void process_lcd_p_command(const char* command) {
255 255
         print_job_timer.stop();
256 256
         thermalManager.disable_all_heaters();
257 257
         #if FAN_COUNT > 0
258
-          for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
258
+          for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
259 259
         #endif
260 260
         wait_for_heatup = false;
261 261
         write_to_lcd_P(PSTR("{SYS:STARTED}"));

+ 20
- 19
Marlin/src/lcd/ultralcd.cpp Visa fil

@@ -159,7 +159,8 @@ millis_t next_lcd_update_ms;
159 159
   constexpr int8_t menu_bottom = LCD_HEIGHT - (TALL_FONT_CORRECTION);
160 160
 
161 161
   // Initialized by settings.load()
162
-  int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
162
+  int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
163
+  uint8_t lcd_preheat_fan_speed[2];
163 164
 
164 165
   #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
165 166
     bool lcd_external_control; // = false
@@ -945,7 +946,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
945 946
 
946 947
       // Restore print cooling fan speeds
947 948
       for (uint8_t i = 0; i < FAN_COUNT; i++) {
948
-        int16_t f = job_recovery_info.fanSpeeds[i];
949
+        uint8_t f = job_recovery_info.fan_speed[i];
949 950
         if (f) {
950 951
           sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f);
951 952
           enqueue_and_echo_command(cmd);
@@ -1553,21 +1554,21 @@ void lcd_quick_feedback(const bool clear_buttons) {
1553 1554
     //
1554 1555
     #if FAN_COUNT > 0
1555 1556
       #if HAS_FAN0
1556
-        MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fanSpeeds[0], 0, 255);
1557
+        MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fan_speed[0], 0, 255);
1557 1558
         #if ENABLED(EXTRA_FAN_SPEED)
1558
-          MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fanSpeeds[0], 3, 255);
1559
+          MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fan_speed[0], 3, 255);
1559 1560
         #endif
1560 1561
       #endif
1561 1562
       #if HAS_FAN1
1562
-        MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 2", &fanSpeeds[1], 0, 255);
1563
+        MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 2", &fan_speed[1], 0, 255);
1563 1564
         #if ENABLED(EXTRA_FAN_SPEED)
1564
-          MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED " 2", &new_fanSpeeds[1], 3, 255);
1565
+          MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 2", &new_fan_speed[1], 3, 255);
1565 1566
         #endif
1566 1567
       #endif
1567 1568
       #if HAS_FAN2
1568
-        MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 3", &fanSpeeds[2], 0, 255);
1569
+        MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 3", &fan_speed[2], 0, 255);
1569 1570
         #if ENABLED(EXTRA_FAN_SPEED)
1570
-          MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED " 3", &new_fanSpeeds[2], 3, 255);
1571
+          MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 3", &new_fan_speed[2], 3, 255);
1571 1572
         #endif
1572 1573
       #endif
1573 1574
     #endif // FAN_COUNT > 0
@@ -1669,7 +1670,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
1669 1670
    * "Temperature" submenu items
1670 1671
    *
1671 1672
    */
1672
-  void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
1673
+  void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const uint8_t fan) {
1673 1674
     if (temph > 0) thermalManager.setTargetHotend(MIN(heater_maxtemp[endnum], temph), endnum);
1674 1675
     #if HAS_HEATED_BED
1675 1676
       if (tempb >= 0) thermalManager.setTargetBed(tempb);
@@ -1678,9 +1679,9 @@ void lcd_quick_feedback(const bool clear_buttons) {
1678 1679
     #endif
1679 1680
     #if FAN_COUNT > 0
1680 1681
       #if FAN_COUNT > 1
1681
-        fanSpeeds[active_extruder < FAN_COUNT ? active_extruder : 0] = fan;
1682
+        fan_speed[active_extruder < FAN_COUNT ? active_extruder : 0] = fan;
1682 1683
       #else
1683
-        fanSpeeds[0] = fan;
1684
+        fan_speed[0] = fan;
1684 1685
       #endif
1685 1686
     #else
1686 1687
       UNUSED(fan);
@@ -1915,7 +1916,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
1915 1916
 
1916 1917
   void lcd_cooldown() {
1917 1918
     #if FAN_COUNT > 0
1918
-      for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
1919
+      for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
1919 1920
     #endif
1920 1921
     thermalManager.disable_all_heaters();
1921 1922
     lcd_return_to_status();
@@ -3609,21 +3610,21 @@ void lcd_quick_feedback(const bool clear_buttons) {
3609 3610
     //
3610 3611
     #if FAN_COUNT > 0
3611 3612
       #if HAS_FAN0
3612
-        MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fanSpeeds[0], 0, 255);
3613
+        MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fan_speed[0], 0, 255);
3613 3614
         #if ENABLED(EXTRA_FAN_SPEED)
3614
-          MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fanSpeeds[0], 3, 255);
3615
+          MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fan_speed[0], 3, 255);
3615 3616
         #endif
3616 3617
       #endif
3617 3618
       #if HAS_FAN1
3618
-        MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 2", &fanSpeeds[1], 0, 255);
3619
+        MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 2", &fan_speed[1], 0, 255);
3619 3620
         #if ENABLED(EXTRA_FAN_SPEED)
3620
-          MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED " 2", &new_fanSpeeds[1], 3, 255);
3621
+          MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 2", &new_fan_speed[1], 3, 255);
3621 3622
         #endif
3622 3623
       #endif
3623 3624
       #if HAS_FAN2
3624
-        MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 3", &fanSpeeds[2], 0, 255);
3625
+        MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 3", &fan_speed[2], 0, 255);
3625 3626
         #if ENABLED(EXTRA_FAN_SPEED)
3626
-          MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED " 3", &new_fanSpeeds[2], 3, 255);
3627
+          MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 3", &new_fan_speed[2], 3, 255);
3627 3628
         #endif
3628 3629
       #endif
3629 3630
     #endif // FAN_COUNT > 0
@@ -3755,7 +3756,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
3755 3756
       #endif
3756 3757
       START_MENU();
3757 3758
       MENU_BACK(MSG_CONFIGURATION);
3758
-      MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
3759
+      MENU_ITEM_EDIT(int8, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
3759 3760
       #if HAS_TEMP_HOTEND
3760 3761
         MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
3761 3762
       #endif

+ 2
- 1
Marlin/src/lcd/ultralcd.h Visa fil

@@ -107,7 +107,8 @@
107 107
     typedef void (*screenFunc_t)();
108 108
     typedef void (*menuAction_t)();
109 109
 
110
-    extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
110
+    extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
111
+    extern uint8_t lcd_preheat_fan_speed[2];
111 112
 
112 113
     #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
113 114
       extern bool lcd_external_control;

+ 3
- 3
Marlin/src/lcd/ultralcd_impl_HD44780.h Visa fil

@@ -1008,13 +1008,13 @@ static void lcd_implementation_status_screen() {
1008 1008
       #if FAN_COUNT > 0
1009 1009
         if (0
1010 1010
           #if HAS_FAN0
1011
-            || fanSpeeds[0]
1011
+            || fan_speed[0]
1012 1012
           #endif
1013 1013
           #if HAS_FAN1
1014
-            || fanSpeeds[1]
1014
+            || fan_speed[1]
1015 1015
           #endif
1016 1016
           #if HAS_FAN2
1017
-            || fanSpeeds[2]
1017
+            || fan_speed[2]
1018 1018
           #endif
1019 1019
         ) leds |= LED_C;
1020 1020
       #endif // FAN_COUNT > 0

+ 2
- 2
Marlin/src/libs/softspi.h Visa fil

@@ -31,7 +31,7 @@ void fastDigitalWrite(uint8_t pin, bool value) {
31 31
  * @return value read
32 32
  */
33 33
 static inline __attribute__((always_inline))
34
-bool fastDigitalRead(uint8_t pin){
34
+bool fastDigitalRead(uint8_t pin) {
35 35
   return g_APinDescription[pin].pPort->PIO_PDSR & g_APinDescription[pin].ulPin;
36 36
 }
37 37
 //------------------------------------------------------------------------------
@@ -40,7 +40,7 @@ bool fastDigitalRead(uint8_t pin){
40 40
  * @param[in] level value to write
41 41
  */
42 42
 static inline __attribute__((always_inline))
43
-void fastDigitalWrite(uint8_t pin, bool value){
43
+void fastDigitalWrite(uint8_t pin, bool value) {
44 44
   if (value)
45 45
     g_APinDescription[pin].pPort->PIO_SODR = g_APinDescription[pin].ulPin;
46 46
   else

+ 8
- 12
Marlin/src/module/configuration_store.cpp Visa fil

@@ -37,7 +37,7 @@
37 37
  */
38 38
 
39 39
 // Change EEPROM version if the structure changes
40
-#define EEPROM_VERSION "V59"
40
+#define EEPROM_VERSION "V60"
41 41
 #define EEPROM_OFFSET 0
42 42
 
43 43
 // Check the integrity of data offsets.
@@ -214,8 +214,8 @@ typedef struct SettingsDataStruct {
214 214
   // ULTIPANEL
215 215
   //
216 216
   int16_t lcd_preheat_hotend_temp[2],                   // M145 S0 H
217
-          lcd_preheat_bed_temp[2],                      // M145 S0 B
218
-          lcd_preheat_fan_speed[2];                     // M145 S0 F
217
+          lcd_preheat_bed_temp[2];                      // M145 S0 B
218
+  uint8_t lcd_preheat_fan_speed[2];                     // M145 S0 F
219 219
 
220 220
   //
221 221
   // PIDTEMP
@@ -630,8 +630,8 @@ void MarlinSettings::postprocess() {
630 630
 
631 631
     #if DISABLED(ULTIPANEL)
632 632
       constexpr int16_t lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
633
-                        lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
634
-                        lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
633
+                        lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED };
634
+      constexpr uint8_t lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
635 635
     #endif
636 636
 
637 637
     EEPROM_WRITE(lcd_preheat_hotend_temp);
@@ -1238,17 +1238,13 @@ void MarlinSettings::postprocess() {
1238 1238
       _FIELD_TEST(lcd_preheat_hotend_temp);
1239 1239
 
1240 1240
       #if DISABLED(ULTIPANEL)
1241
-        int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
1241
+        int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
1242
+        uint8_t lcd_preheat_fan_speed[2];
1242 1243
       #endif
1243 1244
       EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
1244 1245
       EEPROM_READ(lcd_preheat_bed_temp);    // 2 floats
1245 1246
       EEPROM_READ(lcd_preheat_fan_speed);   // 2 floats
1246 1247
 
1247
-      //EEPROM_ASSERT(
1248
-      //  WITHIN(lcd_preheat_fan_speed, 0, 255),
1249
-      //  "lcd_preheat_fan_speed out of range"
1250
-      //);
1251
-
1252 1248
       //
1253 1249
       // Hotend PID
1254 1250
       //
@@ -2489,7 +2485,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
2489 2485
         SERIAL_ECHOPAIR_P(port, "  M145 S", (int)i);
2490 2486
         SERIAL_ECHOPAIR_P(port, " H", TEMP_UNIT(lcd_preheat_hotend_temp[i]));
2491 2487
         SERIAL_ECHOPAIR_P(port, " B", TEMP_UNIT(lcd_preheat_bed_temp[i]));
2492
-        SERIAL_ECHOLNPAIR_P(port, " F", lcd_preheat_fan_speed[i]);
2488
+        SERIAL_ECHOLNPAIR_P(port, " F", int(lcd_preheat_fan_speed[i]));
2493 2489
       }
2494 2490
     #endif // ULTIPANEL
2495 2491
 

+ 4
- 4
Marlin/src/module/planner.cpp Visa fil

@@ -1187,8 +1187,8 @@ void Planner::recalculate() {
1187 1187
  * Maintain fans, paste extruder pressure,
1188 1188
  */
1189 1189
 void Planner::check_axes_activity() {
1190
-  unsigned char axis_active[NUM_AXIS] = { 0 },
1191
-                tail_fan_speed[FAN_COUNT];
1190
+  uint8_t axis_active[NUM_AXIS] = { 0 },
1191
+          tail_fan_speed[FAN_COUNT];
1192 1192
 
1193 1193
   #if ENABLED(BARICUDA)
1194 1194
     #if HAS_HEATER_1
@@ -1225,7 +1225,7 @@ void Planner::check_axes_activity() {
1225 1225
   }
1226 1226
   else {
1227 1227
     #if FAN_COUNT > 0
1228
-      for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fanSpeeds[i];
1228
+      for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fan_speed[i];
1229 1229
     #endif
1230 1230
 
1231 1231
     #if ENABLED(BARICUDA)
@@ -1774,7 +1774,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1774 1774
   #endif
1775 1775
 
1776 1776
   #if FAN_COUNT > 0
1777
-    for (uint8_t i = 0; i < FAN_COUNT; i++) block->fan_speed[i] = fanSpeeds[i];
1777
+    for (uint8_t i = 0; i < FAN_COUNT; i++) block->fan_speed[i] = fan_speed[i];
1778 1778
   #endif
1779 1779
 
1780 1780
   #if ENABLED(BARICUDA)

+ 1
- 1
Marlin/src/module/planner.h Visa fil

@@ -144,7 +144,7 @@ typedef struct {
144 144
            acceleration_steps_per_s2;       // acceleration steps/sec^2
145 145
 
146 146
   #if FAN_COUNT > 0
147
-    uint16_t fan_speed[FAN_COUNT];
147
+    uint8_t fan_speed[FAN_COUNT];
148 148
   #endif
149 149
 
150 150
   #if ENABLED(BARICUDA)

+ 3
- 3
Marlin/src/module/probe.cpp Visa fil

@@ -273,12 +273,12 @@ float zprobe_zoffset; // Initialized by settings.load()
273 273
       fans_paused = p;
274 274
       if (p)
275 275
         for (uint8_t x = 0; x < FAN_COUNT; x++) {
276
-          paused_fanSpeeds[x] = fanSpeeds[x];
277
-          fanSpeeds[x] = 0;
276
+          paused_fan_speed[x] = fan_speed[x];
277
+          fan_speed[x] = 0;
278 278
         }
279 279
       else
280 280
         for (uint8_t x = 0; x < FAN_COUNT; x++)
281
-          fanSpeeds[x] = paused_fanSpeeds[x];
281
+          fan_speed[x] = paused_fan_speed[x];
282 282
     }
283 283
   }
284 284
 

+ 1
- 1
Marlin/src/module/temperature.cpp Visa fil

@@ -97,7 +97,7 @@ int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
97 97
         Temperature::target_temperature[HOTENDS] = { 0 };
98 98
 
99 99
 #if ENABLED(AUTO_POWER_E_FANS)
100
-  int16_t Temperature::autofan_speed[HOTENDS] = { 0 };
100
+  uint8_t Temperature::autofan_speed[HOTENDS] = { 0 };
101 101
 #endif
102 102
 
103 103
 #if HAS_HEATED_BED

+ 1
- 1
Marlin/src/module/temperature.h Visa fil

@@ -123,7 +123,7 @@ class Temperature {
123 123
     static uint8_t soft_pwm_amount[HOTENDS];
124 124
 
125 125
     #if ENABLED(AUTO_POWER_E_FANS)
126
-      static int16_t autofan_speed[HOTENDS];
126
+      static uint8_t autofan_speed[HOTENDS];
127 127
     #endif
128 128
 
129 129
     #if ENABLED(FAN_SOFT_PWM)

Laddar…
Avbryt
Spara