Skip to main content
PKunK.1
Associate III
Solved

About using variables in TouchGFX

folder is model ,main_page_screen, pw_touchgfxactivev_screen.

​

I want to use the variables A declared in the model in main_screen and pw_page_screen. I don't know how to declare variables and how to use them.

​

For example, variable A is declared in model.cpp.

​

In pw_touchgfxactive_screen.cpp, enter 1 for variable A.

​

I want to use variable A in main_page_screen.cpp.

​

Thank you for telling me how to pass the variable A value entered in pw_touchgfxactive to main_page_screen.cpp.

​

0693W000006I3BmQAK.png

This topic has been closed for replies.
Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II

Hello PKunk.1,

Completing the following tutorial should give you all the answers you need

https://support.touchgfx.com/docs/tutorials/tutorial-03

/Alexandre

7 replies

MM..1
Super User

Or use extern C in C++ : example

in main.c

int variableA; or volatile

in globals.h

extern int variableA;

in model.hpp include globals.h use extern C here

then when i remmember can use variableA on any place...

But you need choice what you need C++ setters getters private public ... or C or mix, and too important is who and where will change variableA.(gui,irq,spi,dma...)

PKunK.1
PKunK.1Author
Associate III

Thank you

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II

Hello PKunk.1,

Completing the following tutorial should give you all the answers you need

https://support.touchgfx.com/docs/tutorials/tutorial-03

/Alexandre

PKunK.1
PKunK.1Author
Associate III

Thank you for your advice.

By the way, in the case of Adata [7], struct Adata, can you tell me how it is delivered?

Romain DIELEMAN
ST Employee

Hi,

Can you elaborate on what you are trying to do ?

/Romain