These are chat archives for Makuna/NeoPixelBus

5th
Oct 2016
Mehrdad K
@mkeyno
Oct 05 2016 05:58
Michael to test its accuracy I made simple text file and as you can see I print data after reading from flash and after injected to the strip ,
after couple of test I'm sure the reading from flash read back correct data but I don't know why strip has no correct data
Michael Miller
@Makuna
Oct 05 2016 06:01
Could you change your routines to actually print in decimal or even hexadecimal instead of a char.
Also use a different separator between pixels than a dash; so its easier to read.
Michael Miller
@Makuna
Oct 05 2016 06:11
If you really need me to look into it; you need to provide a sample sketch that is as small as you can make it that demonstrates the problem. No extra code other than what is required to demonstrate the issue. Not one extra line that isn't needed.
Mehrdad K
@mkeyno
Oct 05 2016 06:13
I change the code to this
  ESP.flashRead(_memory_pointer,(uint32_t *) LED_BUFFER,NUM_LEDS*3 );  
  for( int i = 0;i<NUM_LEDS*3; i=i+1) 
  {
   Serial.print((byte)LED_BUFFER[i]);Serial.print(";"); 
  }
   Serial.println("");
                       memcpy(strip.Pixels(),LED_BUFFER,NUM_LEDS*3);
    strip.Dirty();
  for( int i = 0;i<NUM_LEDS; i=i+1) 
  {
   Serial.print((byte)strip.GetPixelColor(i).R);  Serial.print(";"); 
   Serial.print((byte)strip.GetPixelColor(i).G);  Serial.print(";"); 
   Serial.print((byte)strip.GetPixelColor(i).B);  Serial.print(";");
  }
  Serial.println("");
    strip.Show();
    _memory_pointer+=(NUM_LEDS*3);
