neu-rah / ArduinoMenu

Arduino generic menu/interactivity system
GNU Lesser General Public License v2.1
931 stars 189 forks source link

SDFat.ino and SDCard.ino not working #363

Open hicksan opened 2 years ago

hicksan commented 2 years ago

I set up the basic demo for reading an SD card with ArduinoMenu but it didn't work - output garbage characters and crashed repeatedly. Passed on to friends with more experience in C++, who diagnosed that strings were being referred to as pointers when the menu was being printed, and string data was being written into program memory on the Arduino, causing it to crash. The same problem occurred with both SDCard.ino, using the SDCard.h library and SdFat.ino, using the SdFat.h library.

hicksan commented 2 years ago

We finally found the cause.

These libraries both require a declaration of MENU_USERAM variable. This has the effect, in items.h, of converting menu node items from garbage pointers to text (lines 259+, within the class definition of menuNode). It is declared in macros.h, on line 4 at the top of the file. Both files are located in the src directory of the library.

Unfortunately in macros.h, as supplied, it is commented out. All that is required is to uncomment it (edit the file to remove the "//" at the beginning of the line. Doing that completely fixed the problem and the file runs perfectly now.