Go Down

Topic: ITDB02_Touch problems (Read 6227 times) previous topic - next topic

P18F4550

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: [Select]
#define PixSizeX -14.98
#define PixOffsX 226
#define PixSizeY 10.94
#define PixOffsY 368

Joes

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

thanks

Joes

ok what have i dun now lol

Code: [Select]


// 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
      }
    }
  }
}


P18F4550

#18
Aug 27, 2012, 09:41 pm Last Edit: Aug 27, 2012, 09:49 pm by P18F4550 Reason: 1
changed this line
Code: [Select]
if ((x>=270) && (x<=170))  // Button; Off

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

check which way your <=>'s are pointing

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

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

careful not to confuse your x & y's

glad to see you got it working eventually

eried

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: [Select]
// drawButton(0,0,40,40,"text");

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


And you place all that functions in another tab.
My website: http://ried.cl

Joes

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

eried

1) Draw graphics

2) Cycle checking if there is some touch event
          Cycle checking if the touch is inside a button
My website: http://ried.cl

Joes

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

eried

what? see the examples for the screen, and start from there.
My website: http://ried.cl

Joes

Code: [Select]


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?

eried

These are my functions, you need to create yours.
My website: http://ried.cl

Joes

how ?
that was a guess as i have no idea

Go Up