TheNuclearDart / bringup

STM32F7 discovery board bringup
GNU Affero General Public License v3.0
0 stars 0 forks source link

Refactor driver classes to a proper singleton pattern #27

Open TheNuclearDart opened 7 months ago

TheNuclearDart commented 7 months ago

I currently have it set up so that many classes are meant to only have once instance (UART, LCD, etc), but they don't really follow a proper singleton pattern to prevent multiple instances of a class existing. They are prevented from reinitializing hardware by a static "initialized" boolean, but this isn't necessarily the correct way to do this, and I'm not sure if there'd be issues if multiple definitions of these classes occurred.

These classes should be refactored to better follow the singleton patttern, which shouldn't take too much effort to do, and would allow multiple interactors with something like the LCD - they'd get the instance of the singleton class and be able to interact with the LCD independently (if something like that were needed). I'm not sure if the current implementation allows for that.