My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

printer_event_leds.h 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * feature/leds/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() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); }
  35. public:
  36. #if HAS_TEMP_HOTEND
  37. static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
  38. static void onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target);
  39. #endif
  40. #if HAS_HEATED_BED
  41. static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
  42. static void onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target);
  43. #endif
  44. #if HAS_HEATED_CHAMBER
  45. static inline LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); }
  46. static void onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target);
  47. #endif
  48. #if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER
  49. static inline void onHeatingDone() { leds.set_white(); }
  50. static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); }
  51. #endif
  52. #if ENABLED(SDSUPPORT)
  53. static inline void onPrintCompleted() {
  54. leds.set_green();
  55. #if HAS_LEDS_OFF_FLAG
  56. leds_off_after_print = true;
  57. #else
  58. safe_delay(2000);
  59. set_done();
  60. #endif
  61. }
  62. static inline void onResumeAfterWait() {
  63. #if HAS_LEDS_OFF_FLAG
  64. if (leds_off_after_print) {
  65. set_done();
  66. leds_off_after_print = false;
  67. }
  68. #endif
  69. }
  70. #endif // SDSUPPORT
  71. };
  72. extern PrinterEventLEDs printerEventLEDs;