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.

M80_M81.cpp 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. #include "../gcode.h"
  23. #include "../../module/temperature.h"
  24. #include "../../module/stepper.h"
  25. #include "../../inc/MarlinConfig.h"
  26. #if ENABLED(ULTIPANEL)
  27. #include "../../lcd/ultralcd.h"
  28. #endif
  29. #if HAS_POWER_SWITCH
  30. // Could be moved to a feature, but this is all the data
  31. bool powersupply_on =
  32. #if ENABLED(PS_DEFAULT_OFF)
  33. false
  34. #else
  35. true
  36. #endif
  37. ;
  38. #if ENABLED(HAVE_TMC2130)
  39. #include "../../feature/tmc2130.h"
  40. #endif
  41. /**
  42. * M80 : Turn on the Power Supply
  43. * M80 S : Report the current state and exit
  44. */
  45. void GcodeSuite::M80() {
  46. // S: Report the current power supply state and exit
  47. if (parser.seen('S')) {
  48. serialprintPGM(powersupply_on ? PSTR("PS:1\n") : PSTR("PS:0\n"));
  49. return;
  50. }
  51. OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND
  52. /**
  53. * If you have a switch on suicide pin, this is useful
  54. * if you want to start another print with suicide feature after
  55. * a print without suicide...
  56. */
  57. #if HAS_SUICIDE
  58. OUT_WRITE(SUICIDE_PIN, HIGH);
  59. #endif
  60. #if ENABLED(HAVE_TMC2130)
  61. delay(100);
  62. tmc2130_init(); // Settings only stick when the driver has power
  63. #endif
  64. powersupply_on = true;
  65. #if ENABLED(ULTIPANEL)
  66. LCD_MESSAGEPGM(WELCOME_MSG);
  67. #endif
  68. }
  69. #endif // HAS_POWER_SWITCH
  70. /**
  71. * M81: Turn off Power, including Power Supply, if there is one.
  72. *
  73. * This code should ALWAYS be available for EMERGENCY SHUTDOWN!
  74. */
  75. void GcodeSuite::M81() {
  76. thermalManager.disable_all_heaters();
  77. stepper.finish_and_disable();
  78. #if FAN_COUNT > 0
  79. for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
  80. #if ENABLED(PROBING_FANS_OFF)
  81. fans_paused = false;
  82. ZERO(paused_fanSpeeds);
  83. #endif
  84. #endif
  85. safe_delay(1000); // Wait 1 second before switching off
  86. #if HAS_SUICIDE
  87. stepper.synchronize();
  88. suicide();
  89. #elif HAS_POWER_SWITCH
  90. OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
  91. powersupply_on = false;
  92. #endif
  93. #if ENABLED(ULTIPANEL)
  94. LCD_MESSAGEPGM(MACHINE_NAME " " MSG_OFF ".");
  95. #endif
  96. }