cancel
Showing results for 
Search instead for 
Did you mean: 

About using variables in TouchGFX

PKunK.1
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
Alexandre RENOUX
Principal

Hello PKunk.1,

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

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

/Alexandre

View solution in original post

7 REPLIES 7
MM..1
Chief III

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...)

Alexandre RENOUX
Principal

Hello PKunk.1,

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

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

/Alexandre

Thank you for your advice.

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

Thank you

Hi,

Can you elaborate on what you are trying to do ?

/Romain

Model.hpp

typedrf struct TEST_DATA{

int A;

int B;

in C;

}TEST_DATA;

I would like to know if I use structure Test_Data in a place called A_Screen or if I need to return Test_Data from A_Screen as a model.