Print via one line

Hi,

in my program i have now the following syntax to write info to a file. I'ts working.

dataFile.print("teller: "); dataFile.print(i); dataFile.print(" uur: "); dataFile.print(uur); dataFile.println();

My question, can i do this on 1 line (something like this --> dataFile.println("teller: "+(i)+"uur: "+(uur)); Can it be done and will i gain time (clockcycles) by printing it via one line?

Thanks

You can do it with the sprintf() function as long as none of the variables are floats. It takes 2 statements to do it. One to format the data in the buffer and one to actually print it, but at the expense of a lot of memory being used.

In any case, why bother ? What are you trying to speed up ?

Yes, you can write with one command. No, it won't make a big difference in speed.

Using "sprintf" can create a line of text. And that can be written with a single dataFile.print.

You can try to set the SPI bus speed higher. I don't know what the default value is (perhaps 2MHz), so you can try 4MHz perhaps.

(While I was writing this, UKHeliBob wrote the same. Well, I'm gonna post it anyway)