These are chat archives for Makuna/NeoPixelBus

4th
Oct 2016
Mehrdad K
@mkeyno
Oct 04 2016 20:30 UTC
Michael have you read my note is esp room
Mehrdad K
@mkeyno
Oct 04 2016 21:04 UTC
I use 2 following code to test which one read back the correct data , and notice ESP.flashRead(_memory_pointer, (uint32_t*)strip.Pixels(),NUM_LEDS*3 ); not correctly read data
code A
ESP.flashRead(_memory_pointer, (uint32_t*)strip.Pixels(),NUM_LEDS*3 );
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).G); ;Serial.print("-"); 
Serial.print((char)strip.GetPixelColor(i).B);
Serial.println();
}
strip.Show();
_memory_pointer+=(NUM_LEDS*3);
delay(1000);
Serial.println("[new _memory_pointer]");
code B (return true data)

                                  uint8_t* LED_BUFFER = new uint8_t[NUM_LEDS*3];
ESP.flashRead(_memory_pointer,(uint32_t *) LED_BUFFER,              NUM_LEDS*3 );  
memcpy(strip.Pixels(),                     LED_BUFFER,              NUM_LEDS*3);
strip.Dirty();
for( int i = 0;i<NUM_LEDS*3; i=i+3) {
Serial.print((char)strip.GetPixelColor(i).R);Serial.print("-"); 
Serial.print((char)strip.GetPixelColor(i).G);Serial.print("-"); 
Serial.print((char)strip.GetPixelColor(i).B);
Serial.println("");
}
strip.Show();
_memory_pointer+=(NUM_LEDS*3);
Current_imageLine++;
delay(1000);  
Serial.println("[new _memory_pointer]");
Mehrdad K
@mkeyno
Oct 04 2016 22:32 UTC
Michael check this out
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("-");   // totally correct 
  }
   Serial.println("");
                       memcpy(strip.Pixels(),LED_BUFFER,NUM_LEDS*3);
    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).G);  Serial.print("-"); 
   Serial.print((char)strip.GetPixelColor(i).B);  Serial.print("-");  // partial incorrect 
  }
  Serial.println("");
        strip.Show();
        _memory_pointer+=(NUM_LEDS*3);
correct data 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-
incorrect data 0-b-g-g-0-b-b-g-0-0-b-g-g-0-b-b-g-0-[00]-b-g-[00]-[00]-[00]-[00]-[00]-[00]-
Michael Miller
@Makuna
Oct 04 2016 23:04 UTC
@mkeyno Its hard to understand the data output when you cast it to a char. What does the [00] mean for print? I am not sure.
what is the value of NUM_LEDs?
Do you understand when reading from flash it only works in 32bit values? (both 32bit addresses and 32bits at a time).
What happens if you pass it size that is a factor of 4?
I am pretty sure the address of the pixels returned by strip.pixels() is 32bit aligned; otherwise the app would crash in the call to readflash.