NeoPixelTopologyDump.ino 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //----------------------------------------------------------------------
  2. // NeoPixelTopologyDump
  3. // This will dump to the serial output a grid map of the defined topology
  4. // The output is displayed as row column labeled grid with the NeoPixelBus
  5. // index of the pixel at the intersection of the row and column
  6. //
  7. // This is useful in visualising the layout of your panel so you can
  8. // confirm you have the correct pattern
  9. //
  10. // It does not require that you have the actual panel connected
  11. //----------------------------------------------------------------------
  12. #include <NeoPixelAnimator.h>
  13. #include <NeoPixelBus.h>
  14. // uncomment one of these that matches your panel pixel layouts and
  15. // how you want them rotated. Not all the rotations are listed here
  16. // but you can modifiy the name to include the rotation of 90,180, or 270.
  17. typedef ColumnMajorAlternatingLayout MyPanelLayout;
  18. // typedef ColumnMajorLayout MyPanelLayout;
  19. // typedef RowMajorAlternatingLayout MyPanelLayout;
  20. // typedef RowMajorLayout MyPanelLayout;
  21. // typedef RowMajor90Layout MyPanelLayout; // note rotation 90 was used
  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. NeoTopology<MyPanelLayout> topo(PanelWidth, PanelHeight);
  26. void DumpTopo()
  27. {
  28. Serial.println();
  29. Serial.print("\t\t");
  30. for (int x = 0; x < topo.getWidth(); x++)
  31. {
  32. Serial.print(x);
  33. Serial.print("\t");
  34. }
  35. Serial.println();
  36. Serial.print("\t--");
  37. for (int x = 0; x < topo.getWidth(); x++)
  38. {
  39. Serial.print("--------");
  40. }
  41. Serial.println();
  42. for (int y = 0; y < topo.getHeight(); y++)
  43. {
  44. Serial.print(" ");
  45. Serial.print(y);
  46. Serial.print("\t|\t");
  47. for (int x = 0; x < topo.getWidth(); x++)
  48. {
  49. Serial.print(topo.Map(x, y));
  50. Serial.print("\t");
  51. }
  52. Serial.println();
  53. }
  54. }
  55. void setup()
  56. {
  57. Serial.begin(115200);
  58. while (!Serial); // wait for serial attach
  59. DumpTopo();
  60. }
  61. void loop()
  62. {
  63. }