fairly new to the party, also not sure if I should be posting this here or in an R Pi forum, but here goes...
Using Arduino MBED on a Raspberry Pi Pico, and struggling with strings.... Essentially I have a vector of std::string, used for storing lines of text, which are displayed on an LCD screen for a data logger type of situation.
My problem is whenever I pass a new log event to my function, the value of the text shows is always the same as the first log entry.
I am sure it's due to how I am (probably wrongly) using strings, or not using pointers... I am not sure and hoping if someone can point out the error of my ways, I will be back on track...
But now your (poorly-indented) code doesn't do anything with the vLogs vector except insert at the beginning and pop out the back. No attempt to print the log entries ... which I thought was the original problem.
Please pare this down to the bare minimum code that actually demonstrates the problem. Don't comment out unused #includes and functions, that just makes clutter. Delete them. I don't have your hardware, so substitute for or simulate the (unnecessary) uptime library functions.
OK - in your example, you are declaring the elements in the vector, it all works fine.
My problem, I think, is in how I am passing the string to the function which puts the string into the vector, (void appendLog(std::string eventLog) {})
I've been racking my brains but struggling to get my head around string functions, but that must be where the problem lies.
If it helps, I identified today that my serial listener was actually passing an empty string... I fixed that, and now the vector elements are not identical, but they have the first part of the string overwritten by the latest element added:
For example if the serial function receives 3 lines:
This is the first string!
And the 2nd.
3rd.
Then my vector looks like this:
This is the first string!
And the 2nd.first string!
3rd. is the first string!
OK - whilst I enjoyed learning about strings / char in c++, I was totally barking up the wrong tree.
The problem was not in my handling of strings, rather me not realising that my TFT display did not clear the pixels in the background of a new line of displayed text.
Problems solved by padding out my string with blank space before writing to the display.