cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning external data structure variables in TouchGFX

Mric.1
Associate II

Hello community

I face the following problem

I have a global data structure which contains several member variables, I use this data structure to handle all my global variables needs across my project.

Such datatype is delcared in "globals.h", and a variable using this datatype is declared in "globals.c" and exported as extern always in globals.h.

I want to assign some of these variables when TouchGFX interactions happen (like moving a slider or pressing a button) in my TouchGFX "view"

The problem is, if I include globals.h in my "view.cpp", then the TouchGFX simulator won't build as it cannot find "globals.h".

for sake of simplicity

globals.h

typedef _myType{
int sliderValue;
}myType;
 
extern myType myGlobalVar;

globals.c

#include "globals.h"
 
myType myGlobalVar;

How should I access my global variables then without breaking the interface simulator?

Matteo

1 ACCEPTED SOLUTION

Accepted Solutions

Hello Matteo,

Strange, space should work.

You can also write as follows :

folder/folder/file1.c \
folder/folder/file2.c \
folder/folder/file3.c

Make sure the path to your file is correct.

/Alexandre

View solution in original post

4 REPLIES 4
Alexandre RENOUX
Principal

Hello Matteo,

globals.h is not known by the simulator so it cannot compile it.

To add c/h files to a simulator project, go to <your project>/TouchGFX/simulator/gcc/ and edit the Makefile

Add your globals.h/.c file path as follows

ADDITIONAL_SOURCES := <path_to_globals.c>
ADDITIONAL_INCLUDE_PATHS := <path_to_globals.h>

/Alexandre

Thank you Alexandre, can you also tell me what would be the synthax to add multiple include paths and source files? I tried to separate them with white spaces or -I but it does not work 😅

Hello Matteo,

Strange, space should work.

You can also write as follows :

folder/folder/file1.c \
folder/folder/file2.c \
folder/folder/file3.c

Make sure the path to your file is correct.

/Alexandre

Thank you for your support you have been very kind! my problem is that I was not escaping the ":" char correctly now I use

"../" to address the makefile to the project folder when adding sources

Matteo