2008-10-22 09:20:52     touch screen

Document created by Aaronwu Employee on Aug 8, 2013
Version 1Show Document
  • View in full screen mode

2008-10-22 09:20:52     touch screen

Maha lakshmi (INDIA)

Message: 64040   

 

Hi,

 

      I am using BF-548 EZ-Kit Lite Rev-1.4. I have configured AD7877 touch screen driver and it's working fine. The problem is with nano-X, I used the  following code to fetch the x and y coordinates where the touch is made.

 

        GrGetScreenInfo(&sinfo);

        printf("screen width %d height %d",sinfo.cols,sinfo.rows);

        w = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0,sinfo.cols,sinfo.cols, 1, WHITE, BLUE);

        gc = GrNewGC();

        GrSetGCForeground(gc, RED);

        GrSetGCUseBackground(gc, GR_FALSE);

        GrSelectEvents(w, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN);

 

        GrMapWindow(w);

        for (;;)

        {

              GrGetNextEvent(&event);

              switch (event.type)

              {

              case GR_EVENT_TYPE_EXPOSURE:

 

                     break;

               case GR_EVENT_TYPE_BUTTON_DOWN:

                {

                        GrClearWindow(w,0);

                        sprintf(val,"%d %d",event.button.x,event.button.y);

                        GrText(w, gc, 10, 30,val,-1,GR_TFASCII);

                        GrPoint(w,gc,event.button.x,event.button.y);

 

                 }

 

          }

 

          The GrGetScreenInfo api printing 480 and 272 as width and height as expected. The value of x and y mouse positions (event.button.x and event.button.y) are NOT as same as mouse in desktop. I touched at bottom right but the point is drawn at top left. I hope it takes bottom right as 0,0.

 

           event.button.x is showing only in the range of 200 even if press it in top left but I got the event.button.y  around 270.

 

           I want to get the x and y co-ordinates as mouse with top left as 0,0 and bottom right as width and height of the window.

 

           Please tell me a solution for this and please don't mistake me if this question not to be posted in this site.     

 

Thanks,

 

Maha

 

 

 

                 

                

 

 

QuoteReplyEditDelete

 

 

2008-10-27 05:47:39     Re: touch screen

Yi Li (CHINA)

Message: 64226   

 

Sorry. I don't think there is nanox expert here to help you on this. But did you read the doc: http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:ad7877#using_the_ad7877_in_microwin_nano-x.

QuoteReplyEditDelete

 

 

2008-11-09 23:37:22     Re: touch screen

Maha lakshmi (INDIA)

Message: 64899   

 

Hi,

 

        I have the touch screen problem by myself. The x and y coordinates of touch screen in kernel configuration has to be set with 480 and 272 respectively and in the nano-X code get the x and y coordinates by doing a simple calculation 480 - button.x and event.button.y where event is the object of GR_EVENT.

 

Thanks,

 

Maha

Attachments

    Outcomes