My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

runout.cpp 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. * feature/runout.cpp - Runout sensor support
  24. */
  25. #include "../inc/MarlinConfigPre.h"
  26. #if HAS_FILAMENT_SENSOR
  27. #include "runout.h"
  28. FilamentMonitor runout;
  29. bool FilamentMonitorBase::enabled = true,
  30. FilamentMonitorBase::filament_ran_out; // = false
  31. #if ENABLED(HOST_ACTION_COMMANDS)
  32. bool FilamentMonitorBase::host_handling; // = false
  33. #endif
  34. #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
  35. //#define DEBUG_TOOLCHANGE_MIGRATION_FEATURE
  36. #include "../module/tool_change.h"
  37. #endif
  38. #if HAS_FILAMENT_RUNOUT_DISTANCE
  39. float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM;
  40. volatile float RunoutResponseDelayed::runout_mm_countdown[EXTRUDERS];
  41. #if ENABLED(FILAMENT_MOTION_SENSOR)
  42. uint8_t FilamentSensorEncoder::motion_detected;
  43. #endif
  44. #else
  45. int8_t RunoutResponseDebounced::runout_count; // = 0
  46. #endif
  47. //
  48. // Filament Runout event handler
  49. //
  50. #include "../MarlinCore.h"
  51. #include "../gcode/queue.h"
  52. #if ENABLED(HOST_ACTION_COMMANDS)
  53. #include "host_actions.h"
  54. #endif
  55. #if ENABLED(EXTENSIBLE_UI)
  56. #include "../lcd/extui/ui_api.h"
  57. #endif
  58. void event_filament_runout() {
  59. if (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return; // Action already in progress. Purge triggered repeated runout.
  60. #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
  61. if (migration.in_progress) {
  62. #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
  63. SERIAL_ECHOLN("Migration Already In Progress");
  64. #endif
  65. return; // Action already in progress. Purge triggered repeated runout.
  66. }
  67. if (migration.automode) {
  68. #if ENABLED(DEBUG_TOOLCHANGE_MIGRATION_FEATURE)
  69. SERIAL_ECHOLN("Migration Starting");
  70. #endif
  71. if (extruder_migration()) return;
  72. }
  73. #endif
  74. TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));
  75. #if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
  76. const char tool = '0'
  77. #if NUM_RUNOUT_SENSORS > 1
  78. + active_extruder
  79. #endif
  80. ;
  81. #endif
  82. //action:out_of_filament
  83. #if ENABLED(HOST_PROMPT_SUPPORT)
  84. host_action_prompt_begin(PROMPT_FILAMENT_RUNOUT, PSTR("FilamentRunout T"), tool);
  85. host_action_prompt_show();
  86. #endif
  87. const bool run_runout_script = !runout.host_handling;
  88. #if ENABLED(HOST_ACTION_COMMANDS)
  89. if (run_runout_script
  90. && ( strstr(FILAMENT_RUNOUT_SCRIPT, "M600")
  91. || strstr(FILAMENT_RUNOUT_SCRIPT, "M125")
  92. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  93. || strstr(FILAMENT_RUNOUT_SCRIPT, "M25")
  94. #endif
  95. )
  96. ) {
  97. host_action_paused(false);
  98. }
  99. else {
  100. // Legacy Repetier command for use until newer version supports standard dialog
  101. // To be removed later when pause command also triggers dialog
  102. #ifdef ACTION_ON_FILAMENT_RUNOUT
  103. host_action(PSTR(ACTION_ON_FILAMENT_RUNOUT " T"), false);
  104. SERIAL_CHAR(tool);
  105. SERIAL_EOL();
  106. #endif
  107. host_action_pause(false);
  108. }
  109. SERIAL_ECHOPGM(" " ACTION_REASON_ON_FILAMENT_RUNOUT " ");
  110. SERIAL_CHAR(tool);
  111. SERIAL_EOL();
  112. #endif // HOST_ACTION_COMMANDS
  113. if (run_runout_script)
  114. queue.inject_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
  115. }
  116. #endif // HAS_FILAMENT_SENSOR