I am getting this error on compilation of the code given further below;
warning: iteration 3u invokes undefined behavior [-Waggressive-loop-optimizations]
leds[XY (x, y)].r = redarray[x][y];
note: containing loop for(uint8_t x=0; x < MatrixWidth; x++){
Code:
// the header files for the RGB data
#include <FastLED.h>
#include "redarray.h"
#include "greenarray.h" //g data header file (hex or dec)
#include "bluearray.h" //b data header file (hex or dec)*/
//matrix parameters
#define MatrixWidth 36 //columns (x)
#define MatrixHeight 1 //rows (y)
#define numled (MatrixWidth * MatrixHeight)
//pin details
#define datapin 7
#define clockpin 8
CRGB leds[MatrixWidth * MatrixHeight];
const bool MatrixSerpentineLayout = true;
void setup() {
FastLED.addLeds<APA102, datapin, clockpin>(leds,numled);
FastLED.clear();
}
void loop() {
for(uint8_t y=0 ; y<1 ; y++){
for(uint8_t x=0; x < MatrixWidth; x++){
leds[XY (x, y)].r = redarray[x][y];
leds[XY (x, y)].g = 0;
leds[XY (x, y)].b = 0;
FastLED.show();
delay(50);
}
}
}
uint16_t XY( uint8_t x, uint8_t y)
{
uint16_t i;
if( MatrixSerpentineLayout == true) {
if( y & 0x01) {
// Odd rows run backwards
uint8_t reverseX = (MatrixWidth - 1) - x;
i = (y * MatrixWidth) + reverseX;
} else {
// Even rows run forwards
i = (y * MatrixWidth) + x;
}
}
return i;
}
The following is redarray header -
//RED const byte redarray[3][36] PROGMEM = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
};
How to remove this warning. The redarray is not being read properly by arduino. THe above code should make the 36 LEDs turn off (black) as per the header file. They are randomly lit red... I am totally perplexed!
Plz help if somebody can. Thanks!