Skip to main content
KNara.2
Associate III
July 5, 2023
Solved

Communication from screen to backend

  • July 5, 2023
  • 2 replies
  • 1814 views

Hi,

I'm trying to send an event when a button is clicked.

I have added an interaction in Touchgfx designer to call a virtual function when the button is clicked.

In Screen1view.cpp I'm overwriting the virtual function

void SendDataOnButtonClicked()
{
presenter->SetMode();
}

in presenter.cpp

void Screen1Presenter::SetMode()
{
model->SendEvent();
}

In Model.cpp

void Model::SendEvent()
{
Send data to backend.
}
Is this the correct way of sending data to backend when button is clicked ?
 
Right now I'm stuck at view.cpp.
I dont know how to call presenter  from view.
Codes that I tried.
Method 1:
Screen1ViewBase::presenter->SetMode();
Method 2:
Method 2:
presenter->SetMode();
 
Both these codes are throwing compiler errors.
Can somebody please help and let me know the right way of accessing the function in presenter?
 

 

This topic has been closed for replies.
Best answer by JTP1

Hello. Method 2 is correct. There must some simple problem at hpp file maybe ... This 'void SendDataOnButtonClicked()' must be of course 'void Screen1View::SendDataOnButtonClicked()'.

What is the exact error ?

Here you can get simple example of MVP communication in both directions:

https://community.st.com/t5/stm32-mcu-products/toggle-button-off-after-a-specific-interval/m-p/569065#M217071

2 replies

JTP1Best answer
Graduate II
July 5, 2023

Hello. Method 2 is correct. There must some simple problem at hpp file maybe ... This 'void SendDataOnButtonClicked()' must be of course 'void Screen1View::SendDataOnButtonClicked()'.

What is the exact error ?

Here you can get simple example of MVP communication in both directions:

https://community.st.com/t5/stm32-mcu-products/toggle-button-off-after-a-specific-interval/m-p/569065#M217071

KNara.2
KNara.2Author
Associate III
July 5, 2023

Thank you so much @JTP1 .

Your solution helped.