Skip to main content
PKunK.1
Associate III
Jan 8, 2021 5:03 PM UTC
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
Jan 11, 2021 3:45 AM UTC

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

zzzzz
Senior
Jan 8, 2021 6:00 PM UTC
MM..1
Super User
Jan 8, 2021 6:23 PM UTC

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
Jan 12, 2021 6:57 AM UTC

Thank you

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II
Jan 11, 2021 3:45 AM UTC

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
Jan 12, 2021 6:56 AM UTC

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
Jan 12, 2021 8:57 AM UTC

Hi,

Can you elaborate on what you are trying to do ?

/Romain