Updated some examples with fastmode/brightness controls

Signed-off-by: Emil Muratov <gpm@hotplug.ru>
This commit is contained in:
Emil Muratov 2020-12-07 14:13:09 +03:00
parent 0d8fe4aeff
commit e8efa3d29d
3 changed files with 44 additions and 7 deletions

View file

@ -47,6 +47,19 @@ void setup()
Serial.begin(115200); Serial.begin(115200);
delay(250); delay(250);
matrix.begin(R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN ); // setup the LED matrix matrix.begin(R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN ); // setup the LED matrix
/**
* this demos runs pretty fine in fast-mode which gives much better fps on large matrixes (>128x64)
* see comments in the lib header on what does that means
*/
//dma_display.setFastMode(true);
// SETS THE BRIGHTNESS HERE. MAX value is MATRIX_WIDTH, 2/3 OR LOWER IDEAL, default is about 50%
// dma_display.setPanelBrightness(30);
/* another way to change brightness is to use
* dma_display.setPanelBrightness8(uint8_t brt); // were brt is within range 0-255
* it will recalculate to consider matrix width automatically
*/
//dma_display.setPanelBrightness8(180);
Serial.println("**************** Starting Aurora Effects Demo ****************"); Serial.println("**************** Starting Aurora Effects Demo ****************");

View file

@ -44,7 +44,7 @@ class PatternSwirl : public Drawable {
// Note that we never actually clear the matrix, we just constantly // Note that we never actually clear the matrix, we just constantly
// blur it repeatedly. Since the blurring is 'lossy', there's // blur it repeatedly. Since the blurring is 'lossy', there's
// an automatic trend toward black -- by design. // an automatic trend toward black -- by design.
uint8_t blurAmount = beatsin8(2, 10, 255) uint8_t blurAmount = beatsin8(2, 10, 255);
#if FASTLED_VERSION >= 3001000 #if FASTLED_VERSION >= 3001000
blur2d(effects.leds, MATRIX_WIDTH > 255 ? 255 : MATRIX_WIDTH, MATRIX_HEIGHT > 255 ? 255 : MATRIX_HEIGHT, blurAmount); blur2d(effects.leds, MATRIX_WIDTH > 255 ? 255 : MATRIX_WIDTH, MATRIX_HEIGHT > 255 ? 255 : MATRIX_HEIGHT, blurAmount);

View file

@ -44,8 +44,8 @@ MatrixPanel_I2S_DMA dma_display;
// End of default setup for RGB Matrix 64x32 panel // End of default setup for RGB Matrix 64x32 panel
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
int time_counter = 0; uint16_t time_counter = 0, cycles = 0, fps = 0;
int cycles = 0; unsigned long fps_timer;
CRGB currentColor; CRGB currentColor;
CRGBPalette16 palettes[] = {HeatColors_p, LavaColors_p, RainbowColors_p, RainbowStripeColors_p, CloudColors_p}; CRGBPalette16 palettes[] = {HeatColors_p, LavaColors_p, RainbowColors_p, RainbowStripeColors_p, CloudColors_p};
@ -62,13 +62,28 @@ void setup(){
// Panels are the same - some seem to display ghosting artefacts at lower brightness levels. // Panels are the same - some seem to display ghosting artefacts at lower brightness levels.
// In the setup() function do something like: // In the setup() function do something like:
dma_display.setPanelBrightness(30); // SETS THE BRIGHTNESS HERE. 60 OR LOWER IDEAL. // SETS THE BRIGHTNESS HERE. MAX value is MATRIX_WIDTH, 2/3 OR LOWER IDEAL, default is about 50%
// dma_display.setPanelBrightness(30);
/* another way to change brightness is to use
* dma_display.setPanelBrightness8(uint8_t brt); // were brt is within range 0-255
* it will recalculate to consider matrix width automatically
*/
//dma_display.setPanelBrightness8(180);
/** /**
* be sure to specify 'FM6126A' as last parametr to the begin(), * this demo runs pretty fine in fast-mode which gives much better fps on large matrixes (>128x64)
* see comments in the lib header on what does that means
*/
dma_display.setFastMode(true);
/**
* Run display on our matrix, be sure to specify 'FM6126A' as last parametr to the begin(),
* it would reset 6126 registers and enables the matrix * it would reset 6126 registers and enables the matrix
*/ */
dma_display.begin(R1, G1, BL1, R2, G2, BL2, CH_A, CH_B, CH_C, CH_D, CH_E, LAT, OE, CLK, FM6126A); dma_display.begin(R1, G1, BL1, R2, G2, BL2, CH_A, CH_B, CH_C, CH_D, CH_E, LAT, OE, CLK, FM6126A);
fps_timer = millis();
} }
void loop(){ void loop(){
@ -85,12 +100,21 @@ void loop(){
} }
} }
time_counter += 1; ++time_counter;
cycles++; ++cycles;
++fps;
if (cycles >= 1024) { if (cycles >= 1024) {
time_counter = 0; time_counter = 0;
cycles = 0; cycles = 0;
currentPalette = palettes[random(0,sizeof(palettes)/sizeof(palettes[0]))]; currentPalette = palettes[random(0,sizeof(palettes)/sizeof(palettes[0]))];
} }
// print FPS rate every 5 seconds
// Note: this is NOT a matrix refresh rate, it's the number of data frames being drawn to the DMA buffer per second
if (fps_timer + 5000 < millis()){
Serial.printf_P(PSTR("Effect fps: %d\n"), fps/5);
fps_timer = millis();
fps = 0;
}
} }