Flash

A Library to Ease Accessing Flash-based (PROGMEM) Data

Storing static program data in flash/PROGMEM is a tricky part of Arduino programming. To save precious RAM, a novice user already at odds with unfamiliar C++ syntax must digest such daunting concepts as prog_char, PSTR(), PROGMEM, pgm_read_word(), etc. Even seasoned users get tripped up by the indirection and typecasting that are required to retrieve valid PROGMEM data. Add to that a couple of apparent bugs in the implementation, and it’s clear that PROGMEM is a complicated mess.

I have written a new library, Flash, which abstracts away most of this complexity. It provides new String, Array, Table, and String Array types that make ROM-based data collections as easy to use as “normal” types. Each overrides the C++ [] operator, so to extract individual elements one uses familiar array access syntax:

// float array example
float t = temperatures[950];

// (2D) font table example
digitalWrite(pin[i], font_table['a'][i]);
// string example
for (int i=0; i<str.length(); ++i)
  if (str[i] == ';') break;

Download and Installation

To install this library, download here, unzip the archive into the Arduino “libraries” folder, and restart Arduino. You should rename the folder “Flash”, because the IDE doesn’t like dashes in the name.
Download

Creating named Flash objects

To create a Flash object, you use a library-provided macro. Each of the four basic types provides its own creation macro:

Strings: FLASH_STRING(name, value)
Arrays: FLASH_ARRAY(type, name, list of values…)
Tables: FLASH_TABLE(type, name, columns, values…)
String Arrays: FLASH_STRING_ARRAY(name, values…)

Examples:

FLASH_STRING(big_string, "Moreover, as you might appreciate, "
    "their implications were such as to provoke a certain "
    "degree of sorrow within me. Indeed - why should I not "
    "admit it? - at that moment, my heart was breaking.");
FLASH_ARRAY(float, temperatures, 23.1, 23.1, 23.2, 23.2, 23.4,
    23.7, 25.0, 26.0, 26.8, 28.8, 30.2, 31.9, 33.1, 33.1, 33.2,
    33.2, 33.4, 33.7, 35.0, 36.0, 36.8, 38.8, 40.2, 41.9);
FLASH_TABLE(boolean, font_table, 7, {0,0,0,0,0,0,0},
    {0,0,0,1,0,1,1}, {1,0,1,1,1,0,1}, {1,1,0,0,0,0,0},
    {0,1,0,1,0,1,0}, {1,0,1,1,1,0,1}, {1,0,0,1,0,0,1},
    {0,0,1,1,0,1,1}, {1,0,1,1,1,1,1});
FLASH_STRING_ARRAY(digits, PSTR("Zero"), PSTR("One"),
    PSTR("Two"), PSTR("Three"), PSTR("Four"), PSTR("Five"),
    PSTR("Six"), PSTR("Seven"), PSTR("Eight"), PSTR("Nine"));

[Note that you can make Arrays and Tables out of any native type.]

[Note also that the String Array is a slightly special case. For technical reasons, as you can see in the example, each member of the array initializer must be wrapped with the PSTR() operator. For this reason, String Arrays cannot be declared at global scope, but must be non-statically defined within in the body of a function. Note also that while the individual strings in a String Array are contained in PROGMEM space, the array itself (again, for technical reasons) is RAM-based, consuming 2 bytes per array element. This limitation does not apply to the other Flash types.]

Using named Flash objects

