RGB matrix act crazy WHY?

Hello to all.

So something wrong with Adafruit_GFX.h or <RGBmatrixPanel.h> library. Who can check?

The problem is that when i put something in matrix.drawPixel(x, y, RGB_png[ HERE ]); accept just number like RGB_png[1] the RGB acts crazy lights up some other random LED . And absolutely uncontrol able.

So simply what I wanna do to test is just run the first row of 32 leds collored from RGB_png Array

And like I said if just do like that RGB_png[0] with a digit insert the matrix.drawPixel function pick the color for the first LED and light this LED with that collor no problem...

But if I put in RGB_png from for or do like that

  • int index = Serial.parseInt();*
  • matrix.drawPixel(x, y, RGB_png[index]);*
  • The panel act messy.. Check Picture...*
  • So do you know why?*
    ```
    *#include <Adafruit_GFX.h>  // Core graphics library
    #include <RGBmatrixPanel.h> // Hardware-specific library

#define CLK 8  // MUST be on PORTB!
#define LAT 10
#define OE  9
#define A  A0
#define B  A1
#define C  A2
#define D  A3

RGBmatrixPanel matrix (A, B, C,D, CLK, LAT, OE, false);

const unsigned int  RGB_png[] ={  0xE8E4,0xE8E4,0xE8E4,0xE8E4,0xE8E4,0xE8E4,0xE8E4,0xE8E4,0xE8E4,0xE8E4,
0x2589,0x2589,0x2589,0x2589,0x2589,0x2589,0x2589,0x2589,0x2589,0x2589,
0x3A59, 0x3A59,0x3A59,0x3A59,0x3A59,0x3A59,0x3A59,0x3A59,0x3A59,0x3A59,0x3A59,0x3A59,};

void setup(){
   
    Serial.begin(9600);
    Serial.println("Start");

matrix.begin();

matrix.setRotation(4);

}

void loop(){

for(int x=0; x<=32; x++){            // messy
                         
                        matrix.drawPixel(x, y, RGB_png[x]);
                        delay(20);
               
              }

// If I do like that :  so it's lights all LED with same 0xE8E4 color which means it's ok to pick the color from array

for(int x=0; x<=32; x++){          // works
                         
                        matrix.drawPixel(x, y, RGB_png[0]);
                        delay(20);
               
              }
}*
```

yee ye Y is just a 0;;

I was posting from other code that's why;

matrix.drawPixel(x, 0, RGB_png[x]);

So what you think is this because of that A B C D?

ok Im gonna check but this letters from their examples and works for them no problem...

And there is many examples same definition always...

they need exactly A B C D for library I guess can't be changed. Im wrong here

Ok Im a little out from the panel.

So basically this is the code. There is no much code.

The problem like seeable. What ever Im inserting as index to print out that array thrugh matrix.drawPixel function accept actual digit is messy...
but the function actully picks the collor from array no problem which means not the array is causing the problem

ok I get back to the panels will change definition and costructor see if it helps/.. I let it know here...

When asking for help, it always pays to post your entire sketch. This is because a mistake in one part of the sketch can cause problems in a different part, and if we don't see the entire sketch, we cannot locate the problem.

#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library

#define CLK 8  // MUST be on PORTB!
#define LAT 10
#define OE  9
#define termA   A0
#define termB   A1
#define termC   A2
#define termD   A3


RGBmatrixPanel matrix (termA, termB, termC,termD, CLK, LAT, OE, false);



const unsigned int  PROGMEM  RGB_png[] ={
  0xE8E4, 0xE8E4, 0xE8E4, 0xE8E4, 0xE8E4,0xE8E4, 0xE8E4, 0xE8E4, 0xE8E4, 0xE8E4,
  0x2589, 0x2589, 0x2589, 0x2589, 0x2589,0x2589, 0x2589, 0x2589, 0x2589, 0x2589,
  0x3A59, 0x3A59, 0x3A59, 0x3A59, 0x3A59,0x3A59, 0x3A59, 0x3A59, 0x3A59, 0x3A59,0x3A59,0x3A59,
 };


void setup() {

       matrix.begin();
       matrix.setRotation(4);

       Serial.begin(57600);
       Serial.println("Start");

       matrix.fillScreen(0);
       delay(2000);
}

