AnsweredAssumed Answered

Using the BF548 TouchScreen Driver Example

Question asked by yzuo on Aug 31, 2011
Latest reply on Sep 1, 2011 by yzuo
Branched to a new discussion

Hi,

 

I am currently using a BF548 EZ LITE KIT and trying to program a game onto it. I want my game to use touchscreen control and I have been trying to integrate the provided BF548 touchscreen driver example 'SenseCoordinatePressure' into my game.

I have modified a section of the code in the AD7877Callback() function so that every time it senses the screen has been touched, it triggers a flag. Then, in the main loop, if the program sees this flag has been triggered, it calls a function which performs an action based on the (x,y) coordinates read by the touchscreen. Below is an extract of the code I have changed, with my changes in bold:

 

 

static void AD7877Callback(
    void      *AppHandle,
    u32       Event,
    void      *pArg
){
    /* pointer to AD7877 results location */
    ADI_AD7877_RESULT_REGS     *AD7877Results;
u32 Result;
u32 i;
    /* CASEOF (event type) */
    switch (Event)
    {
       
        /* CASE (PENIRQ detected a screen touch event) */
        case ADI_AD7877_EVENT_PENIRQ:
        screen_touched = 1;
             /* set AD7877 in slave sequencer mode to start channel conversion(s) */
             if((Result = adi_dev_Control(AD7877DriverHandle, ADI_DEV_CMD_REGISTER_FIELD_WRITE, (void *)&AD7877_SlaveSequencer))!= ADI_DEV_RESULT_SUCCESS)
             {
            printf("Failed to configure AD7877 in slave sequencer mode: 0x%08X\n",Result);
             }
            break;
/* CASE (PENIRQ detected a screen release event) */
        case ADI_AD7877_EVENT_PENIRQ_RELEASE:
            break;
           
        /* CASE (Single Channel DAV occurred) */
        case ADI_AD7877_EVENT_SINGLE_DAV:
            break;
       
        /* CASE (Sequencer DAV occurred) */
        case ADI_AD7877_EVENT_SEQUENCER_DAV:
              /* AD7877 passes pointer to the results register structure as argument */
             AD7877Results = (ADI_AD7877_RESULT_REGS *)pArg;
            //printf("Co-ordinates   (x,y)   : (0x%04X,0x%04X)\n", AD7877Results->X, AD7877Results->Y);
            //printf("Touch pressure (z1,z2) : (0x%04X,0x%04X)\n\n", AD7877Results->Z1, AD7877Results->Z2);
            x = AD7877Results->X;
            y = AD7877Results->Y;
            break;
           
        /* CASE (ALERT occurred) */
        case ADI_AD7877_EVENT_ALERT:
            printf("ALERT occurred\n");
            break;
           
default:
printf("Callback event not recogonised. Event code: 0x%08X\n",Event);
break;
               
    /* ENDCASE */
    }
   
    /* return */
}

 

 

I have commented out the printf() functions and instead stored the X and Y values from AD7877Results in global variable x and y. However, I seem to get no response after integrating this with my game program. Is there something I am missing? Any help would be greatly appreciated.

 

Kind Regards,

Yan

Outcomes