NeoPixelMosaicTest.ino 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //----------------------------------------------------------------------
  2. // NeoPixelTopologyTest
  3. // This will display specific colors in specific locations on the led panels
  4. //
  5. // This is useful in confirming the layout of your panels
  6. //
  7. // It does require that you have the actual panels connected
  8. //----------------------------------------------------------------------
  9. #include <NeoPixelAnimator.h>
  10. #include <NeoPixelBus.h>
  11. // uncomment one of these that matches your panel pixel layouts
  12. // rotation is ignored for mosaic as it applies a rotation for you
  13. // that is specific to the location of the panel within the mosaic
  14. // to reduce connection lengths
  15. typedef ColumnMajorAlternatingLayout MyPanelLayout;
  16. // typedef ColumnMajorLayout MyPanelLayout;
  17. // typedef RowMajorAlternatingLayout MyPanelLayout;
  18. // typedef RowMajorLayout MyPanelLayout;
  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 uint8_t TileWidth = 4; // laid out in 4 panels x 2 panels mosaic
  23. const uint8_t TileHeight = 2;
  24. const uint16_t PixelCount = PanelWidth * PanelHeight * TileWidth * TileHeight;
  25. const uint8_t PixelPin = 2;
  26. NeoMosaic <MyPanelLayout> mosaic(
  27. PanelWidth,
  28. PanelHeight,
  29. TileWidth,
  30. TileHeight);
  31. NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
  32. // for esp8266 omit the pin
  33. //NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
  34. RgbColor red(128, 0, 0);
  35. RgbColor green(0, 128, 0);
  36. RgbColor blue(0, 0, 128);
  37. RgbColor white(128);
  38. // if using NeoRgbwFeature above, use this white instead to use
  39. // the correct white element of the LED
  40. //RgbwColor white(128);
  41. RgbColor black(0);
  42. const uint16_t left = 0;
  43. const uint16_t right = PanelWidth - 1;
  44. const uint16_t top = 0;
  45. const uint16_t bottom = PanelHeight - 1;
  46. void setup()
  47. {
  48. Serial.begin(115200);
  49. while (!Serial); // wait for serial attach
  50. Serial.println();
  51. Serial.println("Initializing...");
  52. strip.Begin();
  53. strip.Show();
  54. Serial.println();
  55. Serial.println("Running...");
  56. }
  57. void loop()
  58. {
  59. delay(2500);
  60. Serial.println();
  61. Serial.println("If your panel is correctly defined, you should see ...");
  62. Serial.println("Upper left is white.");
  63. Serial.println("Upper right is Red.");
  64. Serial.println("Lower right is Green");
  65. Serial.println("Lower Left is Blue");
  66. // use the topo to map the 2d cordinate to the pixel
  67. // and use that to SetPixelColor
  68. strip.SetPixelColor(mosaic.Map(left, top), white);
  69. strip.SetPixelColor(mosaic.Map(right, top), red);
  70. strip.SetPixelColor(mosaic.Map(right, bottom), green);
  71. strip.SetPixelColor(mosaic.Map(left, bottom), blue);
  72. strip.Show();
  73. delay(5000);
  74. Serial.println();
  75. Serial.println("Cleared to black ...");
  76. strip.ClearTo(black);
  77. strip.Show();
  78. }