result
[new _memory_pointer]
52;103;98;52;103;98;52;103;98;52;103;98;52;103;98;52;103;98;52;103;98;52;103;98;52;103;98;
52;98;103;103;52;98;98;103;52;52;98;103;103;52;98;98;103;52;0;98;103;0;0;0;0;0;0;
text file is something like this
0gb0gb0gb0gb0gb0gb0gb0gb0gb1gb1gb1gb1gb1gb1gb1gb1gb1gb2gb2gb2gb2gb2gb2gb2gb2gb2gb3gb3gb3gb3gb3gb3gb3gb3gb3gb4gb4gb4gb4gb4gb4gb4gb4gb4gb5gb5gb5gb5gb5gb5gb5gb5gb5gb6gb6gb6gb6gb6gb6gb6gb6gb6gb7gb7gb7gb7gb7gb7gb7gb7gb7gb8gb8gb8gb8gb8gb8gb8gb8gb8gb9gb9gb9gb9gb9gb9gb9gb9gb9gbAgbAgbAgbAgbAgbAgbAgbAgbAgbBgbBgbBgbBgbBgbBgbBgbBgbBgbCgbCgbCgbCgbCgbCgbCgbCgbCgbDgbDgbDgbDgbDgbDgbDgbDgbDgbEgbEgbEgb
Michael Miller
@Makuna
Oct 05 2016 06:15
please see my last comment, a full sketch with the minimal code to duplicate the problem.
Mehrdad K
@mkeyno
Oct 05 2016 06:16
ok
Mehrdad K
@mkeyno
Oct 05 2016 09:41
@Makuna this is sketch link
please read its note first
this sample file
Michael Miller
@Makuna
Oct 05 2016 16:45
@mkeyno OK, re-read what I stated. I stated the smallest code to reproduce the problem. You included your complete project. If you want help diagnosing problems from others, the first step is to isolate the problem to smallest code that reproduces it. This helps makes sure that its not some other part of your code that is causing the problem; and it makes it easier for the person you "requesting help" from to read the code.
Please put some effort into it.
Mehrdad K
@mkeyno
Oct 05 2016 16:47
but Michael I turned it to as smallest as possible , just add some browser so you could upload test file and see by your self otherwise the problem is only located in loop function which is pasted before
to test program need a way to upload the file in SPIFF then write in flash
you just need to check 2 or 3 function
Mehrdad K
@mkeyno
Oct 05 2016 16:55
as mention before I'm sure that I write file from SPIFF to flash but somehow can't injected to strip correctly
just upload in your module and check the loop function ,
Michael Miller
@Makuna
Oct 05 2016 16:57
@mkeyno Your definition of smallest is different than mine. The problem is about reading and writing flash. This has nothing to do with WiFi features. Strip the code down. I was expecting to see one routine that put some static data into flash (not from a file, just from some global var). I then expected one function that demonstrated reading into memory and confirm; and another function to read into the strip and confirm it fails.
Mehrdad K
@mkeyno
Oct 05 2016 17:03
function to store file from SPIFF to flash
void copy_file_from_SPIFF_to_Raw_Flash(String path, byte file_num){
uint32_t startTime = millis();
 File f = SPIFFS.open(path, "r");
 if(!f) { Serial.println("Could not open file for reading"); return; } 
size_t i = f.size();
start_address_of_imagefile[file_num]=current_raw_location;
 Serial.printf("File size is %u Bytes Start location =%u\n", i,start_address_of_imagefile[file_num]);
  uint8_t* BUFFER = new uint8_t[SPI_FLASH_SEC_SIZE];
 while(i > SPI_FLASH_SEC_SIZE){
                 f.read(BUFFER, SPI_FLASH_SEC_SIZE);
                 optimistic_yield(10000); 
                 ESP.flashEraseSector(current_raw_location/FLASH_SECTOR_SIZE);
                 ESP.flashWrite(current_raw_location,(uint32_t *) BUFFER, SPI_FLASH_SEC_SIZE);      
                 Serial.print("."); i -= SPI_FLASH_SEC_SIZE;
                 current_raw_location+=SPI_FLASH_SEC_SIZE;
                 } 
 f.read(BUFFER, i); 
  optimistic_yield(10000); 
 ESP.flashEraseSector(current_raw_location/FLASH_SECTOR_SIZE);
 ESP.flashWrite(current_raw_location,(uint32_t *) BUFFER, i);   
 current_raw_location+=i;  
 f.close();
 delete [] BUFFER; 
 Serial.printf("copy took %u ms, memory  end address=%u\n",  millis() - startTime,current_raw_location);  
}
define uint8_t * LED_BUFFER;
in setup define LED_BUFFER = (uint8_t *)malloc(NUM_LEDS*3);
Michael Miller
@Makuna
Oct 05 2016 17:03
@mkeyno sigh; is that a complete sketch? Do you not want help?
Mehrdad K
@mkeyno
Oct 05 2016 17:04
I'm so sorry I've just paste what you ask for in last note
am I in correct way
Michael Miller
@Makuna
Oct 05 2016 17:05
You need to make this as simple as possible for someone to help you, I asked for a simple minimal sketch that duplicates the problem; and you have not given me that yet.
Mehrdad K
@mkeyno
Oct 05 2016 17:06
please hear me out , to test the sketch you need upload some file in SPIFF then run the loop to check whats wrong
believe me you can not do as simple way I put in that sketch
honestly I don't know how to make simplest as that sketch
just check the loop function
believe me , my original sketch consist couple of header file and much larger than this
about 1/3 of sketch consist the html page file
Mehrdad K
@mkeyno
Oct 05 2016 17:11
but if you could find way to put file in spiff then following is the simplest sketch
Michael Miller
@Makuna
Oct 05 2016 18:38

Sigh, you block your thinking with simple failure in thought. The problem space is Flash memory and you believe NeoPixelBus. There is no need for any other code or libraries then.

PLEASE GO READ HOW TO DEVELOPE AND TEST CODE! When you hit problems, you need to be able to simplify the problem space, which means removing all code except that which duplicates the problem. Which means ALL THE CODE. This is important if you want to submit an issue or get help with an issue.

