Storing data in flash memory

Général

ragnarok93

il y a 6 ans

Hello I have one question. How i can store data (for example an object) in flash memory and when I need it just import it to ram ?

Sorunome

NEW il y a 6 ans

Assuming you are using the META, by adding const to your variable definitions you put them into flash.

This string is in RAM:

char mystring[] = "Hello World";

while this string is in flash:

const char mystring[] = "Hello World";

You can access both the exact same way

geed

il y a 6 ans

Is a difference with PROGMEM ?


ragnarok93

NEW il y a 6 ans

Thanks, helpful as always ;). But now I encounter other problem. I want to store my stage data in object of Room class. Sadly I can't make it const cause im adding things to it on setup by using methods. So how can I store my stage data in flash ?

ragnarok93

NEW il y a 6 ans

I can make all stage objects and then store it in constant array but still there are non-constant created objects that still gonna be in RAM not in flash :C

Sorunome

il y a 6 ans

Via brace initializers (you can't run a custom constructor then, though)

const MyObj test = {42, 1337};

the parameters are the attributes in the order they appear

Sorunome

NEW il y a 6 ans

ragnarok93 ragnarok93

Via brace initializers (you can't run a custom constructor then, though)

const MyObj test = {42, 1337};

the parameters are the attributes in the order they appear

geed

NEW il y a 6 ans

Sorunome Sorunome

Is a difference with PROGMEM ?


Sorunome

il y a 6 ans

PROGMEM isn't relevant for the META, as it only has one addressible space. Both the PROGMEM keyword and the F() macro literally do nothing when compiling for the META

Sorunome

NEW il y a 6 ans

geed geed

PROGMEM isn't relevant for the META, as it only has one addressible space. Both the PROGMEM keyword and the F() macro literally do nothing when compiling for the META

ragnarok93

il y a 6 ans

Okay, I got it :D. Thanks for help ^^

ragnarok93

NEW il y a 6 ans

Sorunome Sorunome

Okay, I got it :D. Thanks for help ^^