My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

neopixel.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #pragma once
  23. /**
  24. * Neopixel support
  25. */
  26. // ------------------------
  27. // Includes
  28. // ------------------------
  29. #include "../../inc/MarlinConfig.h"
  30. #include <Adafruit_NeoPixel.h>
  31. #include <stdint.h>
  32. // ------------------------
  33. // Defines
  34. // ------------------------
  35. #define MULTIPLE_NEOPIXEL_TYPES (defined(NEOPIXEL2_TYPE) && (NEOPIXEL2_TYPE != NEOPIXEL_TYPE))
  36. #define NEOPIXEL_IS_RGB (NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR)
  37. #define NEOPIXEL_IS_RGBW !NEOPIXEL_IS_RGB
  38. #if NEOPIXEL_IS_RGB
  39. #define NEO_WHITE 255, 255, 255, 0
  40. #else
  41. #define NEO_WHITE 0, 0, 0, 255
  42. #endif
  43. // ------------------------
  44. // Function prototypes
  45. // ------------------------
  46. class Marlin_NeoPixel {
  47. private:
  48. static Adafruit_NeoPixel adaneo1
  49. #if MULTIPLE_NEOPIXEL_TYPES
  50. , adaneo2
  51. #endif
  52. ;
  53. public:
  54. static void init();
  55. static void set_color_startup(const uint32_t c);
  56. static void set_color(const uint32_t c);
  57. #ifdef NEOPIXEL_BKGD_LED_INDEX
  58. static void set_color_background();
  59. #endif
  60. static inline void begin() {
  61. adaneo1.begin();
  62. #if MULTIPLE_NEOPIXEL_TYPES
  63. adaneo2.begin();
  64. #endif
  65. }
  66. static inline void set_pixel_color(const uint16_t n, const uint32_t c) {
  67. adaneo1.setPixelColor(n, c);
  68. #if MULTIPLE_NEOPIXEL_TYPES
  69. adaneo2.setPixelColor(n, c);
  70. #endif
  71. }
  72. static inline void set_brightness(const uint8_t b) {
  73. adaneo1.setBrightness(b);
  74. #if MULTIPLE_NEOPIXEL_TYPES
  75. adaneo2.setBrightness(b);
  76. #endif
  77. }
  78. static inline void show() {
  79. adaneo1.show();
  80. #if PIN_EXISTS(NEOPIXEL2)
  81. #if MULTIPLE_NEOPIXEL_TYPES
  82. adaneo2.show();
  83. #else
  84. adaneo1.setPin(NEOPIXEL2_PIN);
  85. adaneo1.show();
  86. adaneo1.setPin(NEOPIXEL_PIN);
  87. #endif
  88. #endif
  89. }
  90. #if 0
  91. bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p);
  92. #endif
  93. // Accessors
  94. static inline uint16_t pixels() { return adaneo1.numPixels(); }
  95. static inline uint8_t brightness() { return adaneo1.getBrightness(); }
  96. static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
  97. return adaneo1.Color(r, g, b, w);
  98. }
  99. };
  100. extern Marlin_NeoPixel neo;