Arduino with the MI0283QT9 and the ADS7846

Hello all,

I am building a simple menu on my LCD with the MI0283QT9 (LCD controller library) and the ADS7846 (Touch controller library). I am able to build the menu. But now I am adding the touch controllers. The problem is that my code doesn’t give a good return for my X and Y. They are giving me strange numbers between the 0 and the 1000. I don’t know where they came from. You can see how it all works in my code below.

// Do not remove the include below
#include "Arduino_BobCopter_Menu.h"

#include "MI0283QT9.h"
#include "ADS7846.h"

#define COLOR_FINE_RED RGB(255, 0, 75)
#define COLOR_FINE_GREEN RGB(100, 200, 0)
#define COLOR_FINE_ORANGE RGB(255,165,0)
#define COLOR_FINE_BLUE RGB(100,100,140)

MI0283QT9* LCD = new MI0283QT9();
ADS7846* TP = new ADS7846();

/* -- Variable declarations */
int MENUCASENUMBER;

/* -- Function declarations */
void drawMenuButtons(int MENUCASE);
void buildMainMenu();
void startNewGame();
void buildOptionsMenu();
void showHighscores();

/*
 * Main function of the program
 */
int main(){
	LCD->init(2);
	LCD->led(100);
	TP->init();
	LCD->clear(COLOR_BLACK);
	MENUCASENUMBER = 0;
	//drawMenuButtons(MENUCASENUMBER);

	for(;;)
	{
		TP->service();
		LCD->drawText(10, 10, TP->getX(), 1, COLOR_WHITE, COLOR_BLACK);
		LCD->drawText(10, 25, TP->getY(), 1, COLOR_WHITE, COLOR_BLACK);
		LCD->drawText(10, 40, TP->getPressure(), 1, COLOR_WHITE, COLOR_BLACK);
	}
	return 0;
}

/*
 * Drawing controller for the menu and the menu items
 */
void drawMenuButtons(int MENUCASE) {
	LCD->clear(COLOR_FINE_BLUE);
	switch( MENUCASE )
	{
		case 0:
			buildMainMenu();
		break;
		case 1:
			startNewGame();
		break;
		case 2:
			buildOptionsMenu();
		break;
		case 3:
			showHighscores();
		break;
	}
}

/*
 * Drawing method for the main menu buttons
 */
void buildMainMenu(){
	// Start Game button
	LCD->fillCircle(40, 35, 5, COLOR_FINE_RED); // Top left circle
	LCD->fillCircle(40, 35 + 34, 5, COLOR_FINE_RED); // Bottom left circle
	LCD->fillCircle(40 + 235, 35, 5, COLOR_FINE_RED); // Top right circle
	LCD->fillCircle(40 + 235, 35 + 34, 5, COLOR_FINE_RED); // Bottom right circle
	LCD->fillRect(40, 35 - 5, 40 + 235, 35 + 34 + 5, COLOR_FINE_RED); // Upper-Bottom Rectangle
	LCD->fillRect(40 - 5, 35, 40 + 235 + 5, 35 + 34, COLOR_FINE_RED); // Left-Right Rectangle
	LCD->drawText(40, 35, "Start Game", 3, COLOR_WHITE, COLOR_FINE_RED); // Button tekst
	// Options button
	LCD->fillCircle(75, 100, 5, COLOR_FINE_GREEN); // Top left circle;
	LCD->fillCircle(75, 100 + 34, 5, COLOR_FINE_GREEN); // Bottom left circle
	LCD->fillCircle(75 + 165, 100, 5, COLOR_FINE_GREEN); // Top right circle
	LCD->fillCircle(75 + 165, 100 + 34, 5, COLOR_FINE_GREEN); // Bottom right circle
	LCD->fillRect(75, 100 - 5, 75 + 165, 100 + 34 + 5, COLOR_FINE_GREEN); // Upper-Bottom Rectangle
	LCD->fillRect(75 - 5, 100, 75 + 165 + 5, 100 + 34, COLOR_FINE_GREEN); // Left-Right Rectangle
	LCD->drawText(75, 100, "Options", 3, COLOR_WHITE, COLOR_FINE_GREEN); // Button tekst
	// Highscores button
	LCD->fillCircle(40, 165, 5, COLOR_FINE_ORANGE); // Top left circle
	LCD->fillCircle(40, 165 + 34, 5, COLOR_FINE_ORANGE); // Bottom left circle
	LCD->fillCircle(40 + 235, 165, 5, COLOR_FINE_ORANGE); // Top right circle
	LCD->fillCircle(40 + 235, 165 + 34, 5, COLOR_FINE_ORANGE); // Bottom right circle
	LCD->fillRect(40, 165 - 5, 40 + 235, 165 + 34 + 5, COLOR_FINE_ORANGE); // Upper-Bottom Rectangle
	LCD->fillRect(40 - 5, 165, 40 + 235 + 5, 165 + 34, COLOR_FINE_ORANGE); // Left-Right Rectangle
	LCD->drawText(40, 165, "Highscores", 3, COLOR_WHITE, COLOR_FINE_ORANGE); // Button tekst
	// Version number
	LCD->drawText(0, 227, "BobCopter version 0.1", 1, COLOR_WHITE, COLOR_FINE_BLUE); // Version tekst
}

void startNewGame() {
	LCD->drawText(0, 0, "New game started", 1, COLOR_WHITE, COLOR_FINE_BLUE);
}

void buildOptionsMenu() {
	LCD->drawText(0, 0, "Options", 1, COLOR_WHITE, COLOR_FINE_BLUE);
}

void showHighscores() {
	LCD->drawText(0, 0, "Highscores", 1, COLOR_WHITE, COLOR_FINE_BLUE);
}

Maybe someone knows how to get the right x and y out of my touch controller. I can’t fix it by myself.

Kind regards,

Anybody?