Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Mehrdad K
@mkeyno
actually this is the code line i += FILe.readBytes( ((byte*)leds) + i, (NUM_LEDS*3)-i);
it supposed to read one 144*3 byte of data from file and fed it to the LED array to display
the compiler says , I should casted to char
Ivan Grokhotkov
@igrr
can you please paste the actual error compiler produces?
Mehrdad K
@mkeyno
invalid conversion from 'byte {aka unsigned char}' to 'char*' [-fpermissive]
            i += FILe.readBytes( ((byte*)leds) + i, (NUM_LEDS*3)-i);
Ivan Grokhotkov
@igrr
okay
Mehrdad K
@mkeyno
should I override it
Ivan Grokhotkov
@igrr
so you have found the declaration of readBytes function, right?
virtual size_t fs::File::readBytes(char*, size_t)
Mehrdad K
@mkeyno
yes
Ivan Grokhotkov
@igrr
what type does it take as its first argument?
Mehrdad K
@mkeyno
I need byte for each R, G,B color
Ivan Grokhotkov
@igrr
what type does readBytes function take as its first argument?
Mehrdad K
@mkeyno
GRGB type , this is object from fastLED repo
Ivan Grokhotkov
@igrr
incorrect :)
look at readBytes function prototype again
Mehrdad K
@mkeyno
I know , but it work with char , and used many times in fastLED to read bytes
I don't know how but its work if casted to char
Ivan Grokhotkov
@igrr
so which type do you need to pass into this function if it takes char*?
Mehrdad K
@mkeyno
byte*
FILe.readBytes( ((char*)leds) + i, (NUM_LEDS*3)-i); this worked
Ivan Grokhotkov
@igrr
nope, look at the function prototype again :)
virtual size_t fs::File::readBytes(char*, size_t)
which type does it take?
Mehrdad K
@mkeyno
whereas define CRGB leds[NUM_LEDS];
Ivan Grokhotkov
@igrr
virtual size_t fs::File::readBytes(char*, size_t)
it takes char*
so you should cast to char*
Mehrdad K
@mkeyno
can I override it to byte
Ivan Grokhotkov
@igrr
no
just cast to char*
Mehrdad K
@mkeyno
but people use this function in FastLED repo to read bytes of data and fed it to LED.show() function
why can't override it to byte
FWeinb
@FWeinb
As far as I can see in the documentation they do cast it to (char*). See this.
Ivan Grokhotkov
@igrr
char is the same size as byte
Mehrdad K
@mkeyno
I know but we need all 255 range of color and char range -127 to 127
I should ask them how they do it
thanks @FWeinb I don't know whether it work or not
but it seems have no problem with char*
@igrr I have another problem , reading the the byte from file and fed to function to manipulate it , it is so slow , may I discuss about my code here
Mehrdad K
@mkeyno

I run the POV project with teensy1.2 which is read image lines from SD card and show it in LED strip , each image consist of 300 line 144 pixel 3 byte (about 127 Kbyte)of data which is show in less than 40ms (25 fps)
Then I’ve tried to port it to ESP module , the loop function consist three condition along with wifi websocket service
The first condition check whether duration of show is passed and is time to close last file and open the new file

if( (millis()- OpenlastTime) > DURATION[image_index]*1000L )
        {
          FILe.close();
          image_index++; 
          if(image_index>IMAGE_NUM)    image_index=0;          
           FILe=SPIFFS.open("/SHOW/"+IMAGES[image_index], "r");
          if(!FILe) Serial.println("FILE NOT OPEN");
          OpenlastTime=millis();
        }

The second condition check whether new revolution started and time duration of last line has been passed , it read one chunk of data (number of LED * 3) and fed to show function to display it

if(!Start_new_round && (micros()-lastLineShow)> lineInterval)
        {
        int i = 0; 
           while( (i < NUM_LEDS*3) && FILe.available())
          { 
               i += FILe.readBytes( ((char*)leds) + i, (NUM_LEDS*3)-i);
            }

        FastLED.show(); 
        lastLineShow=micros();
        Current_imageLine++;                                        
        }

The third condition check whether it reach the total line of frame or not , if yes set the file read as beginning and reset to show the frame again

if(Current_imageLine >= IMAGES_LINES)   
          { 
            Serial.print("[frame]"); Serial.println((micros()-lastFrameShow));
            Current_imageLine = 0;
            lastFrameShow=micros(); 
            Start_new_round=false; 
            FILe.seek(0, SeekSet);
           }

But when I calculate the time of each frame it is huge and beyond expectation
More than 1 second for each frame , following is the serial output
i=0 New Image=1.bin duration=4
[frame]1639135
[frame]1571890
i=1 New Image=3.bin duration=4
[frame]1580551
[frame]1038532
[frame]1038509
[frame]1038295
i=2 New Image=2.bin duration=4
[frame]1064185
[frame]1083934
[frame]1085061
[frame]1085059

I don’t know where my time is wasted or which procedure took so long

Mehrdad K
@mkeyno
according to https://github.com/bbx10/esp-spiffs-test test it should read each line less than 1 micro second , but I don't know why this took so long
even when disable wifi (WIFI_OFF)
SteveToulouse
@SteveToulouse

Just an extra data point for you, for comparison. Running Arduino 1.6.9/ESP8266 2.3.0 on a NodeMCU Amica 1.0, 3MByte SPIFFS (80MHz), I get an average of 1.5Mbyte/s read (M=1000), max 2.1MB/s, min 1.1Mbit/s, median 1.4 - values are rather variable for the 7 successful test loops before write error.

What type is your ESP-xx module exactly ?

SteveToulouse
@SteveToulouse

Errr sorry, my flash chip is given as 40MHz speed by the example "CheckFlashConfig.ino" sketch.

Wonder why the speed test fails after 7 loops however, because it seems to reuse the same file over and over again?

Mehrdad K
@mkeyno
thanks @SteveToulouse for your note but I read the post the ESP chip is around 460 Kbayte per second
my chip is ESP-01
SteveToulouse
@SteveToulouse
'''
Flash ide size: 4194304
Flash ide speed: 40000000
Flash ide mode: DIO
Flash Chip configuration ok.
Mehrdad K
@mkeyno
also tested on ESP-12F the fram rate around 1 second
I think for 25 frame 200 line 144 pixel * 3 byte need around 2 Mbayte per second
I don't know whether ESP can handle it or not