Save data to a file

Description

Save data from serial port to file in flash memory.

Note: This function can't run in commands set.

This function will finish writing data to file until:

  1. the specified length of data received.
  2. the waiting time out on serial port---not data received in 0.2 seconds.

Warning: If the file name already exist in flash memory, this operation will over write the old one.

Usage:

Direct:

"fSAVEfilename ",following with 3 bytes MSB of file length(bytes)

Arduino:

char saveFile(const char *fname, uint8_t *data)

C:

char Digole_saveFile(const char *fname, uint8_t *data)

Parameters:

fname

Specify the file name in flash memory.

data 

The pointer to data string going to be saved.

Return:

Return value 17 when finishing file writing. Can be used to determine if writing finished, then send other commands to display

Example (Arduino):

uint8_t data[]={......};

mydisp.saveFile("hello.txt",data);  
 

Example(direct)

serial.writeString("fSAVEhello.txt ");
serial.write(0xff);  //MSB of length, can be the maximum value if don't know the accurate length
serial.write(0xff);
serial.write(0xff);  //LSB of length
for(char i=0;i<64;i++){
      serial.write(i);
}

delay(300);            //this delay will terminate the writing to file, and the file length of "hello.txt" only 64 bytes, the file contents are 0~64

Changelog

Version Description
V7 function was added.

See Also