Skip to main content
Mric.1
Associate II
September 28, 2021
Solved

Assigning external data structure variables in TouchGFX

  • September 28, 2021
  • 4 replies
  • 3053 views

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

This topic has been closed for replies.
Best answer by Alexandre RENOUX

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

4 replies

Alexandre RENOUX
Visitor II
September 29, 2021

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

Mric.1
Mric.1Author
Associate II
September 29, 2021

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 :grinning_face_with_sweat:

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II
September 29, 2021

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