SD card

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
scollins22
Posts: 30
Joined: Sat Mar 05, 2016 11:15 am
Been thanked: 3 times

SD card

Post by scollins22 »

Hello I am a new user. I am trying to write a file to the sd card and then open it and display on lcd. I am having no luck please help. I have attached my file.
Attachments
FlowcodeSD card.fcfx
(8.62 KiB) Downloaded 381 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SD card

Post by Benj »

Hello,

I've made some modest modifications and your program now seems to be working well in simulation.
FlowcodeSD card.fcfx
(11.15 KiB) Downloaded 406 times

scollins22
Posts: 30
Joined: Sat Mar 05, 2016 11:15 am
Been thanked: 3 times

Re: SD card

Post by scollins22 »

Thanks so much. I think I am a bit confused though can i not create a string in the variable filecontent and then display that after i have written it to the sd card on my lcd. so that when i printascii(retval) it is the string i stored on filecontent. such as a calculation that file to content = hello then the lcd prints that as the reval.sorry if i am a bit noobish.

scollins22
Posts: 30
Joined: Sat Mar 05, 2016 11:15 am
Been thanked: 3 times

Re: SD card

Post by scollins22 »

Sorry. Am I being a fool or can you not read a file from the sd card and display on the lcd.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SD card

Post by Benj »

Hello,
I think I am a bit confused though can i not create a string in the variable filecontent and then display that after i have written it to the sd card on my lcd.
You can assign a variable to a string and then use that string to write to the SD card and then write to an LCD. This should all work fine.
when i printascii(retval) it is the string i stored on filecontent
Print ASCII only prints a single byte to the LCD. This is why I used a loop to go through the string a byte at a time. You could instead use the print function which allows a string to be printed to the display in a single command.

If your still struggling then please post your current flowchart again and we can look and see if we can work out what's going wrong.

scollins22
Posts: 30
Joined: Sat Mar 05, 2016 11:15 am
Been thanked: 3 times

Re: SD card

Post by scollins22 »

Hello. I am a little confused about the sequence. If I create a file on the sd card and then append string to file. does that mean that I am writing the string hello i created on the variable file content to the file of the sd card or does it place the name of the variable filecontent into the file aswell or only. what would be written onto the append string to file on a real sd card? if I then write to file how can I read a file in the sd card and write it to the lcd.
Attachments
FlowcodeSD card.fcfx
(8.53 KiB) Downloaded 381 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SD card

Post by Benj »

Hello,
If I create a file on the sd card and then append string to file. does that mean that I am writing the string hello i created on the variable file content to the file of the sd card or does it place the name of the variable filecontent into the file aswell or only.
A string variable is a number of locations in RAM. If you assign the value "Hello" to the string then the ASCII bytes 'H', 'e' etc are transferred to the bytes in RAM.

If you create a file on an SD card, open the file and then use the append string function then it will take the bytes from RAM and write those bytes to the file on the SD card.

You will end up with a file on the SD card which contains the text "Hello".
if I then write to file how can I read a file in the sd card and write it to the lcd.
In the example I posted above I take the string you assign and write it to a file. I then re-open the file and stream the contents to the LCD.

Create File "text.txt"
Open File "text.txt"
Append To File "writing to SD card"

Open File "text.txt"
Stream contents from file to LCD

scollins22
Posts: 30
Joined: Sat Mar 05, 2016 11:15 am
Been thanked: 3 times

Re: SD card

Post by scollins22 »

Thanks Benj I got it now. TYVM

scollins22
Posts: 30
Joined: Sat Mar 05, 2016 11:15 am
Been thanked: 3 times

Re: SD card

Post by scollins22 »

I think I have a little prob. If I wanted to have the lcd read the file from the sd as in a real scenario where the micro scans for sd insert then displays the file contents to lcd would the flowcode program work. I have included your file up to where I understand then want to open sd and read its contents with micro and display on lcd.
Attachments
FlowcodeSD card.fcfx
(9.5 KiB) Downloaded 368 times

scollins22
Posts: 30
Joined: Sat Mar 05, 2016 11:15 am
Been thanked: 3 times

Re: SD card

Post by scollins22 »

Am I going in the right direction?

scollins22
Posts: 30
Joined: Sat Mar 05, 2016 11:15 am
Been thanked: 3 times

Re: SD card

Post by scollins22 »

In your example I still do not see how you read byte from file and it then goes to lcd

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SD card

Post by Benj »

Hello,

Have a look at the example here and it shows streaming a file byte by byte from a file to the LCD.

http://www.matrixtsl.com/wiki/index.php ... _text_file

scollins22
Posts: 30
Joined: Sat Mar 05, 2016 11:15 am
Been thanked: 3 times

Re: SD card

Post by scollins22 »

TYVM I got it now

Post Reply