This is my public brainstorming repo for an idea of MVP architecture for Firmware. If anyone has ideas they'd like to share, please post an Issue!
I've been struggling over the past couple years trying to find a nice, clean, modular architecture for firmware and so far I haven't found anything I've liked. After playing around with writing a mobile app in Flutter, I discovered the MVP architectural model (Model View Presenter) which is diagrammed in the chart below:
borrowed from: StackOverflow
I've really enjoyed this pattern for mobile, so I'm going to attempt to map it to firmware in this repo, eventually providing example projects and guides (if it ends up being something I want to use). If this works, I believe it will provide a simple architecture that is highly testable (via unit and integration testing) and very clean.
Model Our model will handle things like storing data to flash, settings, GPIO configuration, etc... This code should really be constant even if our hardware changes.
Presenter Our presenter will handle any necessary logic between the Model and View. It will accept events from the view, tell the model when and what data to update, the provide any updates to the view that are necessary. This code should remain constant even if hour hardware changes.
View Our view is closely related to the hardware itself, so it may change if our hardware changes. The view will take actions (from outside the device) such as user input/buttons/sensors/etc...
This isn't the best example because it kind of looks like data is only flowing from View to Presenter to Model, when in reality, the communication is 2 way between both the View and Presenter and the Model and Presenter. Nonetheless, it's making for a decent starting point.