InfiniTimeOrg / InfiniTime

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

MultiPurposeButton: Add new widget #1660

Closed Riksu9000 closed 7 months ago

Riksu9000 commented 1 year ago

New widget for potentially improving readability on code, where a button is used for many purposes.

Please let me know if this improves the readability of code. Otherwise there's probably no reason to add this. The index could use an enum, but the name of the variable can also be helpful, for example in btnStopLap Stop is the first word, and it is index 0.

Use MultiPurposeButton in StopWatch.

github-actions[bot] commented 1 year ago
Build size and comparison to main: Section Size Difference
text 406668B -32B
data 940B 0B
bss 53568B 0B
FintasticMan commented 1 year ago

I personally don't think this implementation makes the code easier to read, mostly due to the magic numbers used as IDs for the buttons. Perhaps if you make an enum for the buttons, so that it becomes btnPlayPause.SetActiveButton(PlayButton);, it might make it a worthwhile change IMO.