Massage get Erased after Power cut or Reset

I am very much thankful to you for adding me.

Sir/ madam
I wont you to ask that in one of project on LED dot matrix using arduino and bluetooth , I have made that and it works very well .
But my question is that as we send the massage using bluetooth the last sent massage gets erased when ever there is power cut or reset of arduino.

I wont to now is there any solution on this that the last massage should be display not the initial massage i.e the last massage should be there on the display.
And can anybody help me in this if there is any solution and if there is any kind of command or library to be used please tell me where i have to use it in the code.

Following i have attached the code

Thanking you

Arduino Code.txt (29 KB)

That's a large code; I did not look at it.

You can save messages in eeprom when you receive them and after a reboot read the message from eeprom. Not that an eeprom cell has a limited lifespan (100,000 writes); I don't know how often new messages are refreshed.

You have 1k eeprom on e.g. a 328P based board; if the message is longer, you will have to look at alternatives (external fram/eeprom modules or SD card).

It really doesn't make sense to store the entire alphabet in PROGMEM as strings. This code should do the same as your code... (untested)

//We start our setup
void setup()
{
 
 Serial.begin(9600);     //Start the serial comunication for the bluetooth module
 for (int x=0; x<numDevices; x++)
 {
   lc.shutdown(x,false);       //The MAX72XX is in power-saving mode on startup
   lc.setIntensity(x,8);       // Set the brightness to default value
   lc.clearDisplay(x);         // and clear the display
   }
   
   message.reserve(100);	// max string size
   strcpy_P(message.c_str(), (char *)pgm_read_word(initialText));      
   
}

//We start the infinite loop 
void loop(){ 
    //We start scrooling the initial text

 while(Serial.available() > 0) // Don't read unless you receive something new
   {
     message = Serial.readString(); //Store the bluetooth received text
   }
   scrollMessage(message.c_str());
}
// rest of fonts info the same

That program is a really good example which could be used to teach code optimisation!
Almost every function or code block has glaring inefficiencies - both in stye, performance and readabiity

All those alpha characters could be generated dynamically, all the if() blocks could be condensed to a couple of lines in total etc...

blh64:
It really doesn't make sense to store the entire alphabet in PROGMEM as strings. This code should do the same as your code... (untested)

//We start our setup

void setup()
{

Serial.begin(9600);    //Start the serial comunication for the bluetooth module
for (int x=0; x<numDevices; x++)
{
  lc.shutdown(x,false);      //The MAX72XX is in power-saving mode on startup
  lc.setIntensity(x,8);      // Set the brightness to default value
  lc.clearDisplay(x);        // and clear the display
  }
 
  message.reserve(100); // max string size
  strcpy_P(message.c_str(), (char *)pgm_read_word(initialText));     
 
}

//We start the infinite loop
void loop(){
    //We start scrooling the initial text

while(Serial.available() > 0) // Don't read unless you receive something new
  {
    message = Serial.readString(); //Store the bluetooth received text
  }
  scrollMessage(message.c_str());
}
// rest of fonts info the same

But i am getting the error massage sir following are the errors can you help me in that
warning: invalid conversion from 'const char*' to 'char*' [-fpermissive]

strcpy_P(message.c_str(), (char )pgm_read_word(initialText));
note: initializing argument 1 of 'char
strcpy_P(char*, const char*)'

extern char *strcpy_P(char *, const char *);

Vtronics:
But i am getting the error massage sir following are the errors can you help me in that
warning: invalid conversion from 'const char*' to 'char*' [-fpermissive]

strcpy_P(message.c_str(), (char )pgm_read_word(initialText));
note: initializing argument 1 of 'char
strcpy_P(char*, const char*)'

extern char *strcpy_P(char *, const char *);

Those are warnings, not errors. There is a difference. They also come with a lot more information, such as line#, filename, etc. I have no idea where these errors came from since you compiled the code.

You can always cast those values (wherever they are) from const char * to char * to quite the warnings.