My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

M106_M107.cpp 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 "../../inc/MarlinConfig.h"
  23. #if FAN_COUNT > 0
  24. #include "../gcode.h"
  25. #include "../../Marlin.h" // for fan_speed
  26. #include "../../module/motion.h"
  27. #if ENABLED(SINGLENOZZLE)
  28. #include "../../module/tool_change.h"
  29. #endif
  30. /**
  31. * M106: Set Fan Speed
  32. *
  33. * S<int> Speed between 0-255
  34. * P<index> Fan index, if more than one fan
  35. *
  36. * With EXTRA_FAN_SPEED enabled:
  37. *
  38. * T<int> Restore/Use/Set Temporary Speed:
  39. * 1 = Restore previous speed after T2
  40. * 2 = Use temporary speed set with T3-255
  41. * 3-255 = Set the speed for use with T2
  42. */
  43. void GcodeSuite::M106() {
  44. const uint8_t p = parser.byteval('P', active_extruder);
  45. if (p < MIN(EXTRUDERS, FAN_COUNT)) {
  46. uint16_t s = parser.ushortval('S', 255);
  47. NOMORE(s, 255);
  48. uint8_t np = p;
  49. #if ENABLED(SINGLENOZZLE)
  50. if (p != active_extruder) {
  51. if (p < EXTRUDERS) singlenozzle_fan_speed[p] = s;
  52. return;
  53. }
  54. np = 0; // Always use fan index 0 with SINGLENOZZLE
  55. #endif
  56. #if ENABLED(EXTRA_FAN_SPEED)
  57. const int16_t t = parser.intval('T');
  58. if (t > 0) {
  59. switch (t) {
  60. case 1:
  61. fan_speed[np] = old_fan_speed[np];
  62. break;
  63. case 2:
  64. old_fan_speed[np] = fan_speed[np];
  65. fan_speed[np] = new_fan_speed[np];
  66. break;
  67. default:
  68. new_fan_speed[np] = MIN(t, 255U);
  69. break;
  70. }
  71. return;
  72. }
  73. #endif // EXTRA_FAN_SPEED
  74. fan_speed[np] = s;
  75. }
  76. }
  77. /**
  78. * M107: Fan Off
  79. */
  80. void GcodeSuite::M107() {
  81. const uint16_t p = parser.byteval('P', active_extruder);
  82. #if ENABLED(SINGLENOZZLE)
  83. if (p != active_extruder) {
  84. if (p < EXTRUDERS) singlenozzle_fan_speed[p] = 0;
  85. return;
  86. }
  87. #endif
  88. if (p < MIN(EXTRUDERS, FAN_COUNT)) fan_speed[p] = 0;
  89. }
  90. #endif // FAN_COUNT > 0