Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By PinGuy
#83900 Hi all, I'm running out of RAM so I need to move my strings to flash to free up some.
This is what I'm trying:

The string:
Code: Select allconst char Options[] PROGMEM = "<div><input type='radio' id='{i}' name='{n}' value='1' {r1}><label for='nu1'><span><span></span></span>Option 1</label><input type='radio' id='{i}' name='{n}' value='2' {r2}><label for='nu1'><span><span></span></span>Option 2</label><input type='radio' id='{i}' name='{n}' value='3' {r3}><label for='nu1'><span><span></span></span>Option 3</label></div>";


And I need to call this function with that string:

Code: Select allAddParameter(const char *id, const char *custom, uint8_t defaultValue);


If I do:

Code: Select allAddParameter RadioOptions("nu1", FPSTR(Options), 1);


The compiler complains:
no matching function for call to 'AddParameter::AddParameter(const char [4], const __FlashStringHelper*, int)'

So how can I properly move that long string to flash and call the function with the string? This is giving me a headache, tried many things but can't make the compiler happy :(
Last edited by PinGuy on Mon Sep 23, 2019 8:31 pm, edited 1 time in total.
User avatar
By PinGuy
#83901 BTW, this is the AddParameter function:

Code: Select allAddParameter::AddParameter(const char *id, const char *custom, uint8_t defaultValue) {
  _id = id;
  _customHTML = custom;
  _intvalue = defaultValue;
}


I tried modifying the constructor to:

Code: Select allAddParameter::AddParameter(const char *id, const __FlashStringHelper*, uint8_t defaultValue)

And
Code: Select all_customHTML = __FlashStringHelper;


But the compiler is not accepting that either :x