leddisplay/libraries/SmartMatrix/examples/MultipleTextLayers/MultipleTextLayers.ino
2018-10-13 22:34:06 +02:00

76 lines
3.5 KiB
C++

/*
Note: This example currently has very low performance on large displays (~38FPS refresh rate on 64x64)
The Scrolling Layer refresh code will be optimized in a future SmartMatrix Library release
*/
//#include <SmartLEDShieldV4.h> // uncomment this line for SmartLED Shield V4 (needs to be before #include <SmartMatrix3.h>)
#include <SmartMatrix3.h>
#define COLOR_DEPTH 24 // known working: 24, 48 - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24
const uint8_t kMatrixWidth = 32; // known working: 32, 64, 96, 128
const uint8_t kMatrixHeight = 32; // known working: 16, 32, 48, 64
const uint8_t kRefreshDepth = 36; // known working: 24, 36, 48
const uint8_t kDmaBufferRows = 4; // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate
const uint8_t kPanelType = SMARTMATRIX_HUB75_32ROW_MOD16SCAN; // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels
const uint8_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE); // see http://docs.pixelmatix.com/SmartMatrix for options
const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE);
SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer1, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer2, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer3, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer4, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer5, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
void setup() {
matrix.addLayer(&scrollingLayer1);
matrix.addLayer(&scrollingLayer2);
matrix.addLayer(&scrollingLayer3);
matrix.addLayer(&scrollingLayer4);
matrix.addLayer(&scrollingLayer5);
matrix.begin();
scrollingLayer1.setMode(wrapForward);
scrollingLayer2.setMode(bounceForward);
scrollingLayer3.setMode(bounceReverse);
scrollingLayer4.setMode(wrapForward);
scrollingLayer5.setMode(bounceForward);
scrollingLayer1.setColor({0xff, 0xff, 0xff});
scrollingLayer2.setColor({0xff, 0x00, 0xff});
scrollingLayer3.setColor({0xff, 0xff, 0x00});
scrollingLayer4.setColor({0x00, 0x00, 0xff});
scrollingLayer5.setColor({0xff, 0x00, 0x00});
scrollingLayer1.setSpeed(10);
scrollingLayer2.setSpeed(20);
scrollingLayer3.setSpeed(40);
scrollingLayer4.setSpeed(80);
scrollingLayer5.setSpeed(120);
scrollingLayer1.setFont(gohufont11b);
scrollingLayer2.setFont(gohufont11);
scrollingLayer3.setFont(font8x13);
scrollingLayer4.setFont(font6x10);
scrollingLayer5.setFont(font5x7);
scrollingLayer4.setRotation(rotation270);
scrollingLayer5.setRotation(rotation90);
scrollingLayer1.setOffsetFromTop((kMatrixHeight/2) - 5);
scrollingLayer2.setOffsetFromTop((kMatrixHeight/4) - 5);
scrollingLayer3.setOffsetFromTop((kMatrixHeight/2 + kMatrixHeight/4) - 5);
scrollingLayer4.setOffsetFromTop((kMatrixWidth/2 + kMatrixWidth/4) - 5);
scrollingLayer5.setOffsetFromTop((kMatrixWidth/2 + kMatrixWidth/4) - 5);
scrollingLayer1.start("Layer 1", -1);
scrollingLayer2.start("Layer 2", -1);
scrollingLayer3.start("Layer 3", -1);
scrollingLayer4.start("Layer 4", -1);
scrollingLayer5.start("Layer 5", -1);
}
void loop() {
}