Using the UTFT library in derived classes

I am using the UTFT library, which you can find here:

http://www.henningkarlsen.com/electronics/library.php?id=51

I have a base class called MinMaxScreen, which draws up some general screen for setting the required minimum and maximum values. Then I have a derived class Called TempScreen, it too draws the min and max required levels. However here I would like to draw an extra calibrate button. The problem is that when setting and drawing the buttons with this library I cannot share the instance of the UTFT class with the derived class. I have to set the UTFT class always in the .cpp file like this:

UTFT MM_myGLCD(ITDB32S, 38,39,40,41); UTouch MM_myTouch(6,5,4,3,2); UTFT_Buttons MM_myButtons(&MM_myGLCD, &MM_myTouch);

Outside of the class, just sitting there as a global for that file. How can I share this instance with many classes?

Thanks.

How can I share this instance with many classes?

My crystal ball says to fix line 56 of TempScreen.h. Of course, since it can't see your code, it could be wrong. Since we can't see it, either, I guess you are stuck.

I can upload the code tomorrow, don't really see why you need it though??

Basically how can I use those static variables in derived classes?

UTFT MM_myGLCD(ITDB32S, 38,39,40,41); UTouch MM_myTouch(6,5,4,3,2); UTFT_Buttons MM_myButtons(&MM_myGLCD, &MM_myTouch);

Generally, can be any code and any static I guess.

Basically how can I use those static variables in derived classes?

There is no simple answer. It depends on where the variables are defined. Like it, or not, you need to post your code.

They're defined, at the top of the base .cpp file outside of the class. So just sitting there at the top of the file.

UTFT MM_myGLCD(ITDB32S, 38,39,40,41);
UTouch MM_myTouch(6,5,4,3,2);
UTFT_Buttons  MM_myButtons(&MM_myGLCD, &MM_myTouch);

I use them in the base class to draw up some stuff..

MM_myGLCD.printNumI(aMax, 100, 81, 3);

Now I have a derived class which wants to add some extra things to the UI.

MM_myGLCD.printNumI(value, 100, 100, 3);

That will not work. I must add to the top of the derived .cpp file

UTFT MM_myDerivedGLCD(ITDB32S, 38,39,40,41);
UTouch MM_myDerivedTouch(6,5,4,3,2);
UTFT_Buttons  MM_myDerivedButtons(&MM_myGLCD, &MM_myTouch);

And draw everything again, you cannot have two of those classes on one screen. Also I cannot make them protected or part of the class in any way. Or I don't know how to.

Any ideas?

Thanks.

They're defined, at the top of the base .cpp file outside of the class.

Then, they aren't static variables that belong to the class. They are global variables.

Any ideas?

You would need to use :

extern UTFT;
extern UTouch MM_myTouch;
extern UTFT_Buttons  MM_myButtons;

in other files that want to use them.