2023-09-01 05:42 AM
I have implemented a keyboard and I am trying to keep the text that I have input in to the text areas when I switch between screens. I have read about MVP on the official touchGFX website and I have also watched some tutorials about it and I still don't quite understand how this "mechanisem" works and how to implement it.
Could someone please explain it in a simpler way to me?
2023-09-02 09:39 AM
Simple info model is as main code for your gui part. Model is run neverending, then here is best store relevant data. Presenter is bridge model <> view.
2023-09-07 06:49 AM - edited 2023-09-07 06:53 AM
Have you already read the TouchGFX documentation??? ;)
Model-View-Presenter Design Pattern | TouchGFX Documentation
If you want to google something about this architecture approach, you can find more info under the keyword MVVM.
View:
The view reflects the current screen. There is a separate view for each
screen, but at runtime of the program only the instance of the current screen exists.
currently displayed screen.
Presenter
The presenter is the link between model and view. It conveys data and states and
decides what is to be done with the information.
Each "screen" has its own presenter that is only instantiated when the corresponding screen is active.
Model
The model is always active. The model has a pointer to the active, instantiated presenter. This allows the model to call functions of the presenters under the same name. Each presenter can contain its own implementation of these functions, each with different activities. Your application runs in the model. Presenter and View is only for the HMI of your application.
Regards, Roger
2023-09-07 07:01 AM
The screens are dynamic. View and Presenter exist only as long as the screen is active. If you change the screen, all local data are gone. If you want to pass data, then you should pass it from the view via the presenter to the model and store it there. It is a bit nicer if you give your architecture a data management in an own task. Then you can pass your data via a message queue to the data layer. ;)
Regards, Roger