cancel
Showing results for 
Search instead for 
Did you mean: 

Why does it say member function not declared.

MikeP
Associate III

Hi,

I have been leaning how to use TouchGFX with the STM32F429I Discovery Board. I have managed to get buttons to work with hardware and for it to call Virtual function to toggle GPIO pins. however when i have tried to add a virtual function with a slider i get a build error that i haven't declared the member function in the class:

no 'void Screen1View::desiredValueChanged(int)' member function declared in class 'Screen1View'

Screen1view.hpp 

#ifndef SCREEN1_VIEW_HPP
#define SCREEN1_VIEW_HPP
 
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include <gui/screen1_screen/Screen1Presenter.hpp>
 
class Screen1View : public Screen1ViewBase
{
public:
    Screen1View();
    virtual ~Screen1View() {}
    virtual void setupScreen();
    virtual void tearDownScreen();
    virtual void LED_On();
    virtual void TLED_On();
    virtual void desiredValueChanged(int value);
    
protected:
};
 
#endif // SCREEN1_VIEW_HPP

Screen1View.cpp

#include <gui/screen1_screen/Screen1View.hpp>
#include "main.h"
#include "FreeRTOS.h"
#include "task.h"
 
Screen1View::Screen1View()
{
 
}
 
void Screen1View::setupScreen()
{
    Screen1ViewBase::setupScreen();
}
 
void Screen1View::tearDownScreen()
{
    Screen1ViewBase::tearDownScreen();
}
void Screen1View::LED_On()
{
	HAL_GPIO_WritePin(MIKELED_GPIO_Port,MIKELED_Pin,GPIO_PIN_SET);
	vTaskDelay(50);
	HAL_GPIO_WritePin(MIKELED_GPIO_Port,MIKELED_Pin,GPIO_PIN_RESET);
	vTaskDelay(50);
}
 
void Screen1View::TLED_On()
{
	HAL_GPIO_TogglePin(MIKELED_GPIO_Port,MIKELED_Pin);
}
void Screen1View::desiredValueChanged(int value)
{
	HAL_GPIO_WritePin(MIKELED_GPIO_Port,MIKELED_Pin,GPIO_PIN_SET);
}
 

Any help would be appreciated

i can upload my project if requested.

Kind Regards,

Mike

9 REPLIES 9
Martin KJELDSEN
Chief III

Hi Mike,

Please share your project. Thanks!

MikeP
Associate III

Hi,

please find attached

Martin KJELDSEN
Chief III

It's working fine here using gcc - Which compiler are you using?

Additional observation: It's generally not best practice to call your BSP (LED_On, etc) directly from your view. Let the view make a call to the presenter and then to the model or some other class which handles that kind of logic. Views should be clean (gui code only) and portable (#include "FreeRTOS.h" will cause a compiler error if you're building a simulator)

Best regards,

Martin

Martin KJELDSEN
Chief III

I can't really see why this wouldn't work on any compiler - Maybe you forgot to save your headerfile before compiling.

MikeP
Associate III

Hi Martin,

Thank you for your reply!

i have managed to resolve the issue by changing the default name of the slider1

I am using Atollic TrueStudio, which compiler do you recommended? I would have chosen to use Keil however there is a file size limitation on the free version for the F4 series.

Kind Regards,

Mike

Martin KJELDSEN
Chief III

Hi @MikeP​,

Glad you solved it.

Atollic should be fine. We do not recommend anything specifically - I was just curious because they may behave differently. Keil/IAR are probably among the most used compilers commercially.

MikeP
Associate III

Thank you for your help!

MikeP
Associate III

Hi @Martin KJELDSEN​ 

With the TouchGFX not loading the Simulator - Would you be able to expand on your additional observation mentioned earlier?

i understand that i cant have #include "FreeRTOS.h" ,#include "main.h" and #include "task.h" in my Screen1Vew.cpp but i'm unsure how i go about avoiding this. i could create separate threads and usexTaskNotifyWait and xTaskNotify but they require the "task.h"

Kind Regards,

Mike

Hi @MikeP​,

Sure. What i meant by that is that if you're running in a simulator environment, your compiler will fail because it does not know FreeRTOS. Generally, if you have target specific code and you still wish to be able to compile a simulator, you would sorround that target specific (maybe FreeRTOS task related) block with #ifndef SIMULATOR.

The second part is, it's better to have this in the model. The model is what's being ticked globally - If you receive a tick inside your concrete view then it would be for that view only. You want to define your RTOS task interoperability (e.g. Checking queues for new messages) inside the Model::tick() method which gets called regardless of application state.

So, all in all:

  • Surround target specific code with #ifndef SIMULATOR to be able to compile a simulator
  • Keep RTOS related code near the Model and not inside views.
  • Define your RTOS tasks seperate from the GUI Task and use message queues to exchange data with the GUITask (Check queues inside Model::tick()

Hope that helps!

Best regards,

Martin