Fireduino Buy

Dual-Core Cortex-M3 processor, integrated high-quality audio Codec and WiFi module, have IOT expansion performance, perfectly compatible with the Arduino interface and Arduino IDE programming, and supports FireBlock graphics programming.

TF

Update time:2018-04-13 Views:6094

Fireduino TF

Fireduinohardware integrated SDIO controller, interface driver TF card via SDIO, than the Arduino SPI interface speed has a unique advantage.

Fireduino TF API

begin()

   Description
       Initializing the library and TF card.
  
   Syntax
       TF.begin();

   Parameter 
       None

   Returns 
      Return success or failure(true、 false )

open(...)

   Description 
       Open the file, the default is read-only
  
   Syntax
       TF.open(filename);
       TF.open(filename,FILE_WRITE);

   Parameter 
       filename
       Permissions(FILE_READ,FILE_WRITE)

   Returns 
      returns handle class handle

exists(...)

   Description 
       Test file or directory exists on TF card or not
  
   Syntax
       TF.exists(filename);

   Parameter 
       filename: filename or directory name

   Returns 
      Returns success or failure (true, false)

mkdir(...)

    Description 
       Create a directory on TF card
  
   Syntax
       TF.mkdir(dirname);

   Parameter 
       dirname: directory name

   Returns 
       returns success or failure (true, false)

remove(...)

   Description 
      Delete files from TF card
  
   Syntax
       TF.remove(filename);

   Parameter 
       filename: filename

   Returns 
      Returns success or failure (true, false)

rmdir(...)

   Description
       Remove directory
  
   Syntax
       TF.rmdir(dirname);

   Parameter 
       dirname: directory name

   Returns
      Returns success or failure (true, false)

Fireduino File API

write(...)

   Description 
       Write data to files
  
   Syntax
       file.write(data)
       file.write(buf, len)

   Parameter 
       data : characters 
       buf : characters  array
       len : write length

   Returns 
      The number of characters to write

read(...)

   Description 
       Reads data from a file
  
   Syntax
       file.read()
       file.read(buf, len)

   Parameter 
       data : Character
       buf : Character array
       len : Write length

   Returns 
      Character of read or number of characters read

peek(...)

   Description 
       The next character peeping file (file position pointer does not move)
  
   Syntax
       file.peek()

   Parameter 
       None

   Returns 
      The next character, if the next empty returns -1.

seek(...)

   Description 
       Move the file pointer position (from scratch)
  
   Syntax
       file.seek(pos)

   Parameter 
       pos : The new pointer position (0 ~ file size)

   Returns 
       return success or failure (true, false)

available()

   Description 
       Check whether the file has content
  
   Syntax
       file.available()

   Parameter 
       None

   Returns 
       Number of characters readable

flush()

   Description 
       Confirm file write
  
   Syntax
       file.flush()

   Parameter 
       None

   Returns 
      None

position()

   Description
       Get the current file pointer position
  
   Syntax
       file. position()

   Parameter 
       None

   Returns 
       Location of the file pointer

size()

   Description 
       Get File Size
  
   Syntax
       file.size()

   Parameter 
       None

   Returns 
      None

close()

   Description 
       Close the file
  
   Syntax
       file.close()

   Parameter 
       Nonebr />
   Returns 
      None

Fireduino TF Example

#include "Arduino.h"#include "TF.h"File file;void setup(void){
	Serial.begin(115200);
	Serial.print("\r\narduino setup ...\r\n");if(!TF.begin()){
		Serial.println("\r\nTF.begin err ...\r\n");while(1);}
	file = TF.open("test.txt",FILE_WRITE);if(root){
		Serial.println("TF.open(\"test.txt\") ok!");
		file.write((unsigned char *)"01234567890",10);
		file.write(65);
		file.write(66);
		file.write(65);
		file.write(66);
		file.write((unsigned char *)"01234567890",10);
		file.seek(0);
		Serial.print("file size:");
		Serial.println(file.size());while(root.available()){
			Serial.println(file.read(),BYTE);}
		file.close();}else{
		Serial.println("TF.open(\"test.txt\") err!\n");}}void loop(void){
	Serial.println("loop ... \r\n");
	delay(1000);}