Automatic/Variable File naming to SD card
TurboMan
Posts: 19
I'm not a super programmer by any means so be nice. I have searched in the forums for a couple hours and I apparently don't know what key words to use because I came up empty. I currently have created a type of datalogger that is steaming 2channels 1200 Hz binary to an SD card. I'm using Kwabena FAT 16/32 drivers and they work fabulous. I'm probably missing something simple but at minimum, I would like to auto increment the file name such as File1.DAT, File2.DAT...... I can't figure out how to send a string with a variable in it. The call is such... fat0.openFile(string("File.DAT"), "W"). At min. I can use an index funtion to create a numeric counter but I've tried every way I can think of to insert that generated # into the "File###.DAT" with no success.
I'm sure this is a simple task for the seasoned programmer. Help anyone?
TM
I'm sure this is a simple task for the seasoned programmer. Help anyone?
TM
Comments
Try looking in your library for 'simple_numbers' and see if the 'dec' method doesn't help? It may not be exactly what you want, but it should be close!
... Tim
BTW Thanks Tim for a response and maybe I missed the answer.
Thanks Dave.
1. bytemove the prefix of the filename ("FILE")
2. Use a decimal to string routine to convert the number to a string
3. Move the string from 2. to the end of the string from 1.
4. Move the suffix (".DAT") to the end of that.
In spin, this can be done in at most 9 lines.
The top 5 lines allow you to figure out what the file was with the largest index.
I will experiment with the options that everyone has given. It's great to be able to get help like this. BTW The SD FAT code that you created is very nice. I haven't had any issues with the few cards that I have used. Seems stable so far.
Again Thanks to everyone.
TM
It uses this method:
During the program run, this happens when a new record session is initiated:
Note the post-increment operator on filenum. Finally, the base file name was store in a dat section like this:
All this is to say that the suggestions you've been given work in practice; my animation file number auto increments every time I do a recording and when I power back up,it starts at the right place.
Thanks to all, I'm past that and on to the next expansion to the device.....
TM