I want to keep the 16 last events in my arduino controller, so I make a array like this
char* Eventos[16] ={"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"};
I put this values only to probe the code.
Then I make a routine to show this value all that's ok
This show this screen
All that's perfect but when some events occurs I call this routine
EventoNuevo("Protector"); // a text to show the event like light on light off or what else
And this routine make that
move all the previus values to keep the last one and put the time of the events
void EventoNuevo( char* QuePaso )
{
char TimeandEvent[128];
char* Hora = Reloj.Time();
/*his routine is to move the older values at the beginning and put in the last position the last event occurred
*/
for (int Bucle=1; Bucle<16; Bucle++)
{
Eventos[Bucle-1]=Eventos[Bucle];
}
strncpy(TimeandEvent, Reloj.Time(), sizeof(TimeandEvent));
strncat(TimeandEvent, QuePaso, (sizeof(TimeandEvent) - strlen(TimeandEvent)) );
Eventos[15]=TimeandEvent;
}
But when I see the screen al work fine in the first run, See that
But if another event ocurr I a call the routine at the same way see what happend.
This screen is for 4 events ,
I don't know why they replace all the same values with the last. Always put the same time, It seems like the routine don't move this values...
The problem is here
strncpy(TimeandEvent, Reloj.Time(), sizeof(TimeandEvent));
strncat(TimeandEvent, QuePaso, (sizeof(TimeandEvent) - strlen(TimeandEvent)) );
This code I find in google to put a text to the time of my Watch
If I don't use work , but I need the time to the event.
Can any body help me ?
I only need to make something like this
Eventos[15]=Reloj.Time() + QuePaso ; // both are text ...
But is not the correct code to C++