A question about convert decimal value to string then to store into SD card!!
Hello everyone~
I tried to use the object fsrw.spin to save data in SD card.
Here is my code:
Are there anyone knows that how to convert a variable to string, then save the variable into the SD card ?
Just like A := 10
convert A to string
SDFat.pputs(A)
......
......
Are there any example or any suggestion?
Thanks a lot.
Here is my code.
Code.rar
I tried to use the object fsrw.spin to save data in SD card.
Here is my code:
CON
_clkmode = xtal1 + pll16x ' Set up the clock frequencies
_xinfreq = 5_000_000
CS = 3 ' Propeller Pin 3
DI = 2 ' Propeller Pin 2
CLK = 1 ' Propeller Pin 1
D0 = 0 ' Propeller Pin 0
OBJ
SDfat : "fsrw" ' Download the fswr.spin object from the Parallax Propeller Object Exchange (OBEX), accessed from parallax.com
Debug : "FullDuplexSerialPlus"
PUB Main | insert_card
Debug.start(31, 30, 0, 115_200)
Debug.tx(16)
waitcnt(clkfreq*3 + cnt)
insert_card := \SDfat.mount_explicit(D0, CLK, DI, CS)
if insert_card < 0
Debug.str(string(13))
Debug.str(string("The Micro SD Card was not found!"))
Debug.str(string(13))
Debug.str(string("Insert card, or check your connections."))
Debug.str(string(13))
abort
Debug.str(string(13))
Debug.str(string("Micro SD card was found!"))
Debug.str(string(13))
SDFat.popen(string("output.txt"), "a") 'Open a txt file
[B]SDFat.pputs(string ("text")) [/B]
SDFat.pclose
Debug.str(string("Text was written the [B]text [/B]on the Micro SD Card"))
SDFat.unmount
The SDFat.pputs command seems like have to be string!!Are there anyone knows that how to convert a variable to string, then save the variable into the SD card ?
Just like A := 10
convert A to string
SDFat.pputs(A)
......
......
Are there any example or any suggestion?
Thanks a lot.
Here is my code.
Code.rar

Comments
simple_numbers on the obex is good too.
bot can convert your number to a string. numbers is more powerful, but simple numbers has some feature i like and use (zero padded numbers and so on).
Simply declare num in the object and use it in the pputs function
out of memory something like that:
SDFat.pputs(num.dec (A))
you probably have many options, decf, decx, and so on to set the number format, but all of them convert your number to string.
Massimo
edit:
with simple_numbers is use something like that:
fsrw.sdstr(num.decx(abs_windspeed,6))