cmaglie / FlashStorage

A convenient way to store data into Flash memory on the ATSAMD21 and ATSAMD51 processor family
203 stars 69 forks source link

Question: Data Types #9

Closed TuumIO closed 7 years ago

TuumIO commented 7 years ago

Hi, does this library work with all Data Types? I tried with "String" and "char" and didn't work.

Thanks

fabltd commented 7 years ago

Any up date on this. I tried a string but only part of it is stored.

cmaglie commented 7 years ago

Using just String won't work because you need to know the storage size upfront (while the string can grow dynamically as you add to the string itself).

To store a string you must use the method string.toCharArray(....) to copy the string content into a char array. See: https://github.com/cmaglie/FlashStorage/blob/master/examples/StoreNameAndSurname/StoreNameAndSurname.ino for a complete example.