Browse Source

Restore LED light color after pid tuning (#12082)

Giuliano Zaro 6 years ago
parent
commit
323c088356

+ 5
- 12
Marlin/src/feature/leds/leds.cpp View File

48
   );
48
   );
49
 #endif
49
 #endif
50
 
50
 
51
-#if ENABLED(LED_CONTROL_MENU)
51
+#if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
52
   LEDColor LEDLights::color;
52
   LEDColor LEDLights::color;
53
   bool LEDLights::lights_on;
53
   bool LEDLights::lights_on;
54
 #endif
54
 #endif
72
 
72
 
73
   #if ENABLED(NEOPIXEL_LED)
73
   #if ENABLED(NEOPIXEL_LED)
74
 
74
 
75
-    const uint32_t neocolor = pixels.Color(incol.r, incol.g, incol.b, incol.w);
75
+    const uint32_t neocolor = LEDColorWhite() == incol
76
+                            ? pixels.Color(NEO_WHITE)
77
+                            : pixels.Color(incol.r, incol.g, incol.b, incol.w);
76
     static uint16_t nextLed = 0;
78
     static uint16_t nextLed = 0;
77
 
79
 
78
     pixels.setBrightness(incol.i);
80
     pixels.setBrightness(incol.i);
117
     pca9632_set_led_color(incol);
119
     pca9632_set_led_color(incol);
118
   #endif
120
   #endif
119
 
121
 
120
-  #if ENABLED(LED_CONTROL_MENU)
122
+  #if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
121
     // Don't update the color when OFF
123
     // Don't update the color when OFF
122
     lights_on = !incol.is_off();
124
     lights_on = !incol.is_off();
123
     if (lights_on) color = incol;
125
     if (lights_on) color = incol;
124
   #endif
126
   #endif
125
 }
127
 }
126
 
128
 
127
-void LEDLights::set_white() {
128
-  #if ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(BLINKM) || ENABLED(PCA9632)
129
-    set_color(LEDColorWhite());
130
-  #endif
131
-  #if ENABLED(NEOPIXEL_LED)
132
-    set_neopixel_color(pixels.Color(NEO_WHITE));
133
-  #endif
134
-}
135
-
136
 #if ENABLED(LED_CONTROL_MENU)
129
 #if ENABLED(LED_CONTROL_MENU)
137
   void LEDLights::toggle() { if (lights_on) set_off(); else update(); }
130
   void LEDLights::toggle() { if (lights_on) set_off(); else update(); }
138
 #endif
131
 #endif

+ 9
- 3
Marlin/src/feature/leds/leds.h View File

115
  * Color helpers and presets
115
  * Color helpers and presets
116
  */
116
  */
117
 #if HAS_WHITE_LED
117
 #if HAS_WHITE_LED
118
-  #define LEDColorWhite() LEDColor(0, 0, 0, 255)
119
   #if ENABLED(NEOPIXEL_LED)
118
   #if ENABLED(NEOPIXEL_LED)
120
     #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W, I)
119
     #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W, I)
121
   #else
120
   #else
122
     #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W)
121
     #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W)
123
   #endif
122
   #endif
123
+  #define LEDColorWhite() LEDColor(0, 0, 0, 255)
124
 #else
124
 #else
125
   #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B)
125
   #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B)
126
   #define LEDColorWhite() LEDColor(255, 255, 255)
126
   #define LEDColorWhite() LEDColor(255, 255, 255)
164
     );
164
     );
165
   }
165
   }
166
 
166
 
167
-  static void set_white();
168
   FORCE_INLINE static void set_off()   { set_color(LEDColorOff()); }
167
   FORCE_INLINE static void set_off()   { set_color(LEDColorOff()); }
169
   FORCE_INLINE static void set_green() { set_color(LEDColorGreen()); }
168
   FORCE_INLINE static void set_green() { set_color(LEDColorGreen()); }
169
+  FORCE_INLINE static void set_white() { set_color(LEDColorWhite()); }
170
 
170
 
171
   #if ENABLED(LED_COLOR_PRESETS)
171
   #if ENABLED(LED_COLOR_PRESETS)
172
     static const LEDColor defaultLEDColor;
172
     static const LEDColor defaultLEDColor;
179
     FORCE_INLINE static void set_violet()   { set_color(LEDColorViolet()); }
179
     FORCE_INLINE static void set_violet()   { set_color(LEDColorViolet()); }
180
   #endif
180
   #endif
181
 
181
 
182
-  #if ENABLED(LED_CONTROL_MENU)
182
+  #if ENABLED(PRINTER_EVENT_LEDS)
183
+    FORCE_INLINE static LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
184
+  #endif
185
+
186
+  #if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
183
     static LEDColor color; // last non-off color
187
     static LEDColor color; // last non-off color
184
     static bool lights_on; // the last set color was "on"
188
     static bool lights_on; // the last set color was "on"
189
+  #endif
190
+  #if ENABLED(LED_CONTROL_MENU)
185
     static void toggle();  // swap "off" with color
191
     static void toggle();  // swap "off" with color
186
     FORCE_INLINE static void update() { set_color(color); }
192
     FORCE_INLINE static void update() { set_color(color); }
187
   #endif
193
   #endif

