Prusa MINI Firmware overview
printer_event_leds.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 /**
25  * printer_event_leds.h - LED color changing based on printer status
26  */
27 
28 #include "leds.h"
29 #include "../../inc/MarlinConfig.h"
30 
32 private:
33  static uint8_t old_intensity;
34 
35  #if HAS_LEDS_OFF_FLAG
36  static bool leds_off_after_print;
37  #endif
38 
39  static inline void set_done() {
40  #if ENABLED(LED_COLOR_PRESETS)
41  leds.set_default();
42  #else
43  leds.set_off();
44  #endif
45  }
46 
47 public:
48  #if HAS_TEMP_HOTEND
49  static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
50  static void onHotendHeating(const float &start, const float &current, const float &target);
51  #endif
52 
53  #if HAS_HEATED_BED
54  static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
55  static void onBedHeating(const float &start, const float &current, const float &target);
56  #endif
57 
58  #if HAS_TEMP_HOTEND || HAS_HEATED_BED
59  static inline void onHeatingDone() { leds.set_color(LEDColorWhite()); }
60  static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); }
61  #endif
62 
63  #if ENABLED(SDSUPPORT)
64 
65  static inline void onPrintCompleted() {
66  leds.set_green();
67  #if HAS_LEDS_OFF_FLAG
68  leds_off_after_print = true;
69  #else
70  safe_delay(2000);
71  set_done();
72  #endif
73  }
74 
75  static inline void onResumeAfterWait() {
76  #if HAS_LEDS_OFF_FLAG
77  if (leds_off_after_print) {
78  set_done();
79  leds_off_after_print = false;
80  }
81  #endif
82  }
83 
84  #endif // SDSUPPORT
85 };
86 
LEDLights::set_color
static void set_color(const LEDColor &color)
printerEventLEDs
PrinterEventLEDs printerEventLEDs
MakeLEDColor
#define MakeLEDColor(R, G, B, W, I)
Definition: leds.h:124
LEDColor::r
uint8_t r
Definition: leds.h:42
g29_auto.start
start
Definition: g29_auto.py:150
PrinterEventLEDs
Definition: printer_event_leds.h:31
leds.h
map
long map(long x, long in_min, long in_max, long out_min, long out_max)
Definition: WMath.cpp:49
LEDLights::set_off
static void set_off()
Definition: leds.h:176
LEDColor
Definition: leds.h:41
printer_event_leds.h
red
png_structrp int png_fixed_point red
Definition: png.h:1083
neo
Marlin_NeoPixel neo
LEDColorWhite
#define LEDColorWhite()
Definition: leds.h:143
constrain
#define constrain(amt, low, high)
Definition: wiring_constants.h:79
Marlin_NeoPixel::brightness
static uint8_t brightness()
Definition: neopixel.h:114
uint8_t
const uint8_t[]
Definition: 404_html.c:3
leds
LEDLights leds
safe_delay
void safe_delay(millis_t ms)
Definition: utility.cpp:28
LEDColor::g
uint8_t g
Definition: leds.h:42
createSpeedLookupTable.b
list b
Definition: createSpeedLookupTable.py:30
LEDLights::set_green
static void set_green()
Definition: leds.h:177
ENABLED
#define ENABLED(V...)
Definition: macros.h:177