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 3.0KB

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