NeoPixelTopologyTest.ino 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //----------------------------------------------------------------------
  2. // NeoPixelTopologyTest
  3. // This will display specific colors in specific locations on the led panel
  4. //
  5. // This is useful in confirming the layout of your panel
  6. //
  7. // It does require that you have the actual panel connected
  8. //----------------------------------------------------------------------
  9. #include <NeoPixelAnimator.h>
  10. #include <NeoPixelBus.h>
  11. // uncomment one of these that matches your panel pixel layouts and
  12. // how you want them rotated. Not all the rotations are listed here
  13. // but you can modifiy the name to include the rotation of 90,180, or 270.
  14. typedef ColumnMajorAlternatingLayout MyPanelLayout;
  15. // typedef ColumnMajorLayout MyPanelLayout;
  16. // typedef RowMajorAlternatingLayout MyPanelLayout;
  17. // typedef RowMajorLayout MyPanelLayout;
  18. // typedef RowMajor90Layout MyPanelLayout; // note rotation 90 was used
  19. // make sure to set these panel values to the sizes of yours
  20. const uint8_t PanelWidth = 8; // 8 pixel x 8 pixel matrix of leds
  21. const uint8_t PanelHeight = 8;
  22. const uint16_t PixelCount = PanelWidth * PanelHeight;
  23. const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
  24. NeoTopology<MyPanelLayout> topo(PanelWidth, PanelHeight);
  25. NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
  26. //NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
  27. //NeoPixelBus<NeoRgbwFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
  28. // for esp8266 omit the pin
  29. //NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
  30. RgbColor red(128, 0, 0);
  31. RgbColor green(0, 128, 0);
  32. RgbColor blue(0, 0, 128);
  33. RgbColor white(128);
  34. // if using NeoRgbwFeature above, use this white instead to use
  35. // the correct white element of the LED
  36. //RgbwColor white(128);
  37. RgbColor black(0);
  38. const uint16_t left = 0;
  39. const uint16_t right = PanelWidth - 1;
  40. const uint16_t top = 0;
  41. const uint16_t bottom = PanelHeight - 1;
  42. void setup()
  43. {
  44. Serial.begin(115200);
  45. while (!Serial); // wait for serial attach
  46. Serial.println();
  47. Serial.println("Initializing...");
  48. strip.Begin();
  49. strip.Show();
  50. Serial.println();
  51. Serial.println("Running...");
  52. }
  53. void loop()
  54. {
  55. delay(2500);
  56. Serial.println();
  57. Serial.println("If your panel is correctly defined, you should see ...");
  58. Serial.println("Upper left is white.");
  59. Serial.println("Upper right is Red.");
  60. Serial.println("Lower right is Green");
  61. Serial.println("Lower Left is Blue");
  62. // use the topo to map the 2d cordinate to the pixel
  63. // and use that to SetPixelColor
  64. strip.SetPixelColor(topo.Map(left, top), white);
  65. strip.SetPixelColor(topo.Map(right, top), red);
  66. strip.SetPixelColor(topo.Map(right, bottom), green);
  67. strip.SetPixelColor(topo.Map(left, bottom), blue);
  68. strip.Show();
  69. delay(5000);
  70. Serial.println();
  71. Serial.println("Cleared to black ...");
  72. strip.ClearTo(black);
  73. strip.Show();
  74. }