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.

hotend_idle.cpp 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. /**
  23. * Hotend Idle Timeout
  24. * Prevent filament in the nozzle from charring and causing a critical jam.
  25. */
  26. #include "../inc/MarlinConfig.h"
  27. #if ENABLED(HOTEND_IDLE_TIMEOUT)
  28. #include "hotend_idle.h"
  29. #include "../gcode/gcode.h"
  30. #include "../module/temperature.h"
  31. #include "../module/motion.h"
  32. #include "../module/planner.h"
  33. #include "../lcd/marlinui.h"
  34. extern HotendIdleProtection hotend_idle;
  35. millis_t HotendIdleProtection::next_protect_ms = 0;
  36. void HotendIdleProtection::check_hotends(const millis_t &ms) {
  37. bool do_prot = false;
  38. HOTEND_LOOP() {
  39. const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued());
  40. if (thermalManager.degHotend(e) >= (HOTEND_IDLE_MIN_TRIGGER) && !busy) {
  41. do_prot = true; break;
  42. }
  43. }
  44. if (bool(next_protect_ms) != do_prot)
  45. next_protect_ms = do_prot ? ms + hp_interval : 0;
  46. }
  47. void HotendIdleProtection::check_e_motion(const millis_t &ms) {
  48. static float old_e_position = 0;
  49. if (old_e_position != current_position.e) {
  50. old_e_position = current_position.e; // Track filament motion
  51. if (next_protect_ms) // If some heater is on then...
  52. next_protect_ms = ms + hp_interval; // ...delay the timeout till later
  53. }
  54. }
  55. void HotendIdleProtection::check() {
  56. const millis_t ms = millis(); // Shared millis
  57. check_hotends(ms); // Any hotends need protection?
  58. check_e_motion(ms); // Motion will protect them
  59. // Hot and not moving for too long...
  60. if (next_protect_ms && ELAPSED(ms, next_protect_ms))
  61. timed_out();
  62. }
  63. // Lower (but don't raise) hotend / bed temperatures
  64. void HotendIdleProtection::timed_out() {
  65. next_protect_ms = 0;
  66. SERIAL_ECHOLNPGM("Hotend Idle Timeout");
  67. LCD_MESSAGE(MSG_HOTEND_IDLE_TIMEOUT);
  68. HOTEND_LOOP() {
  69. if ((HOTEND_IDLE_NOZZLE_TARGET) < thermalManager.degTargetHotend(e))
  70. thermalManager.setTargetHotend(HOTEND_IDLE_NOZZLE_TARGET, e);
  71. }
  72. #if HAS_HEATED_BED
  73. if ((HOTEND_IDLE_BED_TARGET) < thermalManager.degTargetBed())
  74. thermalManager.setTargetBed(HOTEND_IDLE_BED_TARGET);
  75. #endif
  76. }
  77. #endif // HOTEND_IDLE_TIMEOUT