+ 4
- 4
Marlin/src/feature/leds/printer_event_leds.h View File

38
 
38
 
39
 public:
39
 public:
40
   #if HAS_TEMP_HOTEND
40
   #if HAS_TEMP_HOTEND
41
-    FORCE_INLINE static void onHotendHeatingStart() { old_intensity = 0; }
41
+    FORCE_INLINE static LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
42
     static void onHotendHeating(const float &start, const float &current, const float &target);
42
     static void onHotendHeating(const float &start, const float &current, const float &target);
43
   #endif
43
   #endif
44
 
44
 
45
   #if HAS_HEATED_BED
45
   #if HAS_HEATED_BED
46
-    FORCE_INLINE static void onBedHeatingStart() { old_intensity = 127; }
46
+    FORCE_INLINE static LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
47
     static void onBedHeating(const float &start, const float &current, const float &target);
47
     static void onBedHeating(const float &start, const float &current, const float &target);
48
   #endif
48
   #endif
49
 
49
 
50
   #if HAS_TEMP_HOTEND || HAS_HEATED_BED
50
   #if HAS_TEMP_HOTEND || HAS_HEATED_BED
51
-    FORCE_INLINE static void onHeated()     { leds.set_white(); }
52
-    FORCE_INLINE static void onHeatersOff() { leds.set_off(); }
51
+    FORCE_INLINE static void onHeated() { leds.set_color(LEDColorWhite()); }
52
+    FORCE_INLINE static void onPidTuningDone(LEDColor c) { leds.set_color(c); }
53
   #endif
53
   #endif
54
 
54
 
55
   #if ENABLED(SDSUPPORT)
55
   #if ENABLED(SDSUPPORT)

+ 8
- 4
Marlin/src/module/temperature.cpp View File

251
     #if HAS_PID_FOR_BOTH
251
     #if HAS_PID_FOR_BOTH
252
       #define GHV(B,H) (hotend < 0 ? (B) : (H))
252
       #define GHV(B,H) (hotend < 0 ? (B) : (H))
253
       #define SHV(S,B,H) do{ if (hotend < 0) S##_bed = B; else S [hotend] = H; }while(0)
253
       #define SHV(S,B,H) do{ if (hotend < 0) S##_bed = B; else S [hotend] = H; }while(0)
254
-      #define ONHEATINGSTART() do{ if (hotend < 0) printerEventLEDs.onBedHeatingStart(); else printerEventLEDs.onHotendHeatingStart(); }while(0)
254
+      #define ONHEATINGSTART() (hotend < 0 ? printerEventLEDs.onBedHeatingStart() : printerEventLEDs.onHotendHeatingStart())
255
       #define ONHEATING(S,C,T) do{ if (hotend < 0) printerEventLEDs.onBedHeating(S,C,T); else printerEventLEDs.onHotendHeating(S,C,T); }while(0)
255
       #define ONHEATING(S,C,T) do{ if (hotend < 0) printerEventLEDs.onBedHeating(S,C,T); else printerEventLEDs.onHotendHeating(S,C,T); }while(0)
256
     #elif ENABLED(PIDTEMPBED)
256
     #elif ENABLED(PIDTEMPBED)
257
       #define GHV(B,H) B
257
       #define GHV(B,H) B
311
     wait_for_heatup = true; // Can be interrupted with M108
311
     wait_for_heatup = true; // Can be interrupted with M108
312
     #if ENABLED(PRINTER_EVENT_LEDS)
312
     #if ENABLED(PRINTER_EVENT_LEDS)
313
       const float start_temp = GHV(current_temperature_bed, current_temperature[hotend]);
313
       const float start_temp = GHV(current_temperature_bed, current_temperature[hotend]);
314
-      ONHEATINGSTART();
314
+      LEDColor color = ONHEATINGSTART();
315
     #endif
315
     #endif
316
 
316
 
317
     // PID Tuning loop
317
     // PID Tuning loop
492
             _SET_BED_PID();
492
             _SET_BED_PID();
493
           #endif
493
           #endif
494
         }
494
         }
495
+        #if ENABLED(PRINTER_EVENT_LEDS)
496
+          printerEventLEDs.onPidTuningDone(color);
497
+        #endif
498
+
495
         return;
499
         return;
496
       }
500
       }
497
       lcd_update();
501
       lcd_update();
498
     }
502
     }
499
     disable_all_heaters();
503
     disable_all_heaters();
500
     #if ENABLED(PRINTER_EVENT_LEDS)
504
     #if ENABLED(PRINTER_EVENT_LEDS)
501
-      printerEventLEDs.onHeatersOff();
505
+      printerEventLEDs.onPidTuningDone(color);
502
     #endif
506
     #endif
503
   }
507
   }
504
 
508
 
2525
       if (wait_for_heatup) {
2529
       if (wait_for_heatup) {
2526
         lcd_reset_status();
2530
         lcd_reset_status();
2527
         #if ENABLED(PRINTER_EVENT_LEDS)
2531
         #if ENABLED(PRINTER_EVENT_LEDS)
2528
-          printerEventLEDs.onHeated();
2532
+          printerEventLEDs.onHeatingDone();
2529
         #endif
2533
         #endif
2530
       }
2534
       }
2531
 
2535
 

Loading…
Cancel
Save