My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

M150.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../../inc/MarlinConfig.h"
  23. #if HAS_COLOR_LEDS
  24. #include "../../gcode.h"
  25. #include "../../../feature/leds/leds.h"
  26. /**
  27. * M150: Set Status LED Color - Use R-U-B-W for R-G-B-W
  28. * and Brightness - Use P (for NEOPIXEL only)
  29. *
  30. * Always sets all 3 or 4 components. If a component is left out, set to 0.
  31. * If brightness is left out, no value changed
  32. *
  33. * With NEOPIXEL_LED:
  34. * I<index> Set the NeoPixel index to affect. Default: All
  35. *
  36. * With NEOPIXEL2_SEPARATE:
  37. * S<index> The NeoPixel strip to set. Default is index 0.
  38. *
  39. * Examples:
  40. *
  41. * M150 R255 ; Turn LED red
  42. * M150 R255 U127 ; Turn LED orange (PWM only)
  43. * M150 ; Turn LED off
  44. * M150 R U B ; Turn LED white
  45. * M150 W ; Turn LED white using a white LED
  46. * M150 P127 ; Set LED 50% brightness
  47. * M150 P ; Set LED full brightness
  48. * M150 I1 R ; Set NEOPIXEL index 1 to red
  49. * M150 S1 I1 R ; Set SEPARATE index 1 to red
  50. */
  51. void GcodeSuite::M150() {
  52. #if ENABLED(NEOPIXEL_LED)
  53. const uint8_t index = parser.intval('I', -1);
  54. #if ENABLED(NEOPIXEL2_SEPARATE)
  55. const uint8_t unit = parser.intval('S'),
  56. brightness = unit ? neo2.brightness() : neo.brightness();
  57. *(unit ? &neo2.neoindex : &neo.neoindex) = index;
  58. #else
  59. const uint8_t brightness = neo.brightness();
  60. neo.neoindex = index;
  61. #endif
  62. #endif
  63. const LEDColor color = MakeLEDColor(
  64. parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
  65. parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
  66. parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
  67. parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
  68. parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness
  69. );
  70. #if ENABLED(NEOPIXEL2_SEPARATE)
  71. if (unit == 1) { leds2.set_color(color); return; }
  72. #endif
  73. leds.set_color(color);
  74. }
  75. #endif // HAS_COLOR_LEDS