cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual Function make wrong call during button press.

Hiram Hyman
Associate III

Hi everyone,

I've setup a project in TouchGFX4.18.1 and STM32H747i Disco, which consist of 4-5 screens. One screen is for motor control. In this motor control screen 3 buttons are used (low, medium, high) for changing the PWM. Simple but, the virtual function at the model (MVP) is calling the wrong Function.

The funny thing is, the order that a function is placed in the .HPP yields that the function to be called in model and it's not the correct function. I've used breakpoints throughout MVP, and all was validated as making the incorrect/correct call. 

 

virtual void PWM_33(); (if PWM_33 is placed on the bottom, PWM_66 would be called for every button.)

virtual void PWM_66(); (same as the above)

virtual void PWM_75(); (same as the above)

 

This is the third time I've made the to change to the buttons that only yield the same results. Otherwise, each function call reverts to the order in .HPP. This area (stepping from VIEW, Presenter to Model not possible) seems to contain a possible reason for my virtual function call issue.

 Do any of you knowledgeable people have an Idea of what I've done wrong?

 What's taking place between the presenter to model?

//***************************************

Reference:

 

#include <gui/model/Model.hpp>
#include <gui/model/ModelListener.hpp>
#include "cmsis_os2.h" //added for osDelay();
#include "string.h"

#define SRAM3 0x38000000

//DEFAULT IS 33% DUTY CYCLE

int PwmCount = 0;

Model::Model() : modelListener(0)
{
}
void Model::tick()
{
}

//***************************************************************************************

//FROM THE DISPLAY(*.VIEW) WE COME TO THIS HERE (M7->M4). MY THINKING IS, MAKE THE SELECTION

// ON THE SCREEN FOR PWM, AND THEN SAVE TO SRAM. FROM SRAM WE'LL OPEN WITH M4 AND SEND

//VIA UART WIRELESSLY TO THE MTR CONTROLLER ON THE ROBOT.

//***************************************************************************************

void Model::PWM_33()
{
osDelay(3);
}

void Model::PWM_66()
{
osDelay(3);
}

void Model::PWM_75()
{
osDelay(3);
}

 

//***************************************
#ifndef MODEL_HPP
#define MODEL_HPP
class ModelListener;

class Model
{

public:

Model();

void bind(ModelListener* listener)
{
modelListener = listener;
}

void tick();
virtual void PWM_33();
virtual void PWM_66();
virtual void PWM_75();
protected:
ModelListener* modelListener;
};

#endif // MODEL_HPP

 

11 REPLIES 11

Hello @Hiram Hyman ,

 

Can you please share this project?
I would like to help you on that.
There is no reason for this behavior if you followed the steps I mentioned in my first post.
With the project, I could be able to track down the issue.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
GaetanGodart
ST Employee

Hello @Hiram Hyman 

 

Have you been able to move forward with your project?

Without answer from you we will close this thread.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)