Error while creating library

Hey.

Im trying to make a library that will calibrate my CTE7" touch screen.

When compiling my sketch with the library included I get these errors:
Arduino: 1.5.4 (Windows 7), Board: “Arduino Due (Programming Port)”

E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp: In member function ‘void Calibration::calib()’:
E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp:20: error: ‘myGLCD’ was not declared in this scope
E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp:36: error: ‘myTouch’ was not declared in this scope
E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp: In member function ‘void Calibration::draw()’:
E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp:191: error: ‘myGLCD’ was not declared in this scope
E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp:198: error: ‘myTouch’ was not declared in this scope
E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp: In member function ‘int Calibration::xfind()’:
E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp:254: error: ‘myTouch’ was not declared in this scope
E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp: In member function ‘int Calibration::yfind()’:
E:\Program Files (x86)\Arduino\libraries\Calibration\calibration.cpp:282: error: ‘myTouch’ was not declared in this scope

Obviously it has something to do with the use of UTFT and uTouch, specifically these lines in the main sketch:
UTFT myGLCD(CTE70);
UTouch myTouch(6,5,32,3,2);

My question is how can I access the variables myGLCD and myTouch in the library?

Thanks in advance :slight_smile:

Solved the error by placing:

UTFT myGLCD(CTE70); UTouch myTouch(6,5,32,3,2);

Inside each function.

Solved the error by placing:

UTFT myGLCD(CTE70); UTouch myTouch(6,5,32,3,2);

Inside each function.

That was one way (not the right one).

A better way would have been to add methods (setUTFT() and setUTouch()) that accepted arguments of type reference to UTFT and reference to UTouch, and called those methods from the sketch.

That way, there would be ONE instance of the classes, shared between the sketch and the library, instead of two separate objects, one known by the sketch and one known by the library.