cancel
Showing results for 
Search instead for 
Did you mean: 

Designer Generated Code: function not declared in the scope

cusp
Associate II

I am currently trying to follow the Designer Generated Code tutorial with `button1Clicked`. However, whenever I try to Run Target it says the function is not declared in the scope. I declared it in the MyView class as a public virtual function. Not sure if I am just missing something simple. If you think it is more complicated and I should add all the details for the situation, feel free to let me know. I am just thinking it is something very simple.

Edit:

Thank you for your reply Alexandre, I can definitely provide more information:

The board I am using is the STM32F469 Discovery Kit.

I am trying to implement a function called `user_button_clicked()` that is called when `button1` is clicked. Necessary code is below.

Include file startup_screenView.hpp:

#ifndef STARTUP_SCREENVIEW_HPP
#define STARTUP_SCREENVIEW_HPP
 
#include <gui_generated/startup_screen_screen/startup_screenViewBase.hpp>
#include <gui/startup_screen_screen/startup_screenPresenter.hpp>
 
class startup_screenView : public startup_screenViewBase
{
public:
    startup_screenView();
    virtual ~startup_screenView() {}
	virtual void user_button_clicked();
    virtual void setupScreen();
    virtual void tearDownScreen();
	
protected:
};
 
#endif // STARTUP_SCREENVIEW_HPP

Source file startup_screenView.cpp:

#include <gui/startup_screen_screen/startup_screenView.hpp>
#include <touchgfx/Color.hpp>
 
startup_screenView::startup_screenView()
{
 
}
 
void startup_screenView::setupScreen()
{
    startup_screenViewBase::setupScreen();
}
 
void startup_screenView::tearDownScreen()
{
    startup_screenViewBase::tearDownScreen();
}
 
void startup_screenView::user_button_clicked()
{
	//do this when user button pushed on dev board
	box2.setColor(Color::getColorFrom24BitRGB(255, 0, 0));
	box2.invalidate();
}

Uneditable generated source file startup_screenViewBase.cpp:

/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/startup_screen_screen/startup_screenViewBase.hpp>
#include <touchgfx/Color.hpp>
#include "BitmapDatabase.hpp"
#include <texts/TextKeysAndLanguages.hpp>
 
startup_screenViewBase::startup_screenViewBase() :
    buttonCallback(this, &startup_screenViewBase::buttonCallbackHandler)
{
 
    box1.setPosition(0, 0, 800, 480);
    box1.setColor(touchgfx::Color::getColorFrom24BitRGB(54, 40, 242));
 
    buttonWithLabel1.setXY(315, 210);
    buttonWithLabel1.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_ID), touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_PRESSED_ID));
    buttonWithLabel1.setLabelText(touchgfx::TypedText(T_SINGLEUSEID1));
    buttonWithLabel1.setLabelColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    buttonWithLabel1.setLabelColorPressed(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    buttonWithLabel1.setAction(buttonCallback);
 
    box2.setPosition(141, 112, 50, 50);
    box2.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
 
    add(box1);
    add(buttonWithLabel1);
    add(box2);
}
 
void startup_screenViewBase::setupScreen()
{
 
}
 
void startup_screenViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
    if (&src == &buttonWithLabel1)
    {
        //Interaction1
        //When buttonWithLabel1 clicked execute C++ code
        //Execute C++ code
        user_button_clicked();
    }
}

Build Log:

    Compile
        make -f target/gcc/Makefile -j10
        Converting images
        Compiling gui/src/startup_screen_screen/startup_screenView.cpp
        Compiling generated/gui_generated/src/startup_screen_screen/startup_screenViewBase.cpp
        generated/gui_generated/src/startup_screen_screen/startup_screenViewBase.cpp: In member function 'void startup_screenViewBase::buttonCallbackHandler(const touchgfx::AbstractButton&)':
        generated/gui_generated/src/startup_screen_screen/startup_screenViewBase.cpp:43:9: error: 'user_button_clicked' was not declared in this scope
                 user_button_clicked();
                 ^~~~~~~~~~~~~~~~~~~
        target/gcc/Makefile:337: recipe for target 'build/ST/STM32469IDISCO/generated/gui_generated/src/startup_screen_screen/startup_screenViewBase.o' failed
        make[2]: *** [build/ST/STM32469IDISCO/generated/gui_generated/src/startup_screen_screen/startup_screenViewBase.o] Error 1
        make[2]: *** Waiting for unfinished jobs....
        make[1]: *** [generate_assets] Error 2
        target/gcc/Makefile:304: recipe for target 'generate_assets' failed
        target/gcc/Makefile:46: recipe for target 'all' failed
        make: *** [all] Error 2
        Failed
    Failed

End Goal: call a function created by me (user) from an event not associated with the touch screen interactions. For example, change the color of the screen or change the screen when the user button on the dev board is clicked. This is what I started with the tutorial Designer Generated Code.

I have not simulated the project like this because I did not make the makefile changes to the simulation makefile; I will do that in the meantime. If you need anymore information, feel free to let me know. Thank you for your help!

13 REPLIES 13
scottSD
Lead

I am not even able to get the virtual function handleTickEvent() compile.

JohanAstrup
ST Employee

Hello @scottSD.

I know your question is somewhat related, but generally you should create a new post instead of replying with questions to other threads. This will ensure better visibility and increase your chance for answers.

It sounds like there is a fundamental issue with your setup. Can you try to run the simulator in the simple test project, I have attached?

Best regards,
Johan

I appreciate the reply. You could be correct. I did try to run the project in the TouchGFX similar. However it is not compatible with the version I am currently running is 4.24.1. I will try to get some time to install that. 

One thing I noticed is there is no core directory in the project you sent?

 

I think what I am experiencing on my project are issues with how the project is displayed in the IDE project explorer compared to it is in the file system. Maybe this changed in recent versions of the IDE? It seems as though some base files aren't in scope with the screen files, causing compiling/linking errors.

 

Best regards,

JohanAstrup
ST Employee

Hello @scottSD.

Since this project is very simple, you can downgrade the TouchGFX version by opening the HandleTickEvent.touchgfx file in a text editor and manually setting the version to 4.24.1 at the bottom of the file.

There is no core directory because this is only a simulator project.

Which IDE are you using, and are you using STM32CubeMX?
In the .touchgfx file, you can see the selected toolchain (it is also visible in the .touchgfx.part file if you have used STM32CubeMX). The toolchain specified here should match the one you are actually using. TouchGFX uses this information to determine which project file to update when you generate code in TouchGFX Designer.

Best regards,
Johan