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.

M303.cpp 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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 "../../inc/MarlinConfig.h"
  23. #if HAS_PID_HEATING
  24. #include "../gcode.h"
  25. #include "../../module/temperature.h"
  26. #if ENABLED(EXTENSIBLE_UI)
  27. #include "../../lcd/extensible_ui/ui_api.h"
  28. #endif
  29. /**
  30. * M303: PID relay autotune
  31. *
  32. * S<temperature> sets the target temperature. (default 150C / 70C)
  33. * E<extruder> (-1 for the bed) (default 0)
  34. * C<cycles> Minimum 3. Default 5.
  35. * U<bool> with a non-zero value will apply the result to current settings
  36. */
  37. void GcodeSuite::M303() {
  38. #if ENABLED(PIDTEMPBED)
  39. #define SI H_BED
  40. #else
  41. #define SI H_E0
  42. #endif
  43. #if ENABLED(PIDTEMP)
  44. #define EI HOTENDS - 1
  45. #else
  46. #define EI H_BED
  47. #endif
  48. const heater_ind_t e = (heater_ind_t)parser.intval('E');
  49. if (!WITHIN(e, SI, EI)) {
  50. SERIAL_ECHOLNPGM(MSG_PID_BAD_EXTRUDER_NUM);
  51. #if ENABLED(EXTENSIBLE_UI)
  52. ExtUI::OnPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM);
  53. #endif
  54. return;
  55. }
  56. const int c = parser.intval('C', 5);
  57. const bool u = parser.boolval('U');
  58. const int16_t temp = parser.celsiusval('S', e < 0 ? 70 : 150);
  59. #if DISABLED(BUSY_WHILE_HEATING)
  60. KEEPALIVE_STATE(NOT_BUSY);
  61. #endif
  62. thermalManager.PID_autotune(temp, e, c, u);
  63. }
  64. #endif // HAS_PID_HEATING