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.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. public:
  35. #if HAS_TEMP_HOTEND
  36. static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
  37. static void onHotendHeating(const float &start, const float &current, const float &target);
  38. #endif
  39. #if HAS_HEATED_BED
  40. static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
  41. static void onBedHeating(const float &start, const float &current, const float &target);
  42. #endif
  43. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  44. static inline void onHeatingDone() { leds.set_color(LEDColorWhite()); }
  45. static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); }
  46. #endif
  47. #if ENABLED(SDSUPPORT)
  48. static inline void onPrintCompleted() {
  49. leds.set_green();
  50. #if HAS_LEDS_OFF_FLAG
  51. leds_off_after_print = true;
  52. #else
  53. safe_delay(2000);
  54. leds.set_off();
  55. #endif
  56. }
  57. static inline void onResumeAfterWait() {
  58. #if HAS_LEDS_OFF_FLAG
  59. if (leds_off_after_print) {
  60. leds.set_off();
  61. leds_off_after_print = false;
  62. }
  63. #endif
  64. }
  65. #endif // SDSUPPORT
  66. };
  67. extern PrinterEventLEDs printerEventLEDs;