Advertisement
Guest User

tearing-test.ino

a guest
Jan 24th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.97 KB | None | 0 0
  1. #include <MatrixHardware_Teensy4_ShieldV5_RBG.h>
  2. #include <SmartMatrix.h>
  3.  
  4. #define COLOR_DEPTH 24                  // Choose the color depth used for storing pixels in the layers: 24 or 48 (24 is good for most sketches - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24)
  5. const uint16_t kMatrixWidth = 128;      // Set to the width of your display, must be a multiple of 8
  6. const uint16_t kMatrixHeight = 64;      // Set to the height of your display
  7. const uint8_t kRefreshDepth = 36;       // Tradeoff of color quality vs refresh rate, max brightness, and RAM usage.  36 is typically good, drop down to 24 if you need to.  On Teensy, multiples of 3, up to 48: 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48.  On ESP32: 24, 36, 48
  8. const uint8_t kDmaBufferRows = 4;       // known working: 2-4, use 2 to save RAM, more to keep from dropping frames and automatically lowering refresh rate.  (This isn't used on ESP32, leave as default)
  9. const uint8_t kPanelType = SM_PANELTYPE_HUB75_64ROW_MOD32SCAN;   // Choose the configuration that matches your panels.  See more details in MatrixCommonHub75.h and the docs: https://github.com/pixelmatix/SmartMatrix/wiki
  10. const uint32_t kMatrixOptions = (SM_HUB75_OPTIONS_NONE);        // see docs for options: https://github.com/pixelmatix/SmartMatrix/wiki
  11. const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
  12. const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE);
  13.  
  14. const uint8_t scrollSpeed = 255;
  15.  
  16. SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
  17. SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer1, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
  18. SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer2, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
  19. SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer3, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
  20. SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer4, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
  21. SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer5, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
  22. SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer6, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
  23. SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer7, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
  24.  
  25. void setup() {
  26.   // Enable printing FPS count information
  27.   Serial.begin(115200);
  28.  
  29.   matrix.addLayer(&scrollingLayer1);
  30.   matrix.addLayer(&scrollingLayer2);
  31.   matrix.addLayer(&scrollingLayer3);
  32.   matrix.addLayer(&scrollingLayer4);
  33.   matrix.addLayer(&scrollingLayer5);
  34.   matrix.addLayer(&scrollingLayer6);
  35.   matrix.addLayer(&scrollingLayer7);
  36. //  matrix.setRefreshRate(60);
  37.   matrix.begin();
  38.  
  39.  
  40.   // Wait for Serial to be ready
  41.   delay(500);
  42.   Serial.println("Boot");
  43.  
  44.   scrollingLayer1.setMode(wrapForward);
  45.   scrollingLayer1.setColor({0x00, 0xff, 0x00});
  46.   scrollingLayer1.setSpeed(scrollSpeed);
  47.   scrollingLayer1.setFont(font8x13);
  48.   scrollingLayer1.start("||||||||||||||||||||||||||||||||||||||||||||||||", -1);
  49.   scrollingLayer1.setOffsetFromTop(-2);
  50.   scrollingLayer2.setMode(wrapForward);
  51.   scrollingLayer2.setColor({0x00, 0xff, 0x00});
  52.   scrollingLayer2.setSpeed(scrollSpeed);
  53.   scrollingLayer2.setFont(font8x13);
  54.   scrollingLayer2.start("||||||||||||||||||||||||||||||||||||||||||||||||", -1);
  55.   scrollingLayer2.setOffsetFromTop(7);
  56.   scrollingLayer3.setMode(wrapForward);
  57.   scrollingLayer3.setColor({0x00, 0xff, 0x00});
  58.   scrollingLayer3.setSpeed(scrollSpeed);
  59.   scrollingLayer3.setFont(font8x13);
  60.   scrollingLayer3.start("||||||||||||||||||||||||||||||||||||||||||||||||", -1);
  61.   scrollingLayer3.setOffsetFromTop(16);
  62.   scrollingLayer4.setMode(wrapForward);
  63.   scrollingLayer4.setColor({0x00, 0xff, 0x00});
  64.   scrollingLayer4.setSpeed(scrollSpeed);
  65.   scrollingLayer4.setFont(font8x13);
  66.   scrollingLayer4.start("||||||||||||||||||||||||||||||||||||||||||||||||", -1);
  67.   scrollingLayer4.setOffsetFromTop(25);
  68.   scrollingLayer5.setMode(wrapForward);
  69.   scrollingLayer5.setColor({0x00, 0xff, 0x00});
  70.   scrollingLayer5.setSpeed(scrollSpeed);
  71.   scrollingLayer5.setFont(font8x13);
  72.   scrollingLayer5.start("||||||||||||||||||||||||||||||||||||||||||||||||", -1);
  73.   scrollingLayer5.setOffsetFromTop(34);
  74.   scrollingLayer6.setMode(wrapForward);
  75.   scrollingLayer6.setColor({0x00, 0xff, 0x00});
  76.   scrollingLayer6.setSpeed(scrollSpeed);
  77.   scrollingLayer6.setFont(font8x13);
  78.   scrollingLayer6.start("||||||||||||||||||||||||||||||||||||||||||||||||", -1);
  79.   scrollingLayer6.setOffsetFromTop(43);
  80.   scrollingLayer7.setMode(wrapForward);
  81.   scrollingLayer7.setColor({0x00, 0xff, 0x00});
  82.   scrollingLayer7.setSpeed(scrollSpeed);
  83.   scrollingLayer7.setFont(font8x13);
  84.   scrollingLayer7.start("||||||||||||||||||||||||||||||||||||||||||||||||", -1);
  85.   scrollingLayer7.setOffsetFromTop(52);
  86. }
  87.  
  88. void loop() {
  89.   delay(100);
  90.   matrix.countFPS();
  91. }
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement