My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

runout.cpp 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return; // Action already in progress. Purge triggered repeated runout.
  63. TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));
  64. #if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
  65. const char tool = '0'
  66. #if NUM_RUNOUT_SENSORS > 1
  67. + active_extruder
  68. #endif
  69. ;
  70. #endif
  71. //action:out_of_filament
  72. #if ENABLED(HOST_PROMPT_SUPPORT)
  73. host_action_prompt_begin(PROMPT_FILAMENT_RUNOUT, PSTR("FilamentRunout T"), tool);
  74. host_action_prompt_show();
  75. #endif
  76. const bool run_runout_script = !runout.host_handling;
  77. #if ENABLED(HOST_ACTION_COMMANDS)
  78. if (run_runout_script
  79. && ( strstr(FILAMENT_RUNOUT_SCRIPT, "M600")
  80. || strstr(FILAMENT_RUNOUT_SCRIPT, "M125")
  81. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  82. || strstr(FILAMENT_RUNOUT_SCRIPT, "M25")
  83. #endif
  84. )
  85. ) {
  86. host_action_paused(false);
  87. }
  88. else {
  89. // Legacy Repetier command for use until newer version supports standard dialog
  90. // To be removed later when pause command also triggers dialog
  91. #ifdef ACTION_ON_FILAMENT_RUNOUT
  92. host_action(PSTR(ACTION_ON_FILAMENT_RUNOUT " T"), false);
  93. SERIAL_CHAR(tool);
  94. SERIAL_EOL();
  95. #endif
  96. host_action_pause(false);
  97. }
  98. SERIAL_ECHOPGM(" " ACTION_REASON_ON_FILAMENT_RUNOUT " ");
  99. SERIAL_CHAR(tool);
  100. SERIAL_EOL();
  101. #endif // HOST_ACTION_COMMANDS
  102. if (run_runout_script)
  103. queue.inject_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
  104. }
  105. #endif // HAS_FILAMENT_SENSOR