InfiniTimeOrg / InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS
GNU General Public License v3.0
2.75k stars 941 forks source link

I made a Life Point counter app for Magic The Gathering #1406

Open Derek52 opened 2 years ago

Derek52 commented 2 years ago

I couldn't figure out how to get the simulator working, so I don't have screenshots to share. But, as referenced in #1382 I made an MTG life counter app. I also implemented a new 2 digit counter widget that could be useful. It has 2 plus buttons on the top, and 2 minus buttons on the bottom. These add and subtract either 10 or 1 from the total. The number displayed changes color as your life goes down, as a warning(i.e. it goes red when it's really low).

Holding the top left plus button will reset the counter to '40' the default starting value I gave it, for Commander games. I probably should refactor the app to have a dedicated reset button.

One thing I could use some feedback on is, how to make the app persist my life points upon closing the app. Currently, I just made the value of the counter, a static variable, which was advice given to me in the matrix dev room, I'm not sure if this was the best way to do that though. The relevant line of code is here.

minacode commented 2 years ago

One thing I could use some feedback on is, how to make the app persist my life points upon closing the app.

You can take a look at src/components/settings/Settings.cpp to see how the persistence is implemented. Then you can write and load the value to the flash at closing or loading the app. Also see the two PRs for alarm persistence.