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.

M106_M107.cpp 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include "../../inc/MarlinConfig.h"
  23. #if HAS_FAN
  24. #include "../gcode.h"
  25. #include "../../module/motion.h"
  26. #include "../../module/temperature.h"
  27. #if ENABLED(SINGLENOZZLE)
  28. #define _ALT_P active_extruder
  29. #define _CNT_P EXTRUDERS
  30. #else
  31. #define _ALT_P _MIN(active_extruder, FAN_COUNT - 1)
  32. #define _CNT_P FAN_COUNT
  33. #endif
  34. /**
  35. * M106: Set Fan Speed
  36. *
  37. * S<int> Speed between 0-255
  38. * P<index> Fan index, if more than one fan
  39. *
  40. * With EXTRA_FAN_SPEED enabled:
  41. *
  42. * T<int> Restore/Use/Set Temporary Speed:
  43. * 1 = Restore previous speed after T2
  44. * 2 = Use temporary speed set with T3-255
  45. * 3-255 = Set the speed for use with T2
  46. */
  47. void GcodeSuite::M106() {
  48. const uint8_t p = parser.byteval('P', _ALT_P);
  49. if (p < _CNT_P) {
  50. #if ENABLED(EXTRA_FAN_SPEED)
  51. const uint16_t t = parser.intval('T');
  52. if (t > 0) return thermalManager.set_temp_fan_speed(p, t);
  53. #endif
  54. uint16_t d = parser.seen('A') ? thermalManager.fan_speed[active_extruder] : 255;
  55. uint16_t s = parser.ushortval('S', d);
  56. NOMORE(s, 255U);
  57. thermalManager.set_fan_speed(p, s);
  58. }
  59. }
  60. /**
  61. * M107: Fan Off
  62. */
  63. void GcodeSuite::M107() {
  64. const uint8_t p = parser.byteval('P', _ALT_P);
  65. thermalManager.set_fan_speed(p, 0);
  66. }
  67. #endif // HAS_FAN