Array-like access. Each Flash type provides an [] operator to get access to the underlying data, for example:

    // extract an element from an Array
    float t = temperatures[5];
    // examine characters in a String
    for (int i=0; i      if (big_string[i] == 'O') ++big_O_counter;
    // Use a font table to configure a 7-segment display
    for (int i=0; i      digitalWrite(pins[i], font_table[1][i]);
    // Examine the sizes of strings in a String Array
    for (int i=0; i      Serial.println(digits[i].length());

Since Tables are really just two-dimensional arrays, the Table object’s implementation of [] returns a one-dimensional Array object.

Size. Each Flash type provides a mechanism for determining its size:

String and String Array: size_t length();
Array: size_t count();
Table: size_t rows(); size_t cols();

Access. If you need it, each Flash object provides an access() method that returns the underlying PROGMEM pointer

Print compatibility. Each Flash object has a print() method that can be used to serialize the object to any stream derived from core class Print (HardwareSerial, NewSoftSerial, LiquidCrystal, Ethernet, PString, etc.) See “Printing Flash objects” below.

String copy. Flash String objects may be copied in whole or part to RAM using the String object’s copy method:

    // copies the first 10 characters of the big_string
    char temp[11];
    big_string.copy(temp, 10);

Printing Flash objects

Each Flash object can “print” itself, using either its print method directly:

    temperatures.print(Serial);
    big_string.print(lcd);
    font_table.print(softserial);

or, equivalently, by using the << streaming operator:

    Serial << temperatures;
    lcd << big_string;
    softserial << font_table;

Library Version

You can retrieve the version of the Flash library by inspecting FLASH_LIBRARY_VERSION.

int ver = FLASH_LIBRARY_VERSION;

Download

The latest version of Flash is available here: Flash5.zip

Change Log

  1. initial version
  2. moved some code to a new .cpp file to avoid inlining every member function
  3. fixed a bug in the copy() method

Acknowledgements

Thanks to forum user Bill W. (“westfw”) for testing Flash and observing that Strings take up a surprising amount of extra PROGMEM space (20 bytes per string). I used his data to modify the library so that some of the commonly used functions, notably the _FLASH_STRING constructor are not inlined. This change reduces the footprint of the example programs noticeably. Thanks, Bill!

I appreciate any suggestions or input.

Mikal Hart

Page last updated on January 30, 2014 at 9:41 pm
250 Responses → “Flash”

  1. Mikal

    4 years ago

    Hmmm. Thanks, p0g0. I need to check on that!


  2. Frank Mertens

    4 years ago

    Hi Mikal,

    I’m new to Arduino… learning every day…
    I’m doing an aquarium automation project with an lcd.
    Recently I fell into the “String concatenation” pitfall, which I managed to solve by using your PString library in a function that takes care of this.
    Thanks for that…
    Now I wanted to move my fixed String arrays to flash so I don’t get in trouble again when adding languages later.
    When I declare the String array as:
    void Stringdeclaration() {
    FLASH_STRING_ARRAY (Day, PSTR(“Monday”), PSTR(“Tuesday”), PSTR(“Wednesday”), PSTR(“Thursday”), PSTR(“Friday”), PSTR(“Saturday”), PSTR(“Sunday”));
    }
    void setup() {
    Stringdeclaration();
    ….
    }
    I assumed I did it as described in your notes (inside a function with PSTR).
    However, I got a compiler error: ‘Day’ was not declared in this scope.
    The only way I got it working was declaring it ‘normally’ without the function and removing the PSTR operator. But I think this way everything stays in RAM, I’m not sure.
    All other combinations I have tried failed…
    Can you give me some more info so I can get this working, and hopefully even understand why…
    Thanks


  3. Mikal

    4 years ago

    @Frank Mertens,

    The declaration has to be in the same function that you use it in. In other words, delete the Stringdeclaration() function and move the declaration of “Day” directly into setup():

    void setup() {
    FLASH_STRING_ARRAY (Day, PSTR(“Monday”), PSTR(“Tuesday”), PSTR(“Wednesday”), PSTR(“Thursday”), PSTR(“Friday”), PSTR(“Saturday”), PSTR(“Sunday”));
    ...
    }

  4. Sparks

    4 years ago

    Mikal, I have added the Flash library to my sketch. I am using the FLASH_STRING_ARRAY. I declare it inside the function where I use it:

    void example(PString &m_data) {
    FLASH_STRING_ARRAY(test_header,
    PSTR(“string 0\n”),
    PSTR(“string 1\n”),
    PSTR(“string 2\n”),
    PSTR(“string 3″));
    etc.
    }
    I nevertheless see warnings in the compilers verbose reporting output: “warning: only initialized variables can be placed into program memory area”.
    What have I missed ? Thanks for your advice !


  5. Mikal

    4 years ago

    Hi Sparks,

    I believe we determined that that warning is a gcc compiler error. Anyway, we just ignore it, as unpleasant as that is.


  6. Sparks

    4 years ago

    OK, thanks for your advice.


  7. Stuart Galloway

    4 years ago

    This program gives weird errors.
    I get the right answer if I print to serial.
    I keep getting the zeroth array member if if dont print to serial!

    #include

    #define ODD 1
    #define EVEN 0
    #define DRY 1
    #define WET 0
    #define RAIN 1
    #define FINE 0
    #define V1 1
    #define V2 2
    #define V3 8
    #define V4 16

    FLASH_TABLE(int, sprinkler, 6 /* width of table */,
    {20,30,V1,ODD,DRY,RAIN},
    {20,32,V2,ODD,FINE,WET},
    {20,36,V3,EVEN,DRY,RAIN},
    {20,39,V4,ODD,WET,RAIN}
    );

    void setup() {
    int tm,t1,t2;
    Serial.begin(115200);
    for (int i = 0; i<4; i++){
    Serial.println(i);
    Serial.println("Error");
    t1 =sprinkler[i][0];
    //Serial.print(t1);
    t2 = sprinkler[i][1];
    //Serial.println(t2);
    tm =t1*60 + t2;
    Serial.println(tm);

    Serial.println("OK");

    t1 =sprinkler[i][0];
    Serial.print(t1);
    t2 = sprinkler[i][1];
    Serial.println(t2);
    tm =t1*60 + t2;
    Serial.println(tm);

    }
    }

    void loop(){
    }


  8. Jose M

    4 years ago

    Congratulations. Your library has been really useful for me. It allowed me to free precious ram space in a complex sketch.


  9. Chen

    4 years ago

    I’m using your Flash Library which is working very nicely in the example code that ships with the lib. But I’m having problems when trying to integrate it in my sketch. Mainly – passing FLASH_TABLE pointes and iterating those objects in the function.

    I browsed the prev comments here and noticed that other people inquired about this in the past. Can you please provide a formal example of how to send one of (let’s say) 3 int based FLASH_TABLEs to a function and iterate the two dimensional pointer inside that function?

    Thanks!!
    Chen.


  10. kburndred

    4 years ago

    I am using arduino due, I keep getting a compilation error when I try to comile the example BlinkLED. The compiler complains that it can’t find pgmspace.h. Do you have any suggestions. I am using the latest arduino IDE (1.5.2) with support for the due.


  11. Colin

    4 years ago

    Hello Mikal,
    My software compiles and works well apart from it crashing after about 5 days. I am not saying it is your code but there are warnings “warning: comparison between signed and unsigned integer expressions”. in flash.h line 75. Isn’t size_t supposed to be an unsigned integer? I see you assign and compare signed integers.

    thanks


  12. chethan

    4 years ago

    here i am trying to copy string array elements to a char array but i am unable to do that, what’s the problem in this program
    #include
    char buffer[20];

    void setup(){
    Serial.begin(9600);
    FLASH_STRING_ARRAY(places, PSTR(“SBM bank ATM”), PSTR(“Nandini Parlour”), PSTR(“Nandini Layout”), PSTR(“Nandini Layout Park”));
    for(int j = 0; j < places.count(); j++){
    places.copy(buffer, places[j]);
    Serial.println(buffer);
    memset(buffer, '', sizeof(buffer));
    }
    }

    void loop(){
    }


  13. Giovanni

    4 years ago

    Hi Mikal.

    If I want to only read data, how is it possible?

    Thank you


  14. Mikal

    4 years ago

    Hi Chen,

    Try this as an example:

    FLASH_TABLE(int, table, 3, {1,2,3}, {4,5,6}, {7,8,9});
    
    void myfunc(_FLASH_TABLE<int> &tab)
    {
      for (int i=0; i<tab.rows(); ++i)
        for (int j=0; j<tab.cols(); ++j)
          Serial.print(tab[i][j]);
    }
    
    void setup() {
      myfunc(table);
    }
    

  15. Mikal

    4 years ago

    @kbrundred, yeah, sorry, Flash was designed with AVR architecture in mind. It’s probably not so important with the Due, as RAM constraints are not too tight.


  16. Mikal

    4 years ago

    @chethan,

    It looks like your double quotes have been corrupted (by MSWord? to decorative quotes. Also the copy line should be:

      places[j].copy(buffer);

  17. Mikal

    4 years ago

    @Giovanni, yep, that’s the whole point of the Flash library–putting read-only data into flash so that it doesn’t occupy RAM unnecessarily.


  18. Chris Mears

    4 years ago

    Hi,

    I am trying to use your excellent library as I am running short of RAM in a large sketch.

    I have a function called UpdateThingSpeak defined as below

    void UpdateThingSpeak(int PumpOnOff,char StatusText[])
    {
    }

    For simplicitys sake I have made each string its own Flash String as so

    FLASH_STRING(Panels_are_too_hot, “Panels are too hot. Pump(s) on”);
    FLASH_STRING(Tropical_mode_active, “Tropical mode active. Pump(s) on”);
    FLASH_STRING(Hot_water_available, “Hot water available. Pumping”);
    FLASH_STRING(Its_very_cold, “It’s very cold. Protect pipes”);
    FLASH_STRING(Pumping_to_stop_pipes, “Pumping to stop pipes bursting”);
    FLASH_STRING(Freezing_point, “Freezing point. Pump(s) off”);
    FLASH_STRING(Collecting_heat, “Collecting heat. Pump(s) off”);
    FLASH_STRING(Waiting_to_pump, “Winter mode. Waiting to pump”);
    FLASH_STRING(Winter_mode_Pumping, “Winter mode. Pumping”);
    FLASH_STRING(Pump_test_mode, “Pump test mode. Pump(s) on”);

    When I try to pass the String to the UpdateThingSpeak function I get

    cannot convert’_FLASH_STRING’ to char* for argument ’2′ to ‘void UpdateThingSpeak(int, char*)’

    I see the problem, I am converting whatever PROGMEM holds the string as to a char[] string. I just don’t know how to overcome it.

    Please can you suggest something


  19. Stephen M.

    4 years ago

    issue appears it does not recognize the #include as when the complier sees:

    FLASH_ARRAY(unsigned long, arrayHtime,1000,2000,3000,50000,60000);

    I get an error of “expected primary expression before ‘unsigned’ and the complier did not make the FLASH_ARRAY highlighted in orange as all other primary commands are???
    Help please
    Stephen


  20. Mikal

    4 years ago

    Hi Chris–

    What you’ll want to do is rewrite UpdateThingSpeak to take a _FLASH_STRING & instead of a char []:

    void UpdateThingSpeak(int PumpOnOff, _FLASH_STRING &StatusText)
    {
      StatusText.print(Serial);
      ...
    }
    

  21. Mikal

    4 years ago

    @Stephen M,

    I think you must not have installed the Flash library in the arduino\libraries folder correctly. When I run this, it works fine:

    #include <Flash.h>
    
    void setup() {
      FLASH_ARRAY(unsigned long, arrayHtime,1000,2000,3000,50000,60000);
      Serial.begin(115200);
      for (int i=0; i<arrayHtime.count(); ++i)
        Serial.println(arrayHtime[i]);
    }
    
    void loop() {
    }
    

  22. Renato

    4 years ago

    Hello,
    I’m new to Arduino and i’m trying to use your library, but something is not clear to me:

    Is it possible to write to my table?

    like

    FLASH_TABLE(int, alarm_table, 4,
    {0,0,0,0});

    and then:

    alarm_table[0][0] = 1;

    to write to this table?


  23. Mikal

    4 years ago

    @Renato,

    Unfortunately, the answer is no. The flash memory is read-only (except at programming time of course). Too bad!


  24. Perry

    4 years ago

    I built a simple flow meter for a friend using an arduino uno. I found the syntax for the project on “jaycar” website. It works fine counting and totaling the liters of fluid. The only problem is, if you get a power cycle, the data is reset to zero on the display. I am trying to keep track of the amount of liters left in a tank so I need the data to stay in memory until reset manually. If it is lost on a power cycle, you cannot recover.
    I am a PLC programmer. It is easy with a PLC, you just store the data from the counter in an upper non volatile register address where it remains indefinitely until reset. I just started looking at this c++ programming (it is very cumbersome and confusing). Is there an easy way to keep the data?


  25. Mikal

    4 years ago

    @Perry,

    Hi, yeah, flash memory is not really what you want for this application, since flash memory is (effectively) read-only. What I suggest you do is look at writing your fluid counter into EEPROM each time it changes. EEPROM is a non-volatile read/write memory. For help on the EEPROM library, which is built in to the Arduino distribution, Google +EEPROM +Arduino.


  26. john

    4 years ago

    Hey, I like the library but the performance is very poor for ethernet client stream as it sends only 1 character at a time. This creates a packet for every character! Here is a change I made to flash.cpp to provide a small buffer. Now speed is excellent.

    #include “Flash.h”
    #include
    #include

    #define FLASHBUFSIZ 300
    char flashbuf[FLASHBUFSIZ + 1];

    _FLASH_STRING::_FLASH_STRING(const prog_char *arr) :
    _arr(arr)
    {
    }

    void _FLASH_STRING::print(Print &stream) const
    {
    size_t i=0;
    size_t l= strnlen_P(_arr,64000);

    while(true) {
    if (l > FLASHBUFSIZ) {
    memcpy_P(flashbuf,_arr + i,FLASHBUFSIZ);
    flashbuf[FLASHBUFSIZ] = 0;
    l -= FLASHBUFSIZ;
    i += FLASHBUFSIZ;
    stream.print(flashbuf);
    }
    else {
    memcpy_P(flashbuf,_arr + i,l);
    flashbuf[l] = 0;
    stream.print(flashbuf);
    break;
    }
    }
    }


  27. Mikal

    4 years ago

    @john,

    Thanks very much for that. I’m sure Ethernet users will find this patch enormously useful.


  28. Alexander Benjamin

    3 years ago

    Hi,

    is there a way to write to a string array at run time.

    What I need is to store strings into array that user types into serial terminal.

    All together user will be able to input 24 strings.

    Would really appreciate your advice.

    Thanks

    Alex


  29. Mikal

    3 years ago

    @Alexander Benjamin,

    Alas, no. Flash is for read-only data.


  30. Alessio

    3 years ago

    Hi Mikal,

    are you in mind to adapt Flash library to new Arduino Due?

    Thanks


  31. Mikal

    3 years ago

    @Alessio,

    I would like to do that, but honestly it’s pretty far down my priority stack. I haven’t had much use for Due development. Is anyone interested in taking that task on?


  32. Cristi

    3 years ago

    Hello Mikal!
    I use your Flash library and I experience the following trouble:
    Code:
    char Stepdsp;
    int Stpdspindex;
    void setup(){
    FLASH_STRING_ARRAY(Step,PSTR(“A”), PSTR(“B”), PSTR(“C”), PSTR(“D”), PSTR(“E”));
    Serial.begin(9600);
    Stpdspindex=3;
    Stepdsp=Step[Stpdspindex];
    Serial.println(Freqstpdsp);
    }
    I receive this error messagge : “Cannot convert ‘_FLASH_STRING’ to ‘char’ in assignment.
    Please tell me how to solve this situation!
    Best regards


  33. Mikal

    3 years ago

    @Cristi–

    Almost there…

    Since Step[Stpdspindex] is a flash string and not a char, what you want is

    Stepdsp = Step[Stpdspindex][0];
    

  34. michael_x

    3 years ago

    I read
    >> a small patch to the core Print.h file. See “Patching Print.h” below

    but did not find what I expected on this page.
    Patch still required for Arduino 1.0.5 ?

    Thanks


  35. Mikal

    3 years ago

    Hi michael_x,

    Unfortunately, this feature doesn’t work with Arduino 1+. You have to use the object.print(Serial) technique. I’ll change that mistake. Thanks.


  36. Trinh Dinh Chung

    3 years ago

    Hi Mikal,
    I’m new to Arduino,my project’s : read tags RFID and save on arduino,then send to orther device,but i don’t know where is data will storage on arduino , i want save tag’s ID ex 0004083312 , please help me, tks you


  37. Mikal

    3 years ago

    @Trinh,

    If you are looking to store dynamically acquired data, you’ll probably want to use the EEPROM library. EEPROM is a read/write medium, but the Flash memory is read-only.


  38. RAFA

    3 years ago

    hello.
    I am using many arrays in the Arduino sketch and exhausted the RAM.
    I’m trying to implement this solution but I think I have a problem with the lib .. the program does not recognize the variables. I’ve done include lib and did not work.
    can you help me?
    thanks


  39. Mikal

    3 years ago

    @RAFA,

    I would need many more details to solve this problem…


  40. RAFA

    3 years ago

    For example, in the code below the program returns me errors when compiling.

    #include <flash.h>
    int x = 0;
    
    void setup(){
      FLASH_ARRAY(int, value, 1, 2, 2, 5, 6, 7, 10);
    }
    
    void loop(){
      x = value[1];
    }
    

    ERRORS:

    flash.ino: In function ‘void setup()’:
    flash:6: error: expected primary-expression before ‘int’
    flash:6: error: ‘value’ was not declared in this scope
    flash:6: error: ‘FLASH_ARRAY’ was not declared in this scope
    flash.ino: In function ‘void loop()’:
    flash:10: error: ‘value’ was not declared in this scope

    I think that is because the compiler is not recognizing the lib
    Thanks


  41. Mikal

    3 years ago

    @RAFA,

    Make sure the flash library is correctly installed, and move the FLASH_ARRAY line outside the setup() function, i.e up one line.


  42. mihai

    3 years ago

    Hi
    How remove data from flash of arduino mega after I wrote in it?
    The flash remaining written after power of, right?
    Many thanks


  43. Mikal

    3 years ago

    @mihai,

    Upload a new empty sketch. That will erase the existing flash.


  44. mihai

    3 years ago

    Many thanks my fiend.Now I understand how works with clear flash.
    Please , another help from your part.
    If I want to save in flash some data read from loop() function , can I do it?
    Thanks again for your support.Have a nice weekend.


  45. Mikal

    3 years ago

    @mihai,

    No, I’m afraid you can’t write to the flash during normal program execution. For read/write non-volatile memory, try the EEPROM.


  46. Karl

    3 years ago

    Just starting to use your library. So far looking good..

    My project consists of multiple source files that need to include Flash.h, and I got lots of redefinition errors such as:
    error: redefinition of ‘class _Printable’

    I suggest putting in protection against the header file being included twice:

    #ifndef FLASH_H
    #define FLASH_H
    … [rest of Flash.h] …
    #endif


  47. Olx

    3 years ago

    #include

    class Test
    {
    public:
    int a;
    int b;
    Test(){
    a=0;
    b=0;
    }
    Test(int aa, int bb){
    a=aa;
    b=bb;
    }
    };

    Test tt = Test(5,6);

    FLASH_ARRAY(Test, ttt, Test(1,2), Test(3,3), Test(5,6), Test(7,8));

    Test t;

    void setup(){
    Serial.begin(9600);
    for (int i = 0; ttt.count(); i++)
    Serial.println(ttt[i].a);
    }

    void loop(){

    }

    ERROR:

    C:\Program Files (x86)\Arduino\libraries\Flash/Flash.h: In member function ‘void _FLASH_ARRAY::print(Print&) const [with T = Test]‘:
    FLASH_TEST.ino:32: instantiated from here
    C:\Program Files (x86)\Arduino\libraries\Flash/Flash.h:126: error: no matching function for call to ‘Print::print(Test)’
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:55: note: candidates are: size_t Print::print(const __FlashStringHelper*)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:56: note: size_t Print::print(const String&)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:57: note: size_t Print::print(const char*)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:58: note: size_t Print::print(char)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:59: note: size_t Print::print(unsigned char, int)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:60: note: size_t Print::print(int, int)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:61: note: size_t Print::print(unsigned int, int)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:62: note: size_t Print::print(long int, int)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:63: note: size_t Print::print(long unsigned int, int)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:64: note: size_t Print::print(double, int)
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:65: note: size_t Print::print(const Printable&)


  48. Olx

    3 years ago

    void setup(){
    Serial.begin(9600);
    FLASH_STRING_ARRAY(pips,
    PSTR(“Ace”), PSTR(“Two”), PSTR(“Three”), PSTR(“Four”), PSTR(“Five”), PSTR(“Six”),
    PSTR(“Seven”), PSTR(“Eight”), PSTR(“Nine”), PSTR(“Ten”), PSTR(“Jack”), PSTR(“Queen”), PSTR(“King”));
    }

    How can I make pips array visible for class level?


  49. Pascal

    3 years ago

    Mikal,

    I am sucessfully using your very nice FLASH library.

    Nevertheless, I have still a lot of (F(“….”)) in my source code and experience strange problems with (F(“…”)).

    On one side the compiler display an error relating to vector while commenting the last typed in (F(“…)) eliminates the error.

    On the other side, it looks like the implementation of the (F(“…”)) is bugged because some variable in my program are changed when running through a printf(F(“…”)) like instruction.

    As you mentioned that the were apparently bugs in the implementation of (F(“…”)), could you explain what you have noticed on your side.

    In the mean-time, I will eliminate all (F(“…”)) from my source code by writing a dedicated print function for Debug messages and put them all in a FLASH_STRING_ARRAY.

    Thanks in advance

    Pascal


  50. Hans

    3 years ago

    Hi Mikal!
    I have build a telephonenumber,”Call-ID” reseiver with a MC8870 chip.
    It is working perfectly, and I get the numbers on an LCD and in IDE.
    Arduinio Uno is used (ATmega328) to detect the numbers.
    The problem is how to store the incomming calls so I later can see
    who has called. I need at least 30 to 50 numbers stored in the
    memory. The numbers are characters displaying one by one untill
    all (10) of them has finished. The last rows in the sketch:

    void storeCalls()
    {
    Serial.print(“Store: “);
    Serial.println(dial);
    lcd.print(dial);
    }

    Here “dial” contains all the ten numbers.
    How can I store this in mem. and then wait for the next
    call to arrive?
    I have installed your Flash.lib but I don’t know
    realy how t use it here.
    Maybe you can help me. This is the last thing to do, to
    get this Call-ID to work properly.
    Best Reg.// Hans

11 Trackbacks For This Post
  1. New Flash library « Arduiniana

    [...] Interested to learn more? Read all about it here! [...]

  2. vkick Blog Site » Blog Archive » How to do Timer and Save Settings?

    [...] http://arduiniana.org/libraries/Flash/ Categories: Arduino Posted By: Mon Last Edit: 18 Jun 2009 @ 04 01 PM Email • Permalink Previous  Responses to this post » (None)  Post a Comment Click here to cancel reply. [...]

  3. Arduino net connected clock tells weather not time

    [...] third party libraries were used; PString to handle parsing the incoming website, Flash for memory management, and Streaming for easier coding. [...]

  4. Blog What I Made » YAHMS: Base Station

    [...] interface, see the links below for that too. You’ll also need NewSoftSerial of course and the Flash library which I’ve used to decrease memory usage. Follow the instructions in [...]

  5. Arduino – Steuern per Internet | bastianmueller - blog

    [...] Steckdose (An/Aus) hängt sich der Ardu komplett auf. Ihr benötigt zusätzlich die Bibliothek Flash (für das Speichern im Flash statt SRAM) und FreeMemory (für die Anzeige des freien [...]

  6. Single Machine Sun Tracking / Heliostat Electronics Set Up – CerebralMeltdown.com

    [...] Also, make sure you download and install the flash.h library before trying to upload this program. Here is the link. http://arduiniana.org/libraries/flash/ [...]

  7. Arduino – Steuern per Internet | 3bm. blog.

    [...] Steckdose (An/Aus) hängt sich der Ardu komplett auf. Ihr benötigt zusätzlich die Bibliothek Flash (für das Speichern im Flash statt SRAM) und FreeMemory (für die Anzeige des freien [...]

  8. Blog J.Schweiss | Design Patterns with Arduino

    [...] http://arduiniana.org/libraries/flash/ Tags: Categories: Actions: E-mail | Kick it! | Permalink | Kommentare (0) | Comment RSS Ähnliche BeiträgeAVR Studio and the Arduino core libraryHowTo  Forum and there Arduino-Addin Project Announcing – Arduino Tutorial Refe…Arduino Libs Interactive Arduino BASIC interpreter: – An Interactive Arduino BASIC interpreter that runs on th…Arduino Tipps               http://www.kriwane... Über den Author.Net, Silverlight, Tools & more Search Tagscmdlet-list Filesystem Key NGEN PWM SnapShot SQL SQLServer SP2 Temperature-Measurement Tipps & Tricks USB Thermometer Windows Firewall Archiv2014Februar (13)Januar (30)2013Dezember (44)November (24)Oktober (19)September (36)August (26)Juli (14)Juni (35)Mai (40)April (26)März (19)Februar (29)Januar (27)2012Dezember (35)November (36)Oktober (44)September (45)August (50)Juli (28)Juni (22)Mai (32)April (28)März (18)Februar (11)Januar (39)2011Dezember (41)November (37)Oktober (39)September (74)August (22)Juli (42)Juni (34)Mai (35)April (89)März (92)Februar (42)Januar (34)2010Dezember (13) Weitere SeitenTool ÜbersichtUtilities Blogroll Al NyveldtRazorAnt Software acqui…RazorPDF SamplesTalking MonoTouch at Ph… Download OPML file RecentPostsDesign Patterns with ArduinoC# XML SerializerCOMArduino C++ optional arguments in functionsArduino with TPLink RouterIIS app pools, worker processes, app domainsOpenWRT ForumOpenWRT on Linksys RouterLinioRepRap [...]

  9. Haskins Arduino Fans | Flash | Arduiniana

    [...] Flash | Arduiniana. [...]

  10. Ipfone2 » RELÓGIO ROLANTE COM MATRIZ 5X7 E RTC DS1307

    [...] é que o comando PROGMEM é bem complicado e após pesquisar um pouco encontrei o seguinte link: Library to Ease Accessing Flash-based (PROGMEM) Data com uma biblioteca que facilita muito o uso do [...]

  11. Accessing Arduino Program Memory | WoodUino.ca

    [...] there are libraries of functions (Mikal Hart’s FLASH library, for one) to simplify the use of storing and reading data in the program memory, I like to [...]

Leave a Reply