Your Thoughts On A 2 Line Display and SD Card

Hello everyone. Thank you for Arduino!

This is nothing new, but I have a 2 line display, I have an SD card reader.
I have got a sketch that will read 4 'messages' from the SD card and display them on the screen.

However, I was thinking it would be great if the Arduino could/would, rather than load all 4 messages into precious memory, instead would just read the 'next' message on the SD card...

Thinking through this, I have a couple of questions and maybe need some guidance?

Does someone know of an SD library that will read the contents of a file, line by line, keeping track of where it is?

Each message actually has 3 lines in the file...
Message1Text =, Message1Delay=, Message1Type=

Would I simply have in the file, a sequence of three lines -

MessageText=
MessageDelay=
MessageType=
MessageText=
MessageDelay=
MessageType=
MessageText=
MessageDelay=
MessageType=

I was also considering opening and closing the SD card everytime, but that sounds like a nightmare and an ever-growing delay as the Arduino goes to the index location in the file.

I am currently using "SDCONFIG FILE" by Fuzzer11 ( GitHub - Fuzzer11/SDconfig: Arduino Library to read an SD Configuration File ) forked from bneedhamia ( GitHub - bneedhamia/sdconfigfile: Arduino Library to read an SD Configuration File )

I'd like to not have to put an INT or something at the top of the file to tell how many messages there are, just read until the end, start over??

Thank you!

What creates the file you are reading? There shouldn't be a need to repeat the names of the three fields, just their values. I don't care, just curious.

Reading through a file maintaining an idea of where you are is straightforward, whether or not you open and close the file in between.

Post that please. It will provide a picture of where you are as a point of departure.

a7

Just read once trough the whole file and remember the amount of rows in a variable.

Btw You could read the next block of 3 lines while the user is reading the first block alread.

You guys are absolutely right. Just read 3 lines of the file at a time.
Simple -- just over thinking it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.