Pages: 1 [2]   Go Down
Author Topic: ITDB02_Touch problems  (Read 5555 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 7
Posts: 476
what?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im guessing it might be the calibration settings
There are mine, thats not to say they will work for you but it might help, are you able to take a picture of the screen?
Code:
#define PixSizeX -14.98
#define PixOffsX 226
#define PixSizeY 10.94
#define PixOffsY 368
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for that they work perfectly  smiley-lol
i expect i will be back on here soon trying to get my own to work lol

thanks
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok what have i dun now lol

Code:

// UTFT_Demo_320x240

#include <UTFT.h>
#include <ITDB02_Touch.h>
// Declare which fonts we will be using
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];

// Uncomment the next line for Arduino Mega
UTFT myGLCD(ITDB32S,38,39,40,41);   // Remember to change the model parameter to suit your display module!
ITDB02_Touch  myTouch(6,5,4,3,2);

int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";

void setup()
{

  // Setup the LCD
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setFont(BigFont);

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);

  pinMode(13, OUTPUT);
  //                               L,R   up, down
  myGLCD.print("LIGHTING CONTROL", 25, 300);
  myGLCD.print("ON", 54, 385);
  myGLCD.print("OFF", 218, 385);
  myGLCD.setColor(0, 0, 255);



  //                 T,L  B,L  T,R  B,R 
  myGLCD.drawRoundRect(50,100,100,170);        // Draw a rectangle
  myGLCD.drawRoundRect(220,100,270,170);        // Draw a rectangle
  myGLCD.setColor(0, 300, 255);

}

void loop()
{


  if (myTouch.dataAvailable())
  {
    myTouch.read();
    x=myTouch.getX();
    y=myTouch.getY();

    if ((y>=50) && (y<=100)) 
    {
      if ((x>=100) && (x<=170))  // Button: On
      {
        digitalWrite(13, HIGH);   // set the LED on
      }
      if ((x>=270) && (x<=170))  // Button; Off
      {
        digitalWrite(13, LOW);    // set the LED off
      }
    }
  }
}

Logged

0
Offline Offline
Sr. Member
****
Karma: 7
Posts: 476
what?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

changed this line
Code:
if ((x>=270) && (x<=170))  // Button; Off

to this
Code:
if ((x>=170) && (x<=270))  // Button; Off

check which way your <=>'s are pointing

also
Code:
if ((y>=50) && (y<=100)) 
to this
Code:
if ((y>=100) && (y<=170)) 

and this
Code:
if ((x>=100) && (x<=170))  // Button: On
to this
Code:
if ((x>=50) && (x<=100))  // Button: On

careful not to confuse your x & y's

glad to see you got it working eventually
« Last Edit: August 27, 2012, 02:49:25 pm by P18F4550 » Logged

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Remember that you need to constantly update things, then ask if there is touch data and continue otherwise if you keep too much time in some task, the screen will seems unresponsive. Not in this state, but when your app goes bigger and do something.

For the buttons I recommend you to do some functions to create them and ask if user touched them like

Code:
// drawButton(0,0,40,40,"text");

// if(isButtonTouched(0,0,40,40)) { ...

And you place all that functions in another tab.
Logged

My website: http://ried.cl

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi thanks for that but could you elaborate on it as i dont quite follow
Logged

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

1) Draw graphics

2) Cycle checking if there is some touch event
          Cycle checking if the touch is inside a button
Logged

My website: http://ried.cl

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

no sorry, how do i fit that into my code?
Logged

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

what? see the examples for the screen, and start from there.
Logged

My website: http://ried.cl

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:

 drawButton(0,0,54,385,"ON");
if(isButtonTouched(100,170,50,100)) {

        digitalWrite(13, HIGH);   // set the LED on
      }
 drawButton(0,0,218,385,"OFF");     
if(isButtonTouched(100,170,170,270)) {

        digitalWrite(13, LOW);    // set the LED off
      }


this is what i have at mo when i compile it i get drawButton was not declared in this scope  so i am missing sumthing?
Logged

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

These are my functions, you need to create yours.
Logged

My website: http://ried.cl

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how ?
that was a guess as i have no idea
Logged

Pages: 1 [2]   Go Up
Jump to: