I wrote a new library, Flash, which abstracts away most of the complexity of PROGMEM programming. It provides String, Array, and Table types that make ROM-based data collections as easy to use as “normal” types. Each overrides the C++ [] operator, so to get at individual elements, one simply uses familiar array syntax. For example, if you have 1000 floating point temperatures in a flash-based “temperature_table” array, you might write code like this:
for (int i=0; i<temperature_table.count(); ++i) if (temperature_table[i] > 98.6) Serial.println(temperature_table[i]);
Interested to learn more? Read all about it here!
Mikal
Oleg Mazurov
15 years ago
The link to Flash3.zip is broken. It gives me 404 when I try to follow it.
Oleg.
Mikal
15 years ago
Thanks, Oleg. I don’t know what I was thinking. The latest is version 2.
Mikal
Hans Loepfe
15 years ago
Hi Mikal
Your Flash Library looks very promising, but I did not succeed either.
I modified a sketch for a camera remote release timer with an LCD and with a few pages to enter data in order to shoot several images.
Unfortunately, when flipping through the settings pages, the code crashes.
I know that the 2 arrays are using too much memory and causing this sketch to crash as there is not enought RAM.
I was told to move the arrays into FLASH-Memory. I tried with the aid of the PROGMEM reference, but did not succeed writing the correct syntax.
The problem I am having is that I am using ‘unsigned long’ variables and I just can’t get the code right.
Would you mind helping me on this? I’d highly appreciate it as I am more a photographer and less a code writer.
The WEB-page for this project and the code is here:
http://www.halo-photographs.com/remote-shutter-release-timer/the-arduino-code.html
The arrays in question are on line 154 and line 157.
Looking forward to your reply.
Thanks, Hans.
Mike
15 years ago
Hey Mikal,
I’m having some problems that I was hoping you would know how to resolve. I get the error when I just have the #include and no calls to the library.
/Users/Mike/Downloads/arduino-0012/hardware/libraries/Flash/Flash.o:(.data+0xa): undefined reference to `__cxa_pure_virtual’
Couldn’t determine program size: hardware/tools/avr/bin/avr-size: ‘/tmp/build2486.tmp/sketch_090608a.hex’: No such file
Thanks for your time,
Mike
Mikal
15 years ago
Mike,
I notice that you’re using Arduino 0012. That’s pretty old. I’m not sure I ever even tested Flash on that. Can you try upgrading?
What other libraries are you using in your project? I wonder if there is some conflict.
Mikal
Simon
15 years ago
Hello Mikal.
This Flash library is of great interest to me for a project that needs to access several kB of data. My question is whether one can create a flash object without declaring its value in the same statement. I would like to initialize the data structures and then send a bunch of values over the serial port to populate the array or table. Thanks for your help.
Best regards,
=Simon=
Mikal
15 years ago
Simon,
I’m afraid the scenario you hope for cannot be accomplished using Flash or any other library. It is an architectural limitation of the flash that it can only be written in its entirety once when you program your sketch, so you can’t write to it during the run of your program.
Mikal