who can help  Fast led  xy array and a  belfag  array with fix color (

who can help

Fast led xy array and a belfag array with fix color ( this is a flag off a country
my flag is always showing the wrong color’s ? has somebody a idea what i’m doing wrong . ?
the desitnation arry leds[XY(x,y)] should have the right color vaule off my belflag array ?

Belflag() {0x ff00,0xff01, … 280 elements};

void bel_flag() {
for (int i = 0; i < 279 ; i++) {
for (int x = 0; x < kMatrixWidth; x++) {
for (int y = 0; y < kMatrixHeight; y++)
memmove8( &leds[XY(x,y)], &belflag[i],10 * sizeof (CRGB)); }
}
}

who is possible to help me out ?

Need a bit more info (if not the whole code) - what is kMatrixWidth, what is kMatrixHeight? What exactly are you trying to do here?

Are you trying to map the elements of your belflag array to the led array?

Some immediate issues pop up:

  • you’re showing 16 bit values in your belflag array (0xff00, 0xff01, etc…) - if they’re supposed to be colors, then you need them to be 24-bit values, however, C doesn’t have 24-bit values, so really belflag should be an array of CRGB objects as well.

  • you are iterating over the x/y values in single steps, but you are copying 30 bytes of data at a time (this is going to compound the error caused by what appears to be an array of 16 bit values)

  • the way your loops are structured have more issues - your outer loop will run 280 times, each time it runs, it will set every led, effectively, to the color value for belflag[i].

I think what you might want instead is something like:

uint32_t belflag[] = { 0xFF0000, 0xFF0001, … }

void bel_flag() {
int i = 0;
for(int x = 0; x < kMatrixWidth; x++) {
for(int y = 0; y < kMatrixHeight; y++) {
leds[XY(x,y)] = CRGB(belflag[i])
}
}
}

of course, this assumes that kMatrixWidth * kMatrixHeight == 280.

It’d be helpful to see the entire sketch rather than just snippits like this (you can put it on pastebin or http://gist.github.com)

#include <FastLED.h>

#define COLOR_ORDER RGB
#define CHIPSET APA102

#define BRIGHTNESS 64
uint32_t Col = 0x55ff55;
uint32_t br_flag = 0xff;
uint32_t Col_br = 0;

// Params for width and height
const uint8_t kMatrixWidth = 20;
const uint8_t kMatrixHeight = 14;

uint32_t belflag[] = {
0xF800,0xF820,0xF8C0,0xF9E0,0xFB40,0xF4E1,0xF641,
0xF721,0xFFA0,0xFFC0,0xEF40,0xC620,0x9481,0x5AC1,
0x2941,0x0861,0x0000,0x0000,0x0000,0x0000,0xF800,
0xF840,0xF8E0,0xFA20,0xFBC0,0xFD60,0xF6C1,0xFF80,
0xFFC0,0xFFC0,0xE720,0xBDE0,0x8420,0x4A40,0x18E0,
0x0840,0x0000,0x0000,0x0000,0x0000,0xF800,0xF840,
0xF920,0xFA80,0xFC40,0xFDE0,0xFF20,0xFFA0,0xFFE0,
0xFFC0,0xE700,0xB5A0,0x7BE0,0x4220,0x18C0,0x0020,
0x0000,0x0000,0x0000,0x0000,0xF800,0xF840,0xF920,
0xFAA0,0xFC60,0xFE00,0xFF40,0xFFC0,0xFFE0,0xFFC0,
0xDEE0,0xAD60,0x73A0,0x39C0,0x10A0,0x0020,0x0000,
0x0000,0x0000,0x0000,0xF800,0xF840,0xF940,0xFAC0,
0xFC80,0xFE40,0xFF60,0xFFC0,0xFFE0,0xFFC0,0xE700,
0xAD60,0x7380,0x39C0,0x10A0,0x0020,0x0000,0x0000,
0x0000,0x0000,0xF800,0xF820,0xF900,0xFAC0,0xFC80,
0xFE20,0xFF40,0xFFC0,0xFFE0,0xF7A0,0xDEE0,0xAD40,
0x6B60,0x31A0,0x1080,0x0020,0x0000,0x0000,0x0000,
0x0000,0xF800,0xF820,0xF900,0xFAA0,0xFC80,0xFE40,
0xFF60,0xFFC0,0xFFE0,0xFFC0,0xE700,0xAD60,0x6B60,
0x31A0,0x1080,0x0000,0x0000,0x0000,0x0000,0x0000,
0xF800,0xF820,0xF8E0,0xFA80,0xFC60,0xFE20,0xFF40,
0xFFC0,0xFFE0,0xFFC0,0xE700,0xAD40,0x6B60,0x31A0,
0x1080,0x0020,0x0000,0x0000,0x0000,0x0000,0xF800,
0xF820,0xF8E0,0xFA60,0xFC40,0xFE20,0xFF40,0xFFC0,
0xFFE0,0xFFC0,0xE700,0xAD40,0x6B60,0x39C0,0x1080,
0x0000,0x0000,0x0000,0x0000,0x0000,0xF800,0xF800,
0xF8C0,0xFA40,0xFC20,0xFDE0,0xFF20,0xFFC0,0xFFE0,
0xFFC0,0xE700,0xAD60,0x7380,0x39C0,0x1080,0x0020,
0x0000,0x0000,0x0000,0x0000,0xF800,0xF800,0xF8A0,
0xFA20,0xFC00,0xFDE0,0xFF00,0xFFA0,0xFFE0,0xFFC0,
0xDEE0,0xAD60,0x73A0,0x39E0,0x10A0,0x0020,0x0000,
0x0000,0x0000,0x0000,0xF800,0xF800,0xF8A0,0xFA00,
0xFBC0,0xFDA0,0xFEE0,0xFFA0,0xFFE0,0xFFC0,0xE700,
0xB580,0x7BC0,0x4200,0x18C0,0x0020,0x0000,0x0000,
0x0000,0x0000,0xF800,0xF800,0xF8A0,0xF9E0,0xFBA0,
0xFD60,0xFEC0,0xFF80,0xFFE0,0xFFC0,0xE700,0xB5A0,
0x7BE0,0x4A40,0x18E0,0x0840,0x0000,0x0000,0x0000,
0x0000,0xF800,0xF800,0xF880,0xF9A0,0xFB40,0xFD00,
0xFE80,0xFF60,0xFFC0,0xF7A0,0xE720,0xBDE0,0x8C40,
0x5280,0x2120,0x0840,0x0000,0x0000,0x0000,0x0000
};

//
#define NUM_LEDS (kMatrixWidth * kMatrixHeight)

CRGB leds[kMatrixWidth * kMatrixHeight];
CRGB ledstemp[kMatrixWidth * kMatrixHeight];

#define LAST_VISIBLE_LED 279
uint16_t XY( uint16_t x, uint16_t y)
{
// any out of bounds address maps to the first hidden pixel
if( (x >= kMatrixWidth) || (y >= kMatrixHeight) ) {
return (LAST_VISIBLE_LED + 1);
}
const uint16_t ShadesTable[] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,
40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,
79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63,62,61,60,
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
119,118,117,116,115,114,113,112,111,110,109,108,107,106,105,104,103,102,101,100,
120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,
159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,142,141,140,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,
199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,
200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,
239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,
279,278,277,276,275,274,273,272,271,270,269,268,267,266,265,264,263,262,261,260,
};

uint16_t i = (y * kMatrixWidth) + x;
uint16_t j = ShadesTable[i];
return j;
}

void loop()
{

//Belgian_flag2();
Belgian_flag();
//FastLED.show();
}

void Belgian_flag(){
for(int x = 0; x < kMatrixWidth; x++){
{
for( int y = 0; y < kMatrixHeight; y++){
for(int i = 0; i<NUM_LEDS; i++ ) {
// Col = belflag[i] ;
// Col_br = ( br_flag << 24 | Col );
// leds[ XY(x, y)]= CRGB(Col);
memmove8( &leds[XY(x,y)], &belflag[i],10 * sizeof (CRGB));
FastLED.show() ;
}
}
}
}
}

void setup() {
FastLED.addLeds<CHIPSET, 5,4, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
FastLED.setBrightness( BRIGHTNESS );
}

// apart off the whole code , but works on its own
//array is 280 pixels apa 102 and on the moment there is a xy matrix as //the pixels will not be aligned ( used the xy spread factor )
i only want to show flag image on my led screen , very basic i’m using a teensy 3.1 for memory and faster results

regards

(For large blocks of code - please use pastebin or gist - navigating code pasted in a comment like this is a pain in the ass :slight_smile:

Also - some questions from your original paste, that you haven’t answered or are still unclear from the code:

  • the beflag array - it’s an array of 16 bit values, how are you expecting these to map to colors, or is it that the flag just has no red?

  • again, what are you trying to accomplish with your loop? Is it that you want each value in belflag to end up in corresponding value in led array?

Your memmove is extra problematic, because you are doing a memmove of 30 bytes, but your flag table is made up of 4 byte items - which means you’re moving 7.5 entries in bflag worth of data into 10 rgb leds.

The inner loop in your Belgian_flag function means that you’re going to copy this first 30 bytes of data from belflag into the set of leds starting at x,y 280 times for each x/y location.

I think for the Belgian_flag function you want:

void Belgian_flag() {
int i = 0;
for(int y = 0; y < kMatrixHeight; y++) {
for(int x = 0; x < kMatrixWidth; x++) {
leds[XY(x,y)] = CRGB(belflag[i++])
}
}
FastLED.show();
}

or some variation on that.

thanks , Daniel , founded a work around solution … with a temp array and then a loolup table for the xy values .

will posted the elements when i’m ready ,