My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 <http://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. /**
  35. * Called by FilamentSensorSwitch::run when filament is detected.
  36. * Called by FilamentSensorEncoder::block_completed when motion is detected.
  37. */
  38. void FilamentSensorBase::filament_present(const uint8_t extruder) {
  39. runout.filament_present(extruder); // calls response.filament_present(extruder)
  40. }
  41. #if ENABLED(FILAMENT_MOTION_SENSOR)
  42. uint8_t FilamentSensorEncoder::motion_detected;
  43. #endif
  44. #ifdef FILAMENT_RUNOUT_DISTANCE_MM
  45. float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM;
  46. volatile float RunoutResponseDelayed::runout_mm_countdown[EXTRUDERS];
  47. #else
  48. int8_t RunoutResponseDebounced::runout_count; // = 0
  49. #endif
  50. //
  51. // Filament Runout event handler
  52. //
  53. #include "../MarlinCore.h"
  54. #include "../gcode/queue.h"
  55. #if ENABLED(HOST_ACTION_COMMANDS)
  56. #include "host_actions.h"
  57. #endif
  58. #if ENABLED(EXTENSIBLE_UI)
  59. #include "../lcd/extui/ui_api.h"
  60. #endif
  61. void event_filament_runout() {
  62. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  63. if (did_pause_print) return; // Action already in progress. Purge triggered repeated runout.
  64. #endif
  65. #if ENABLED(EXTENSIBLE_UI)
  66. ExtUI::onFilamentRunout(ExtUI::getActiveTool());
  67. #endif
  68. #if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
  69. const char tool = '0'
  70. #if NUM_RUNOUT_SENSORS > 1
  71. + active_extruder
  72. #endif
  73. ;
  74. #endif
  75. //action:out_of_filament
  76. #if ENABLED(HOST_PROMPT_SUPPORT)
  77. host_action_prompt_begin(PROMPT_FILAMENT_RUNOUT, PSTR("FilamentRunout T"), tool);
  78. host_action_prompt_show();
  79. #endif
  80. const bool run_runout_script = !runout.host_handling;
  81. #if ENABLED(HOST_ACTION_COMMANDS)
  82. if (run_runout_script
  83. && ( strstr(FILAMENT_RUNOUT_SCRIPT, "M600")
  84. || strstr(FILAMENT_RUNOUT_SCRIPT, "M125")
  85. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  86. || strstr(FILAMENT_RUNOUT_SCRIPT, "M25")
  87. #endif
  88. )
  89. ) {
  90. host_action_paused(false);
  91. }
  92. else {
  93. // Legacy Repetier command for use until newer version supports standard dialog
  94. // To be removed later when pause command also triggers dialog
  95. #ifdef ACTION_ON_FILAMENT_RUNOUT
  96. host_action(PSTR(ACTION_ON_FILAMENT_RUNOUT " T"), false);
  97. SERIAL_CHAR(tool);
  98. SERIAL_EOL();
  99. #endif
  100. host_action_pause(false);
  101. }
  102. SERIAL_ECHOPGM(" " ACTION_REASON_ON_FILAMENT_RUNOUT " ");
  103. SERIAL_CHAR(tool);
  104. SERIAL_EOL();
  105. #endif // HOST_ACTION_COMMANDS
  106. if (run_runout_script)
  107. queue.inject_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
  108. }
  109. #endif // HAS_FILAMENT_SENSOR