Read coordinates touchscreen(UART)

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
BreadBord
Posts: 20
Joined: 16 Feb 2012 09:44

Read coordinates touchscreen(UART)

#1 Post by BreadBord » 16 Feb 2012 09:52

Hi

I want to read the touch coordinates (x,y) from a picaso scg display.

Datasheet: http://www.4dsystems.com.au/downloads/S ... -rev10.pdf

I send the following hex commands(via UART) to the display to read those coordinates:
0x6F //command
0x4F //get touch status
0x6F //command
0x5F //get touch coordinates

0x5F returns a 2 byte value for x and a 2 byte value for y.

How can i place this return value in a string to place it as text on the display ?

Thanks in advance.

drdoug
Posts: 1074
Joined: 16 Aug 2007 03:49
Location: St. Louis, MO

Re: Read coordinates touchscreen(UART)

#2 Post by drdoug » 17 Feb 2012 05:30

Have you tried inttostr() found in help file?

BreadBord
Posts: 20
Joined: 16 Feb 2012 09:44

Re: Read coordinates touchscreen(UART)

#3 Post by BreadBord » 17 Feb 2012 11:05

I have made the following code but i can't still read the coordinates on the screen:

Code: Select all

void interrupt () {
  if (PIR1.RCIF) {          // test the interrupt for uart rx
    rxchar = Uart1_Read();  //
    rxarray[i] = rxchar;
    PORTB=0b000011000;
    i++;
    // ******************************************************
    // Only select one of the following statements

    if (i ==0) {         // select this if looking for a number of characters
      flag = 1;
        PORTB=0b00001000;

      } // end if (rxchar == "$")
    }
     // end  if (PIR1.RCIF)
}

main code:

Code: Select all



void main() {
unsigned short j;
INTCON.GIE = 1;                            // Enable global interrupts
INTCON.PEIE = 1;
PIE1.RCIE = 1;

while(1) {
Initpic();                                 //configuratie pic
InitScreen();
DelayOneCode(100);
Uart1_write(0x6F);
UART1_write(0x04);
UART1_write(0x6F);
UART1_write(0x05);

  if (flag ==1) {
    j = 0;
    while(j < i) {
     WriteText(rxarray[j],0,0);
     j++;
     }
    i = 0;
    flag = 0;
  }

}

}

Post Reply

Return to “mikroC PRO for PIC General”