NeoPixelTilesTest.ino 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //----------------------------------------------------------------------
  2. // NeoPixelTilesTest
  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 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. // change this to be one of the layouts which will define the layout
  20. // of the panels themselves
  21. typedef ColumnMajorLayout MyTilesLayout;
  22. // make sure to set these panel values to the sizes of yours
  23. const uint8_t PanelWidth = 8; // 8 pixel x 8 pixel matrix of leds
  24. const uint8_t PanelHeight = 8;
  25. const uint8_t TileWidth = 4; // laid out in 4 panels x 2 panels mosaic
  26. const uint8_t TileHeight = 2;
  27. const uint16_t PixelCount = PanelWidth * PanelHeight * TileWidth * TileHeight;
  28. const uint8_t PixelPin = 2;
  29. NeoTiles <MyPanelLayout, MyTilesLayout> tiles(
  30. PanelWidth,
  31. PanelHeight,
  32. TileWidth,
  33. TileHeight);
  34. NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
  35. //NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
  36. //NeoPixelBus<NeoRgbwFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
  37. // for esp8266 omit the pin
  38. //NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
  39. RgbColor red(128, 0, 0);
  40. RgbColor green(0, 128, 0);
  41. RgbColor blue(0, 0, 128);
  42. RgbColor white(128);
  43. // if using NeoRgbwFeature above, use this white instead to use
  44. // the correct white element of the LED
  45. //RgbwColor white(128);
  46. RgbColor black(0);
  47. const uint16_t left = 0;
  48. const uint16_t right = PanelWidth - 1;
  49. const uint16_t top = 0;
  50. const uint16_t bottom = PanelHeight - 1;
  51. void setup()
  52. {
  53. Serial.begin(115200);
  54. while (!Serial); // wait for serial attach
  55. Serial.println();
  56. Serial.println("Initializing...");
  57. strip.Begin();
  58. strip.Show();
  59. Serial.println();
  60. Serial.println("Running...");
  61. }
  62. void loop()
  63. {
  64. delay(2500);
  65. Serial.println();
  66. Serial.println("If your panel is correctly defined, you should see ...");
  67. Serial.println("Upper left is white.");
  68. Serial.println("Upper right is Red.");
  69. Serial.println("Lower right is Green");
  70. Serial.println("Lower Left is Blue");
  71. // use the topo to map the 2d cordinate to the pixel
  72. // and use that to SetPixelColor
  73. strip.SetPixelColor(tiles.Map(left, top), white);
  74. strip.SetPixelColor(tiles.Map(right, top), red);
  75. strip.SetPixelColor(tiles.Map(right, bottom), green);
  76. strip.SetPixelColor(tiles.Map(left, bottom), blue);
  77. strip.Show();
  78. delay(5000);
  79. Serial.println();
  80. Serial.println("Cleared to black ...");
  81. strip.ClearTo(black);
  82. strip.Show();
  83. }