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.

M412.cpp 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include "../../../inc/MarlinConfig.h"
  23. #if HAS_FILAMENT_SENSOR
  24. #include "../../gcode.h"
  25. #include "../../../feature/runout.h"
  26. /**
  27. * M412: Enable / Disable filament runout detection
  28. *
  29. * Parameters
  30. * R : Reset the runout sensor
  31. * S<bool> : Reset and enable/disable the runout sensor
  32. * H<bool> : Enable/disable host handling of filament runout
  33. * D<linear> : Extra distance to continue after runout is triggered
  34. */
  35. void GcodeSuite::M412() {
  36. if (parser.seen("RS"
  37. TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, "D")
  38. TERN_(HOST_ACTION_COMMANDS, "H")
  39. )) {
  40. #if ENABLED(HOST_ACTION_COMMANDS)
  41. if (parser.seen('H')) runout.host_handling = parser.value_bool();
  42. #endif
  43. const bool seenR = parser.seen_test('R'), seenS = parser.seen('S');
  44. if (seenR || seenS) runout.reset();
  45. if (seenS) runout.enabled = parser.value_bool();
  46. #if HAS_FILAMENT_RUNOUT_DISTANCE
  47. if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units());
  48. #endif
  49. }
  50. else {
  51. SERIAL_ECHO_START();
  52. SERIAL_ECHOPGM("Filament runout ");
  53. serialprint_onoff(runout.enabled);
  54. #if HAS_FILAMENT_RUNOUT_DISTANCE
  55. SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(), "mm");
  56. #endif
  57. #if ENABLED(HOST_ACTION_COMMANDS)
  58. SERIAL_ECHOPGM(" ; Host handling ");
  59. serialprint_onoff(runout.host_handling);
  60. #endif
  61. SERIAL_EOL();
  62. }
  63. }
  64. void GcodeSuite::M412_report(const bool forReplay/*=true*/) {
  65. report_heading_etc(forReplay, PSTR(STR_FILAMENT_RUNOUT_SENSOR));
  66. SERIAL_ECHOLNPGM(
  67. " M412 S", runout.enabled
  68. #if HAS_FILAMENT_RUNOUT_DISTANCE
  69. , " D", LINEAR_UNIT(runout.runout_distance())
  70. #endif
  71. , " ; Sensor "
  72. );
  73. serialprintln_onoff(runout.enabled);
  74. }
  75. #endif // HAS_FILAMENT_SENSOR