Background brightness FastLED_Functions sketch

As a beginner I succeeded setting up the hardware using SmartLed 4 with Teensy 3.4 and Adafruit 32x64 LED matrix. All the example sketches run perfect. For some testing I now have modified the FastLED_Functions sketch (see code) so only the background animation is shown. So far this works but I did not succeed increasing the overall brightness of the background. Some help would be appreciated.

#include <SmartLEDShieldV4.h>
#include <SmartMatrix3.h>
#include <FastLED.h>

#define COLOR_DEPTH 24
const uint8_t kMatrixWidth = 64;
const uint8_t kMatrixHeight = 32;
const uint8_t kRefreshDepth = 36;
const uint8_t kDmaBufferRows = 4; rate
const uint8_t kPanelType = SMARTMATRIX_HUB75_32ROW_MOD16SCAN; 
const uint8_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE);
const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE);

SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);

static uint16_t x;
static uint16_t y;
static uint16_t z;
uint16_t speed = 10;
uint16_t scale = 20;
uint8_t noise[kMatrixWidth][kMatrixHeight];

void setup() {
  Serial.begin(38400);
  Serial.println("Start (setup)");
  delay(1000);
  matrix.addLayer(&backgroundLayer); 
  matrix.addLayer(&scrollingLayer); 
  matrix.begin();
  backgroundLayer.setBrightness(255);

  x = random16();
  y = random16(); 
  z = random16();
}

void fillnoise8() {
  for(int i = 0; i < kMatrixWidth; i++) {
    int ioffset = scale * i;
    for(int j = 0; j < kMatrixHeight; j++) {
      int joffset = scale * j;
      noise[i][j] = inoise8(x + ioffset,y + joffset,z);
    }
  }
  z += speed;
}

void loop() {
  static uint8_t circlex = 0;
  static uint8_t circley = 0;
  while(backgroundLayer.isSwapPending());
  rgb24 *buffer = backgroundLayer.backBuffer();
  static uint8_t ihue=0; 
  fillnoise8();
  for(int i = 0; i < kMatrixWidth; i++) {
    for(int j = 0; j < kMatrixHeight; j++) {
      buffer[kMatrixWidth*j + i] = CRGB(CHSV(255,noise[j][i],noise[i][j]));
    }
  }
  ihue+=1;
  backgroundLayer.swapBuffers(false);
}

At a glance, it looks like your code is setting the matrix brightness (default is 100% and you didn’t change) and background brightness at 100%. Why do you think it’s not 100%?

Thanks for replying Louis. The brightnmess of the LEDs when using above sketch is very low, I guess 20-25% of the full brightness. Hardware (powering) should not be the problem because other sketches show full brightness, even when all 2048 LEDs are enabled white (255,255,255) there are no issues.

Maybe the colors generated by the FastLED code aren’t scaled to reach 100% brightness? Try adding some 100% white pixels manually to the sketch to compare relative brightness

Thanks again Louis. Although I have a little experience with Arduino I still find the FastLED code a bit hard to understand. Can you help me with the code to make some LEDs light white as suggested?

Just follow the FastLED_Functions example and draw something to the background layer after the FastLED code is finished.

Following your advice I have added the code below under setup in the sketch, the result is shown in the photo. Maybe I’m wrong and this is the normal (maximum) brightness of the animated background. I like to read your opinion, thanks in advance.

// Show off smart matrix scrolling text
  scrollingLayer.setMode(wrapForward);
  scrollingLayer.setColor({0xff, 0xff, 0xff});
  scrollingLayer.setSpeed(15);
  scrollingLayer.setFont(font6x10);
  scrollingLayer.start("SmartMatrix & FastLED", -1);
  scrollingLayer.setOffsetFromTop((kMatrixHeight/2) - 5);

Add this right before swapBuffers at the end (it’s untested, maybe you need to fix the code to make it work):

  backgroundLayer.drawLine(0,0,matrixWidth,matrixHeight,rgb24(255,255,255));

Your support is greatly appreciated. The photo shows the result after I have added two lines of code (see below), white and red lines. None of the background pixels is as bright as those in the diagonal lines.

  backgroundLayer.drawLine(0,0,64,32,rgb24(255,255,255));
  backgroundLayer.drawLine(64,0,0,32,rgb24(255,0,0));