You should be able to provide a sketch of no more than 50 lines of code and a single file that duplicate this. If you need more than that then you haven't done enough on your side to narrow down where the problem is.
Mehrdad K
@mkeyno
Oct 05 2016 19:03
ok Michael , honestly I don't know how to simplest the sketch more whereas remove more lines make sketch or issue turn to somethings else , anyway I'm gonna recheck the sketch however I really appreciated if you could just look the following code and suggest if any more approach is possible to trace program
ESP.flashRead(_memory_pointer,(uint32_t *) LED_BUFFER,NUM_LEDS*3 );  
  for( int i = 0;i<NUM_LEDS*3; i=i+1) 
  {
   Serial.print((byte)LED_BUFFER[i]);Serial.print(";"); 
  }
   Serial.println(""); /// ---->>>>>>      to here work perfectly 
                       memcpy(strip.Pixels(),LED_BUFFER,NUM_LEDS*3); 
  strip.Dirty();
  for( int i = 0;i<NUM_LEDS; i=i+1) // non conformity appear here 
  {
   Serial.print((byte)strip.GetPixelColor(i).R);  Serial.print(";"); 
   Serial.print((byte)strip.GetPixelColor(i).G);  Serial.print(";"); 
   Serial.print((byte)strip.GetPixelColor(i).B);  Serial.print(";");
  }
  Serial.println("");
  strip.Show();
  _memory_pointer+=(NUM_LEDS*3);
Mehrdad K
@mkeyno
Oct 05 2016 20:20
Michael I found somethings interesting , I store data in RGB sequence but when inject data in strip the sequence not only change but shifted one byte
Mehrdad K
@mkeyno
Oct 05 2016 20:28
I replace the order of serial print in RBG and its matched for first 3 byte and if shift the data one byte per 3 byte , it matched all
New Bitmap Image.jpg
Mehrdad K
@mkeyno
Oct 05 2016 20:39
as it pretty obvious it seems memcpy to strip.Pixels() pick 4 byte instead of 3 , that's why we miss one byte and instead of reading 3xNUM_LED(27) , read 4xNUM_LED(36)
Mehrdad K
@mkeyno
Oct 05 2016 22:20
but I find the problem
what should I suppose to do then
You should be able to provide a sketch of no more than 50 lines of code and a single file that duplicate this. If you need more than that then you haven't done enough on your side to narrow down where the problem is.
Mehrdad K
@mkeyno
Oct 05 2016 22:27
so I thought I find the problem, because I couldn't make code under 50 lines of sketch which is consist my problem
Mehrdad K
@mkeyno
Oct 05 2016 23:57
any way I run another test to explicity get each LED value by SetPixelColor() function , then print the given value by GetPixelColor()
  ESP.flashRead(_memory_pointer,(uint32_t *)LED_BUFFER    ,NUM_LEDS*3 );  
  for(int i = 0;i<NUM_LEDS*3; i=i+1)   {   Serial.print((char)LED_BUFFER[i]);Serial.print(";");   }   Serial.println("");
  for(int i = 0;i<NUM_LEDS*3; i=i+1)  strip.SetPixelColor(i, LED_BUFFER[i]);  
 strip.Dirty();
  for( int i = 0;i<NUM_LEDS; i=i+1) 
  {
   Serial.print((char)strip.GetPixelColor(i).R);  Serial.print(";"); 
   Serial.print((char)strip.GetPixelColor(i).B);  Serial.print(";"); 
   Serial.print((char)strip.GetPixelColor(i).G);  Serial.print(";");
  }
  Serial.println("");
    strip.Show();
the result was strange
0;g;b;0;g;b;0;g;b;0;g;b;0;g;b;0;g;b;0;g;b;0;g;b;0;g;b; 0;0;0;g;g;g;b;b;b;0;0;0;g;g;g;b;b;b;0;0;0;g;g;g;b;b;b;