My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 "../../Marlin.h" // for pin_is_protected
  24. #include "../../inc/MarlinConfig.h"
  25. /**
  26. * M42: Change pin status via GCode
  27. *
  28. * P<pin> Pin number (LED if omitted)
  29. * S<byte> Pin status from 0 - 255
  30. */
  31. void GcodeSuite::M42() {
  32. if (!parser.seenval('S')) return;
  33. const byte pin_status = parser.value_byte();
  34. int pin_number = PARSED_PIN_INDEX('P', GET_PIN_MAP_INDEX(LED_PIN));
  35. if (pin_number < 0) return;
  36. const pin_t pin = GET_PIN_MAP_PIN(pin_number);
  37. if (pin_is_protected(pin)) {
  38. SERIAL_ERROR_START();
  39. SERIAL_ERRORLNPGM(MSG_ERR_PROTECTED_PIN);
  40. return;
  41. }
  42. pinMode(pin, OUTPUT);
  43. digitalWrite(pin, pin_status);
  44. analogWrite(pin, pin_status);
  45. #if FAN_COUNT > 0
  46. switch (pin) {
  47. #if HAS_FAN0
  48. case FAN_PIN: fanSpeeds[0] = pin_status; break;
  49. #endif
  50. #if HAS_FAN1
  51. case FAN1_PIN: fanSpeeds[1] = pin_status; break;
  52. #endif
  53. #if HAS_FAN2
  54. case FAN2_PIN: fanSpeeds[2] = pin_status; break;
  55. #endif
  56. }
  57. #endif
  58. }