//***************************************************************************** // // The callback function that is called by the touch screen driver to indicate // activity on the touch screen. // //***************************************************************************** int32_t UITouchCallback(uint32_t ui32Message, int32_t i32X, int32_t i32Y) { int32_t i32XDiff, i32YDiff; if(((g_sUIState.ui32Indicators & UI_STATUS_KEYBOARD) == 0) && ((i32Y > BG_MIN_Y) && (i32Y < (BG_MAX_Y - STATUS_HEIGHT)))) { switch(ui32Message) { // // . // case WIDGET_MSG_PTR_DOWN: { sMouseState.i32XLast = i32X; sMouseState.i32YLast = i32Y; sMouseState.bPressed = true; ui32PressCount = g_ui32SysTickCount; break; } // The touchscreen is no longer being pressed. // case WIDGET_MSG_PTR_UP: { sMouseState.bPressed = false; if(ui32PressCount > g_ui32SysTickCount) { ui32PressCount = ui32PressCount - g_ui32SysTickCount; } else { ui32PressCount = g_ui32SysTickCount - ui32PressCount; } if(ui32PressCount < 20) { // // Ensure that all buttons are not pressed. // sMouseState.i8Buttons = 0x01; } else { // // Ensure that all buttons are not pressed. // sMouseState.i8Buttons = 0x00; } // // Send the report back to the host. // USBMouseUpdate(0, 0, sMouseState.i8Buttons); break; } // // The touch position has moved. // case WIDGET_MSG_PTR_MOVE: { // // Send the difference not the absolute value. // i32XDiff = i32X - sMouseState.i32XLast; i32YDiff = i32Y - sMouseState.i32YLast; // // Send the report back to the host. // USBMouseUpdate(i32XDiff, i32YDiff, 0); // // Save these values to calculate the next move. // sMouseState.i32XLast = i32X; sMouseState.i32YLast = i32Y; break; } default: { break; } } } else { WidgetPointerMessage(ui32Message, i32X, i32Y); } return(0); }
int main(void) { int xCoOd = 0, yCoOd = 0; char pressure = 0, touched = 0; unsigned int i = 0; unsigned char *dest; unsigned char *src; SetupIntc(); SetUpLCD(); /* configuring the base ceiling */ RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_0); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_1); src = (unsigned char *) palette_32b; dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET); // Copy palette info into buffer for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++) { *dest++ = *src++; } // copy splash screen /*src = (unsigned char *)&splash[40]; for(; i < LCD_SIZE; i++) { *dest++ = *src++; }*/ GrOffScreen16BPPInit(&g_sSHARP480x272x16Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); // Initialize a drawing context. GrContextInit(&sContext, &g_sSHARP480x272x16Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); /* Enable display panel backlight and power */ ConfigRasterDisplayEnable(); DisplayGR(); SoundInit(); // TS init PeripheralsSetup(); InitTouchScreen(); // Loop forever handling widget messages. while(1) { while(!touched) { ReadAxis(2, &pressure, &touched); } /* Resolving the coordinates of the touched location.*/ ResolveCoordinates(&xCoOd, &yCoOd); do { WidgetPointerMessage(WIDGET_MSG_PTR_DOWN, xCoOd, yCoOd); // Process any messages in the widget message queue. WidgetMessageQueueProcess(); ResolveCoordinates(&xCoOd, &yCoOd); ReadAxis(2, &pressure, &touched); }while(touched); WidgetPointerMessage(WIDGET_MSG_PTR_UP, xCoOd, yCoOd); WidgetMessageQueueProcess(); } }
//***************************************************************************** // // The callback function that is called by the touch screen driver to indicate // activity on the touch screen. // //***************************************************************************** int32_t TouchCallback(uint32_t ui32Message, int32_t i32X, int32_t i32Y) { int32_t i32XDiff, i32YDiff; // // Reset the timeout for the screen saver. // g_ui32ScreenSaver = 60 * SYSTEM_TICK_S; if(g_sSwipe.bEnable) { switch(ui32Message) { // // The user has just touched the screen. // case WIDGET_MSG_PTR_DOWN: { // // Save this press location. // g_sSwipe.i32InitX = i32X; g_sSwipe.i32InitY = i32Y; // // Done handling this message. // break; } // // The user has moved the touch location on the screen. // case WIDGET_MSG_PTR_MOVE: { // // Done handling this message. // break; } // // The user is no longer touching the screen. // case WIDGET_MSG_PTR_UP: { // // Indicate that no key is being pressed. // i32XDiff = i32X - g_sSwipe.i32InitX; i32YDiff = i32Y - g_sSwipe.i32InitY; // // Dead zone for just a button press. // if(((i32XDiff < SWIPE_MIN_DIFF) && (i32XDiff > -SWIPE_MIN_DIFF)) && ((i32YDiff < SWIPE_MIN_DIFF) && (i32YDiff > -SWIPE_MIN_DIFF))) { if(g_sButtons.bActive) { // // Reset the delay. // g_sButtons.ui32Delay = 200; if(i32X < 30) { g_sSwipe.eMovement = iSwipeRight; } else if(i32X > 290) { g_sSwipe.eMovement = iSwipeLeft; } else if(i32Y < 40) { g_sSwipe.eMovement = iSwipeDown; } else if(i32Y > 200) { g_sSwipe.eMovement = iSwipeUp; } else { g_sSwipe.eMovement = iSwipeNone; } } else { if(g_i32ScreenIdx == SCREEN_SUMMARY) { AnimateButtons(true); } if(g_i32ScreenIdx == SCREEN_DETAILS) { AnimateButtons(true); } } break; } // // If Y movement dominates then this is an up/down motion. // if(i32YDiff/i32XDiff) { if(i32YDiff < 0) { g_sSwipe.eMovement = iSwipeUp; } else { g_sSwipe.eMovement = iSwipeDown; } } else { if(i32XDiff > 0) { g_sSwipe.eMovement = iSwipeRight; } else { g_sSwipe.eMovement = iSwipeLeft; } } // // Done handling this message. // break; } } } WidgetPointerMessage(ui32Message, i32X, i32Y); return(0); }