AWOL:
char extract[] = {0}; //this should work for any length of message I pass to it, right?
No. Pretty dangerous.
You know how long the FLASH_STRING is, so why not use that length?
...but they are all different lengths. ...my flash strings are anywhere from a couple words, to a few sentences.
Maybe I'm not making myself clear, let me explain again: My code has lots a text it sends to the LCD, which needs to be send 1 char at a time, with a little delay between each char, making a nice user experience with the LCD.
These messages can be anything from "Settings saved", to "a very long 3 sentence description of some function or other"
I was hoping to be able to save all this text in Flash, and have 1 function like the sendMessage function I made, so that anytime in my code I can just say sendMessage 'whatever the message is'.
Is my send message function the way to go, or is there a better way to do this? This is my whole sendMessage() function:
void sendMessage(char myMessage[]) {
i = 0; //reset display character counter
LCDclear();
while(1) { //loop
if(millis() - prevLCDtime > 100 ) { //continue every 10 ms
prevLCDtime = millis(); //update the time counter
Serial.print(myMessage[i]); //print the next letter to the display
i = i + 1; //increase counter
if (i == strlen(myMessage)) break; //when the counter i gets to the end of the message, break
}
}
delay(1000); //time to read the last line
LCDclear();
cups = 0; //reset the cups counter
prevKeypress = millis(); //reset last keypress time
Serial.flush(); //clear any keypresses during this message
}