Since we delivered the new weather 🌤️ feature in #InfiniTime, some users noticed that their #PineTime would crash after a few hours.
We figured that those crashes were caused by a memory overflow : InfiniTime stores too many weather events in memory!
https://github.com/InfiniTimeOrg/InfiniTime/pull/1822#issuecomment-1712842416
Let's fix this!
I wanted to investigate this issue: #1788 I found some things that could be refactored, and also some issues with the current implementation: Already expired events are added to the timeline and d...
But first, let's enable C++17, we'll need a few functionalities from newer C++ (like "if constexpr")!
Coming from a company that is stuck (for various reasons) in C++11, this is probably one of the most satisfying commit ever!
Then let's refactor and improve the weather service : create weather events in dedicated functions and write a #template function (and multiple specializations) to handle the QCBOR deserialization.
Now, since #InfiniTime actually uses only temperature, cloud and precipitation information, let's disable all the other weather events. This way, #InfiniTime won't spend time and memory processing useless data.
Since we'll probably want to use those info later on, I don't want to delete the code that handles those events. I think this is a good opportunity to disable the code using "if constexpr".
Even if companion apps send multiple "versions" of the same event (ex : temperature for the next 6h and 24h), #InfiniTime currently use only one of them. So... there's no need to store multiple version. The next step consists in choosing which event to add in the timeline, and to remove events that are overwritten by newer ones.
And finally, fix PineTimeStyle (PTS) so that it refreshes the weather info even if it didn't receive any precipitation info (and assume 0 precipitation in this case).
Ok! Now, time to push, create a PR and wait for the reviews !
https://github.com/InfiniTimeOrg/InfiniTime/pull/1860
This branch implements the suggestion I did in this comment in #1822: Disable all weather events that are not processed by InfiniTime Ensure that a single version of each event is stored in memory...
Ooh and this PR frees 1596B in flash memory! Nice!