Zuzu, start by telling what is it that you are trying to do. Then it is much easier to help.
STORYTIME !
When I was in school, I always went to the tool store keeper (a Mr. Malminen, great guy) to ask for tool X. Then he brought it to me. Before he handed it over the counter, he held on to it lingeringly and asked: “what are you trying to do?”. After I explained, he said “I know a better tool for doing that”, took tool X back to the shelf, brought me tool Y, and I went back to class with it. This happened dozens of times. And not only to me, I later heard the same story from all my classmates.
I’m trying to figure out how to write things to SD
I’ll need it later to safe game-data. This test program should put numbers on a file and read it afterwards.
It’s important that i can write every object data. Btw i’m testing the r/w speed also.
PetitFatFS (built in SD library, used in the loader)
fastest, smallest memory use
can not create, delete or resize files
save file must exist and be correct size (fill it zeroes or other dummy data)
SDfileSystem (external mbed library)
can do pretty much anything including creating files
not as fast as PetitFatFS
Pokitto::Cookie class (EEPROM cookies for small data, like highscores etc)
-works without SD
-very simple to use
-data size is limited (I would say absolute max 512 bytes, if more use SD instead)
I’m fine with the SDFileSystem, it’s perfect, if it would work for me. I’m don’t know why the code above does’nt work. I’ll debug it now. If anyone knows the issue please tell me
First, check whether the file is actually being created on the SD card. Put it in an adapter and take a look at it. Use a hex editor to check the values in the file are what you intended.
Do a less extreme version of the reading test first. Before the isRunning loop, open the file once, read first 10 values into buffer. Dont seek, just read. Dont even close the filw
Then in the display update loop, println the 0…9 elements
It seems like the pins at SDFileSystem sd(P0_9,P0_8, P0_6, P0_7,"sd"); are wrong. @jonne what are the exact pins for SD? These ones are somehow connected to the buttons…
Yes @Zuzu36 , this is the correct answer. Create the SDFileSystem.object after game.begin. The init process is interfering with the SDFileSystem object