void loop() {

        for(int x = 0; x<=32; x++)
        {
          matrix.drawPixel(x, 0, RGB_png[x]);           // don't work

         // matrix.drawPixel(x, 0, RGB_png[1]);    works  good red color 
        //   matrix.drawPixel(x, 0, 0xE8E4);          works  good red color     

          delay(500);
        }

        matrix.fillScreen(0);
        delay(2000);

   
}

So now with those A B C D seems like work. But still here's some issue...
It's now goes by for loop it's lights'up the a ledes successively but messes with color on evry single LED..

Seems like X in the brackets don't work and it's picking color data from the air..

Maybe I need to print them via poiners?

Slavka85:
Seems like X in the brackets don't work and it's picking color data from the air..

Maybe I need to print them via poiners?

I think your problem is here:

for(int x = 0; x<=32; x++)

and/or here:

const unsigned int  PROGMEM  RGB_png[] ={
  0xE8E4, 0xE8E4, 0xE8E4, 0xE8E4, 0xE8E4,0xE8E4, 0xE8E4, 0xE8E4, 0xE8E4, 0xE8E4,
  0x2589, 0x2589, 0x2589, 0x2589, 0x2589,0x2589, 0x2589, 0x2589, 0x2589, 0x2589,
  0x3A59, 0x3A59, 0x3A59, 0x3A59, 0x3A59,0x3A59, 0x3A59, 0x3A59, 0x3A59, 0x3A59,0x3A59,0x3A59,
 };

If an array has 32 elements, they will be numbered from 0 to 31.
Inside your for loop, x goes from 0 to 32.

Also, I'm not sure exactly how PROGMEM works. Maybe someone who knows more about it can help.

This way you can fix the PROGMEM issue

          matrix.drawPixel(x, 0, pgm_read_word_near(&RGB_png[x]));

but I think the two bytes contained in each value can not hold R G B data, only R+G or G+B.
If that is not intended, you should use unsigned longs for the color values, and use          matrix.drawPixel(x, 0, pgm_read_dword_near(&RGB_png[x]));

matrix.drawPixel(x, 0, pgm_read_word_near(&RGB_png[x])); WORKS LIKE THAT!!!

as suppose to be..

and if I delite word PROGMEM :

const unsigned int RGB_png[] ={} masses... Any other definition messes actually.

Whandall Thanks... Now time to read about PROGMEM

for (int x = 0; x <= 32; x++)These for loops use 33 values from the array. Is that what you intended ?

How many entries are there in the RGB_png[] array ?
What is the value of the final one ?

yes yes 31 you guys right about ... but it dosn't matter it has no effect...

Slavka85:
yes yes 31 you guys right about ... but it dosn't matter it has no effect...

Please show us the revised line.

you mean this line?

for (int x = 0; x < 32; x++) or for(int x = 0; x <= 31; x++)

or line of light RGB?

Slavka85:
you mean this line?

for (int x = 0; x < 32; x++) or for(int x = 0; x <= 31; x++)

or line of light RGB?

Yes, that one, but you gave me two. Which one did you use?
What correction did you make, based on reply #10?

You have two for loops like that in your program. Did you correct them both?

int i = 0;
     for(int y =0; y<32; y++)
     {
        for(int x = 0; x<=31; x++)
        {

          matrix.drawPixel(x, y, pgm_read_word_near(&Azbuka[i]));

          i = i+1;
        
          delay(50);
        }

     }

In that case, variable i will end up with the value of 32*32-1. Is Asbuka[] that big?

yes... it is 32x32 RGB matrix panel..

As I already noted, it is not RGB, you need 3 bytes per value for RGB.

Whandall:
As I already noted, it is not RGB, you need 3 bytes per value for RGB.

Here's a comment from inside one of the relevant Adafruit libraries:

// Original RGBmatrixPanel library used 3/3/3 color.  Later version used
// 4/4/4.  Then Adafruit_GFX (core library used across all Adafruit
// display devices now) standardized on 5/6/5.  The matrix still operates
// internally on 4/4/4 color, but all the graphics functions are written
// to expect 5/6/5...the matrix lib will truncate the color components as
// needed when drawing.  These next functions are mostly here for the
// benefit of older code using one of the original color formats.

5 + 6 + 5 = how many?

That is not RGB, but some compressed subset.

Whandall:
As I already noted, it is not RGB, you need 3 bytes per value for RGB.

So, by definition, each component must have at least eight bits resolution?
I thought RGB meant that there are red, green, and blue components, with the brightness of each component specified individually. I did not know that it had to have a specific number of bits of resolution in order to qualify.