SD Card help on reading text lines from a file
Mike_GTN
Posts: 106
Hi Everyone,
I have a project that would like to use an SD memory card to open a file called Label.txt that will contain
8 lines of text as in: -
One
Two
Three
etc
I do not need to process these lines, above using each one seperately to represent information to a user via LCD on the selection of input 1 to 8. Thus far have tested that my hardware can correctly detect an SD memory card. Really looking for a few pointers on how to accomplish this instead of fully completed code from the forum.
Thank-you for any insight offered.
Mike.
I have a project that would like to use an SD memory card to open a file called Label.txt that will contain
8 lines of text as in: -
One
Two
Three
etc
I do not need to process these lines, above using each one seperately to represent information to a user via LCD on the selection of input 1 to 8. Thus far have tested that my hardware can correctly detect an SD memory card. Really looking for a few pointers on how to accomplish this instead of fully completed code from the forum.
Thank-you for any insight offered.
Mike.
Comments
There is a fair bit of code in there that you won't need - eg the demo does all sorts of things like play wav files. So it might be a matter of removing bits.
The 'main' program is the SD3FATDemo and just check that for startup syntax and opening and closing files.
The routine that does the part you need is in the FATEngine and this is the code
One small thing there is that this reads a line and ends with either 13 or 10. If you are reading a line of text, you might want to delete one of those and it will depend on which order they are saved, eg if you file saves 13,10, then you might finish on 10 so you might modify that code to ignore the 13. Or you might use that code as it is, and it reads the line of text, and then maybe the alternate lines return a 10. Perhaps test this as it is very close to what you want. If you can read your text file with a binary reader program (I use hexedit and simply rename .txt files as .bin files) then you can see which order the 13 and 10 are stored.
There are a lot of things you won't need in Kye's code. The real time clock is optional (it is used for date stamping but works fine without this). You might find the string object useful if you want to process the strings of text.