2019-04-24 02:31 AM
Hello,
I'm trying to generate some sample data in the model.
My problem is, it is a little bit tricky for a beginner - so I want to ask if there is any guide in text written, would be awesome, because videos are very quick.
=======
At the moment I have added a "Circle Process" in TouchGFX and a button which calls a virtual function.
Now what are the exact steps to iterate the value of the circle process (by tick - not by pressing the button :) )?
Some sample code would also be great, like:
1) Edit ScreenView.hpp
public:
...
virtual void setvalue();
...
2) Edit ScreenView.cpp
...
void MainView::setvalue()
{
presenter->updatevalue(circleProgress1.getValue());
}
...
3) Edit ScreenPresenter.hpp
...
public:
void updatevalue(int value);
...
4) Edit ScreenPresenter.cpp
5) Edit Model.hpp
6) Edit Model.cpp
7) Edit ModelListener.hpp
I have seen the PoolDemo, and I'm trying to use this code, but it would be much easier seeing the code for each file in one text, for me.
thank you for your help! :)
best regards,
max
Solved! Go to Solution.
2019-04-30 01:41 AM
Hi @MGeyer,
So here are the steps to achieve what you want:
1) Receive a value through model::tick() - Or generate value by incrementing a counter.
2) Call a method on the modelListener interface to let the active presenter know of a new value
3) Implement the interface method in the presenter
4) Pass the value to the active view (presenter has a view reference)
5) View sets the new value on circle progress using the same code that you used from your button handler
Let me know if that's not clear or if you need further help.
Best regards,
Martin
2019-04-29 01:41 AM
Hi @MGeyer,
I think we've tried to focus on training videos more because they are less maintenance and often more appreciated, but not always. Sorry you're having trouble finding what you need! Did you check out the getting started-tutorials here? https://touchgfx.zendesk.com/hc/en-us/categories/200529271
Just to understand you correctly, you simply want to send some test-data from the model to the active view? Let me know if reading those guides do not help you and we can go through it together.
Thanks!
Best regards,
Martin
2019-04-29 02:37 AM
@Martin KJELDSEN
thank you for your answer - I know it is really noobie after seeing these videos --> it was about all files which have to be edited and I thought you got the code so strg+c + strg+v is everything to do.
I will write the code down and post it - was a comfort question =)
=======
PoolDemoExample - link Method 1
Code here:
Source Files\gui\main_screen\MainView.cpp
...
void MainView::updatePoolLight()
{
//report change to presenter
presenter->setPoolLight(onOffButton.getState());
}
Source Files\gui\main_screen\MainPresenter.cpp
void MainPresenter::setPoolLight(bool state)
{
model->userSetPoolLight(state);
}
Source Files\gui\model\model.cpp
...
void Model::tick()
{
#ifndef SIMULATOR
//poll blue push button
static uint32_t old = 0;
uint32_t state = BSP_PB_GetState(BUTTON_KEY);
if (state != old)
{
old = state;
if (state == 0) //released
{
poolTemperature++;
if (poolTemperature>28) poolTemperature = 28;
modelListener->poolTemperatureChanged();
}
}
#endif
}
void Model::userSetPoolLight(bool state)
{
poolLightState = state;
updatePoolLight();
}
void Model::userSetTemperature(uint32_t temp)
{
poolTemperature = temp;
}
void Model::updatePoolLight()
{
#ifndef SIMULATOR
if (poolLightState)
{
BSP_LED_On(LED_GREEN);
}
else
{
BSP_LED_Off(LED_GREEN);
}
#endif
}
Source Files\gui\pooltemp_screen\PoolTempView.cpp
...
void PoolTempView::setPoolTemp(uint32_t temp)
{
//update slider and temperature text
slider.setValue(temp);
Unicode::snprintf(tempTextBuffer, 3, "%d", temp);
tempText.invalidate();
}
void PoolTempView::sliderMoved(int value)
{
//report to presenter and update text
presenter->userSetTemperature(value);
Unicode::snprintf(tempTextBuffer, 3, "%d", value);
tempText.invalidate();
}
Source Files\gui\pooltemp_screen\PoolTempPresenter.cpp
...
void PoolTempPresenter::activate()
{
//Set view to match pool temperature in Model
view.setPoolTemp(model->getPoolTemperature());
}
...
void PoolTempPresenter::poolTemperatureChanged()
{
//forward new temperature to view
view.setPoolTemp(model->getPoolTemperature());
}
:flexed_biceps: TouchGFX *rocks*
2019-04-30 01:41 AM
Hi @MGeyer,
So here are the steps to achieve what you want:
1) Receive a value through model::tick() - Or generate value by incrementing a counter.
2) Call a method on the modelListener interface to let the active presenter know of a new value
3) Implement the interface method in the presenter
4) Pass the value to the active view (presenter has a view reference)
5) View sets the new value on circle progress using the same code that you used from your button handler
Let me know if that's not clear or if you need further help.
Best regards,
Martin