Go Down

Topic: Neopixel and SD card (Read 8077 times) previous topic - next topic

Grumpy_Mike

Quote
I modify the contents of the file as follows,
Yes I am asking how you modify the contents of the file to do that. It seems to me like you are not doing what you think you are doing. Most of those colours will be blue.
What if you change the numbers to be :-
800000
800000
800000
800000
800000
800000

Then you should see the first 6 as red. If you don't then you are not changing the file like you think you are.

mooop

I modify the file by taking the micro sd card out of the shield, I insert it into my computer, I modify test.PAT, I replace the first couple lines with different HEX color codes like so:

FBFF00
35AD4D
1EDADF

I save the changes to the file, I take the micro sd card out of my computer, and put it back into the slot.

What am I doing wrong?

Grumpy_Mike

You are still not answering my question. What software did you use to change the file?

mooop

I used Sublime Text 2 for Mac, on Mac.

Grumpy_Mike

Thank you.
Now the problem with that is that is is only a text editor so you can not use it to change the hex values in a file, all it will do is change ASCII values. So as I said you are not doing what you think you are doing.
Look at the printout from that code I sent, you will see the LED values the code is reading. You will see that it is not what you thought you set in your text editor.

To change a file so that the bytes change to exactly what you want you need to use what is called a hex editor. As you are on a Mac you can use a free application called 0xED that starts with a zero. With that you can type ASCII, the code you get from your keyboard, to change the upper and lower nibbles of your byte.

mooop

Ok, thank you for your help.

However this is not working yet. Now I do get colors, but not the right one.

Here is the file, which is basically the same series of colors (highlighted in red), 80 times, to make it 400 LEDs.



These are the 5 colors FF15BB6F FF24B5E3 FFE90EE9 FFE3DA11 FFFA8223. I could be mistaken on that as I have added FF before the colors, to make them fit in what appears to be the 8 character "slots" of the 0xED software.



And this is what the LED panel outputs:



So it does somehow seem to be the right colors, we're making progress, but they're not in the right order.

I am getting there, thank you so much for your help, let me know what I am doing wrong this time!



Grumpy_Mike

#51
May 04, 2017, 08:24 pm Last Edit: May 04, 2017, 08:32 pm by Grumpy_Mike
Quote
I could be mistaken on that as I have added FF before the colors, to make them fit in what appears to be the 8 character "slots" of the 0xED software.
That is wrong. Just ignore the slots. Each pixel is represented by 3 bytes in Red, Green, Blue order, do not pad it out.

Also I don't get the same colours for those swatches. I get this:-


Quote
These are the 5 colors FF15BB6F FF24B5E3 FFE90EE9 FFE3DA11 FFFA8223.
I think those colours are in the wrong order they seem to be blue, green, red.

Grumpy_Mike

Try this file, untested so it might not work. It is a pattern for 400 LEDs in a 20 by 20 matrix, there are 13 frames in an animation. Can you change the code to cope with that?

Change the file type from .txt to .PAT

mooop

I get 6 patterns, so 6 frames, then the panel turns to white, and then it just shuts off. What the hell.

This is the code I am using:

Code: [Select]
// Simple reading neopixels from an SD card by Mike Cook
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

#include <Adafruit_NeoPixel.h>

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN            6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      400

#include <SPI.h>
#include <SD.h>

File fileptr;
 
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second

void setup() {
  Serial.begin(9600);
  pixels.begin(); // This initializes the NeoPixel library.
  wipe();
  pixels.show();
   if (!SD.begin(53)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
    fileptr = SD.open("t4.PAT");
  if (fileptr) {
    Serial.println("test.PAT open");
    // fileptr.close();
  }

}

void nextPattern(){
byte red,green,blue;
int count = 0;
while(count < NUMPIXELS){
    //Serial.print("LED ");
    //Serial.print(count);
    //Serial.print(" - ");
  red = fileptr.read();
    //Serial.print(red); // for seeing what is happening comment out later
    //Serial.print(",");
  green = fileptr.read();
    //Serial.print(green);
    //Serial.print(",");
  blue = fileptr.read();
    //Serial.print(blue);
    //Serial.println("");
pixels.setPixelColor(count, red,green,blue);
count ++;
}
pixels.show();
}

void loop() {
  for(int i=0;i<13;i++){
    Serial.println();
    Serial.print("Pattern ");
    Serial.println(i);
    nextPattern();
    delay(delayval);
  }
  fileptr.close();
  Serial.println("file closed");
  wipe();
  pixels.show();
  Serial.println("Finished patterns press reset to repeat");
  while(true) { } // hang here with the file closed
}

void wipe(){
       for(int i=0;i<pixels.numPixels();i++){
       pixels.setPixelColor(i, pixels.Color(0,0,0));
       }
  }

Grumpy_Mike

#54
May 05, 2017, 09:53 pm Last Edit: May 05, 2017, 09:54 pm by Grumpy_Mike
OK try this file, I had a bit of a problem writing bytes in the other one.
This should work as I intended.

When the patterns finish all the LEDs will go off. Press the reset on the Arduino to repeat.

mooop

Ok, the problem is now solved. At least the display problem.

The LED panel is built, and it can now display animations with the technique you taught me @Grumpy_Mike. Entering actual hex codes rather completing them with FF to make the data chunks 8 characters long was the solution. I can now run gifs on the LED panel, and the frame rate is really good.

With a little less than 2 months remaining to finish this project, I now need to implement interaction with the computer in between each frame, or every 10 frames, something short. The animation will be divided into clips that will play one after the other, every 5 questions the user answers. The questions are answered with a 5 pad keyboard connected to a computer, which analyzes the inputs, and simply sends a signal to the LED panel Arduino Mega to jump to next clip.

I also have a bit of an issue with the colors of the led panel, which are really different. This picture here does not render well on my LED panel. You can barely see the difference in tint between the 2 blues, and the beige layer is barely visible, so as the contrast between the 2 oranges.



This is a minor issue, as I only need a palette of 5 different colors for each cell I will do (around 10), I can just live test the color palettes on the panel rather than on my computer screen, and see what looks best.

I do hope the rest of the job will go more smoothly, and I thank you so much @Grumpy_Mike for your help. I hope you're a good person and if you think you are I am willing to pay you a paypal coffee, you helped me a lot so far, thanks so much!

I will get back on here if I run into more trouble, thanks a lot, cheers!

Grumpy_Mike

Quote
I also have a bit of an issue with the colors of the led panel, which are really different.
To correct for this you need to use gamma correction. You can use this either when you generate the pattern or when you read it back from the SD card. The latter will slow things down a small tad but might be simpler to implement.
Here is a link telling you about it:- https://learn.adafruit.com/led-tricks-gamma-correction/the-longer-fix

Quote
I hope you're a good person
No wicked evil and grumpy  ;)

Thanks for the offer, but this is my hobby as well, hope your project goes well.  :)

mooop

Quote
No wicked evil and grumpy  ;)

Thanks for the offer, but this is my hobby as well, hope your project goes well.  :)
All right no problem!

I also get some LEDs blinking. Like, if one LED has to stay white for so long it will blink sometimes to yellow. Might be bad soldering of the data line. But overall the light is very stable.


Grumpy_Mike

I would try a few more large capacitors, this time in the middle as well as the corners.

mooop

Hey me again!

Is that the issue you think? I'm going to  try, it's really doing it a lot now. Pixels flashing to yellow.

Hook up the capacitors like so?


Go Up