PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

99 lines
3.1KB

  1. /* OctoWS2811 BasicTest.ino - Basic RGB LED Test
  2. http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
  3. Copyright (c) 2013 Paul Stoffregen, PJRC.COM, LLC
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. Required Connections
  20. --------------------
  21. pin 2: LED Strip #1 OctoWS2811 drives 8 LED Strips.
  22. pin 14: LED strip #2 All 8 are the same length.
  23. pin 7: LED strip #3
  24. pin 8: LED strip #4 A 100 ohm resistor should used
  25. pin 6: LED strip #5 between each Teensy pin and the
  26. pin 20: LED strip #6 wire to the LED strip, to minimize
  27. pin 21: LED strip #7 high frequency ringining & noise.
  28. pin 5: LED strip #8
  29. pin 15 & 16 - Connect together, but do not use
  30. pin 4 - Do not use
  31. pin 3 - Do not use as PWM. Normal use is ok.
  32. This test is useful for checking if your LED strips work, and which
  33. color config (WS2811_RGB, WS2811_GRB, etc) they require.
  34. */
  35. #include <OctoWS2811.h>
  36. const int ledsPerStrip = 120;
  37. DMAMEM int displayMemory[ledsPerStrip*6];
  38. int drawingMemory[ledsPerStrip*6];
  39. const int config = WS2811_GRB | WS2811_800kHz;
  40. OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
  41. void setup() {
  42. leds.begin();
  43. leds.show();
  44. }
  45. #define RED 0xFF0000
  46. #define GREEN 0x00FF00
  47. #define BLUE 0x0000FF
  48. #define YELLOW 0xFFFF00
  49. #define PINK 0xFF1088
  50. #define ORANGE 0xE05800
  51. #define WHITE 0xFFFFFF
  52. // Less intense...
  53. /*
  54. #define RED 0x160000
  55. #define GREEN 0x001600
  56. #define BLUE 0x000016
  57. #define YELLOW 0x101400
  58. #define PINK 0x120009
  59. #define ORANGE 0x100400
  60. #define WHITE 0x101010
  61. */
  62. void loop() {
  63. int microsec = 2000000 / leds.numPixels(); // change them all in 2 seconds
  64. // uncomment for voltage controlled speed
  65. // millisec = analogRead(A9) / 40;
  66. colorWipe(RED, microsec);
  67. colorWipe(GREEN, microsec);
  68. colorWipe(BLUE, microsec);
  69. colorWipe(YELLOW, microsec);
  70. colorWipe(PINK, microsec);
  71. colorWipe(ORANGE, microsec);
  72. colorWipe(WHITE, microsec);
  73. }
  74. void colorWipe(int color, int wait)
  75. {
  76. for (int i=0; i < leds.numPixels(); i++) {
  77. leds.setPixel(i, color);
  78. leds.show();
  79. delayMicroseconds(wait);
  80. }
  81. }