Song calculation button Touchscreen

Hello everyone,

My environment:

  • Arduino MEGA 2560
  • LCD SAINSMART 320 * 240 touch with SDCARD
  • Card adapter MEGA2560
  • Arduino IDE 1.0.5
  • TLU Library (C) 2014 Henning Karlsen

My goal:

  • Calculate following the information screen (size) the position and size of the button according to the desired number.

My methodology:

  • Try '(based on known information (width and screen height, Marge and many key) to create an array int [xligne] [xColonne] not used later to build and display the key and set the value of selection area of the touch function.

My current problem:

  • My array int is endless and the data is inconsistent.
    (Attached is the personal function file)
    Below the main code.

// Liaison à la biblioteque UTFT et les fonctions personnelles
#include <UTFT.h>
#include <UTouch.h>

// Liaison aux fonctions personnelles
#include “Fonctions.C”

// Declare variable we will be using

// Declaration des fonctions utilis�es

void setup()
{
myGLCD.InitLCD(LANDSCAPE);
myTouch.InitTouch(LANDSCAPE);

infosLCD ();
delay(2000);
}

void loop()
{
Cadre();
CalcTouch (12);
PrintTableau();
while(1)
{
}
}

Fonctions.C (8.16 KB)

My current problem: - My array int [] [] is endless

I can assure you that it is not.

Cross-post from French section. Please ensure that any posts/resolutions from there are reflected here.

  • My array int [] []

What int array? The code uses a char array to hold coordinate values, which is stupid. A char is a signed variable type, with a range of -128 to 127. Your screen is bigger than 127 x 127.

Thank you for your response,

my PrintTableau () function rotates from endless 15min while my for loops
for (row = 0; line <12; ++ online)
for (column = 0; column <4; line ++)
are 12 rows and 4 column !!!

More in the calculations of the function
CalcTouch void (int touch)
the values of the second pass key already in negative !!
The calculations on paper It Works.

Hello and thank you PaulS,
if I report to the official documentation
http://arduino.cc/en/Reference/int
int is not from -128 to 127?
An array int should therefore be either?

From http://arduino.cc/en/Reference/int

On the Arduino Uno (and other ATMega based boards) an int stores a 16-bit (2-byte) value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1).

Ok PaulS,

Sorry for my last post, My error is corrected, But the results are always infinite but loop type void PrintTableau () does not stop is.

My error is corrected

But, I'm not going to post my code...

But the results are always infinite but loop type void PrintTableau () does not stop is.

Your translator needs new batteries.

Well thank you all,
I must be tired?
My mistake was on copy paste.

Sorry,

Error 1 :
// Declare variable we will be using
int Kb12T[12][4];
int NumMenu;

And error 2
void PrintTableau()
{
int ligne;
int colonne;
int val;
int x=10; //max 310
int y=10; //max 205
for (ligne=0; ligne < 12; ligne++)
{
for (colonne=0; colonne < 4; colonne++)
{

my result and always is not infinite :smiley:
thank you again for everything.
I still have much to do

Why did you put "colonne" in italics?

because when writing this control function of the values of my table, I left in the second loop line instead of column. ;)

MDZT: because when writing this control function of the values of my table, I left in the second loop line instead of column. ;)

I don't know what that means, or how it answers my question.

my original code is :
void PrintTableau()
{
int ligne;
int colonne;
int val;
int x=10; //max 310
int y=10; //max 205
for (ligne=0; ligne < 12; ligne++)
{
for (colonne=0; colonne < 4; ligne++)
{
if (x>=280) // Button: 8
{
x = 10;
y = y + 10;
}
else if (y>=185) // Button: 8
{
y = 10;
}
else
{
val = Kb12T[ligne][colonne];
myGLCD.print(String(" "), x, y);
myGLCD.printNumI(val, x, y);
x = x + 80;
}
}
}
}

And the correct code is :
for (colonne=0; colonne < 4; colonne ++)
the incrementation is colonne no ligne for this loop

For information,
Here are the functions terminated with a standard numeric keypad 12 keys using the TLU library (C) 2014 Henning Karlsen

FoncKb.C (9.76 KB)