My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

printer_event_leds.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * printer_event_leds.h - LED color changing based on printer status
  25. */
  26. #include "leds.h"
  27. #include "../../inc/MarlinConfig.h"
  28. class PrinterEventLEDs {
  29. private:
  30. static uint8_t old_intensity;
  31. #if HAS_LEDS_OFF_FLAG
  32. static bool leds_off_after_print;
  33. #endif
  34. static inline void set_done() {
  35. #if ENABLED(LED_COLOR_PRESETS)
  36. leds.set_default();
  37. #else
  38. leds.set_off();
  39. #endif
  40. }
  41. public:
  42. #if HAS_TEMP_HOTEND
  43. static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
  44. static void onHotendHeating(const float &start, const float &current, const float &target);
  45. #endif
  46. #if HAS_HEATED_BED
  47. static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
  48. static void onBedHeating(const float &start, const float &current, const float &target);
  49. #endif
  50. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  51. static inline void onHeatingDone() { leds.set_white(); }
  52. static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); }
  53. #endif
  54. #if ENABLED(SDSUPPORT)
  55. static inline void onPrintCompleted() {
  56. leds.set_green();
  57. #if HAS_LEDS_OFF_FLAG
  58. leds_off_after_print = true;
  59. #else
  60. safe_delay(2000);
  61. set_done();
  62. #endif
  63. }
  64. static inline void onResumeAfterWait() {
  65. #if HAS_LEDS_OFF_FLAG
  66. if (leds_off_after_print) {
  67. set_done();
  68. leds_off_after_print = false;
  69. }
  70. #endif
  71. }
  72. #endif // SDSUPPORT
  73. };
  74. extern PrinterEventLEDs printerEventLEDs;