Presentation is loading. Please wait.

Presentation is loading. Please wait.

MTK Touch panel 2010/10/14. 2 Agenda Introduction Features Files Frameworke Driver Touch Panel Introduction Touch Panel Calibration Process Touch panel.

Similar presentations

Presentation on theme: "MTK Touch panel 2010/10/14. 2 Agenda Introduction Features Files Frameworke Driver Touch Panel Introduction Touch Panel Calibration Process Touch panel."— Presentation transcript:

1 MTK Touch panel 2010/10/14

2 2 Agenda Introduction Features Files Frameworke Driver Touch Panel Introduction Touch Panel Calibration Process Touch panel event Flow diagram Exercise: tocuh panel event Draw Manager Introduction Draw flow diagram Event flow diagram Controls map Control sets Coordinate Sets Exercise: Add new screen Editor and handwriting

3 3 Features Enable touch panel in project(CUSTOM_PROJECT.mak) TOUCH_PANEL_SUPPORT = TRUE HAND_WRITING = MMI_HANWANG # MMI_HANWANG, MMI_PENPOWER Enable touch panel in MMI(MMI_features.h,do not modify) #ifdef TOUCH_PANEL_SUPPORT #define __MMI_TOUCH_SCREEN__ #endif #ifdef __MMI_TOUCH_SCREEN__ #define __MMI_TOUCH_DIAL_SCREEN__ #define __MMI_DRAW_MANAGER__ #define __MMI_WGUI_CSK_ENABLE__ #endif

4 4 Files System Driver Touch_panel.c (drv\src) Touch_panel.h (interface\hwdrv) Touch_panel_buff.h (interface\hwdrv) Touch_panel_main.c (drv\src) Custom Driver Touch_panel_custom.c (custom\drv\misc_drv\BOARD_VER) Touch_panel_custom.h (custom\drv\misc_drv\BOARD_VER) Touch_panel_spi.c (custom\drv\misc_drv\BOARD_VER) Touch_panel_spi.h (custom\drv\misc_drv\BOARD_VER) MMI framework TouchScreen.c (plutommi\mmi\framework\eventhandling\eventssrc) TouchScreenGprot.h (plutommi\mmi\framework\eventhandling\eventsinc) MMI GUI Wgui_draw_manager.c (plutommi\mmi\gui\gui_src) Wgui_draw_manager.h (plutommi\mmi\gui\gui_inc) Wgui_touch_screen.c (plutommi\mmi\gui\gui_src) Wgui_touch_screen.h (plutommi\mmi\gui\gui_inc) CustCoordinates.c (plutommi\customer\custresource) EditorPen.c (plutommi\mmi\editorpen\editorpensrc)

5 5 Framework System : MMI : MMI Application Category screens WGUI GUI Draw Manager Protocol / Keypad / Interrupt event manager Touch panel event manager

6 6 Driver: 4-Wire Resistive Touch Panel (1/3)

7 7 Driver: 4-Wire Resistive Touch Panel (2/3)

8 8 Driver: 4-Wire Resistive Touch Panel (3/3) How to get a touch point coordinate? 1.Turn on Y+,Y- drivers. 2.Read X+ ADC. 3. Use calibration data to transformed ADC value into coordinate. 4.Turn on X+, X- and repeat step 1 and step 2. Differential Mode Single-Ended Mode

9 9 Driver: 2- points Calibration(1/2)

10 10 Driver: 2-points Calibration(2/2)

11 11 Driver: MTK Calibration(1/2) 2 points calibration with extra one point determination Calibration Flow Calibration Point Position Avoid boundary points Use relative ADC difference to verify calibration points ADC difference is in proportion to coordinate difference The main reason is LCD size and transform speed For example: 256*256 LCD with 12 bits ADC converter The distance between two adjacent pixels could reach 16 units (ADC coordinate)

12 12 Driver: MTK Calibration(2/2) Factory Mode

13 13 Driver: Custom const variables MembersDescription TOUCH_PANEL_ADC_X_STARTADC of the left-upper x coordinate TOUCH_PANEL_ADC_X_EDNADC of the right-lower x coordinate TOUCH_PANEL_ADC_Y_STARTADC of the left-upper y coordinate TOUCH_PANEL_ADC_Y_EDNADC of the right-lower y coordinate TOUCH_PANEL_COORD_X_STARTMinimum value of the x coordinate TOUCH_PANEL_COORD_X_EDNMaximum value of the x coordinate TOUCH_PANEL_COORD_Y_STARTMinimum value of the y coordinate TOUCH_PANEL_COORD_Y_EDNMaximum value of the y coordinate TOUCH_PANEL_START_BITStart bit setting of touch panel module TOUCH_PANEL_X_PLUSX plus setting of touch panel module TOUCH_PANEL_Y_PLUSY plus setting of touch panel module TOUCH_PANEL_ADC3ADC3 setting of touch panel module TOUCH_PANEL_ADC4ADC4 setting of touch panel module TOUCH_PANEL_12BIT_SAMPLE12 bits sample setting of touch panel module TOUCH_PANEL_8BIT_SAMPLE8 bits sample setting of touch panel module TOUCH_PANEL_DIFF_MODEDifferential mode setting of touch panel module TOUCH_PANEL_SINGLE_MODESingle-ended mode setting of touch panel module TOUCH_PANEL_PWD_ENBLEPower down enable setting of touch panel module TOUCH_PANEL_IRQ_DISABLEInterrupt disable setting of touch panel module TOUCH_PANEL_PWD_DISABLEPower down disable setting of touch panel module TOUCH_PANEL_PWD_RESERReset setting of touch panel module SPI_DIN_PINGPIO used to be input SPI_CLK_PINGPIO used to be clock SPI_DOUT_PINGPIO used to be output SPI_CS_PINGPIO used to be chip select SPI_BUSY_PINGPIO used to be busy signal TOUCH_PANEL_EINT_DOWN_LEVELTouch panel interrupt level

14 14 Touch panel event flow(Touch panel task)

15 15 Touch panel event flow(MMI task)

16 16 Exercise: touch panel event #include "MMI_features.h" #include "PixtelDataTypes.h" #include "wgui_categories.h" #include "gdi_include.h" #include "lcd_sw_rnd.h" #include "wgui_draw_manager.h" void my_pen_up_hdlr(mmi_pen_point_struct point); void my_pen_down_hdlr(mmi_pen_point_struct point); void my_pen_move_hdlr(mmi_pen_point_struct point); void my_pen_abort_hdlr(mmi_pen_point_struct point); void my_pen_repeat_hdlr(mmi_pen_point_struct point); void my_pen_long_tap_hdlr(mmi_pen_point_struct point); void start_handwriting(); void end_handwriting(); void touch_panel_event_test() { EntryNewScreen(64000,NULL,NULL,NULL); clear_screen(); mmi_pen_register_up_handler(my_pen_up_hdlr); mmi_pen_register_down_handler(my_pen_down_hdlr); mmi_pen_register_move_handler(my_pen_move_hdlr); mmi_pen_register_abort_handler(my_pen_abort_hdlr); mmi_pen_register_repeat_handler(my_pen_repeat_hdlr); mmi_pen_register_long_tap_handler(my_pen_long_tap_hdlr); SetKeyHandler((FuncPtr)start_handwriting, KEY_1, KEY_EVENT_UP); SetKeyHandler((FuncPtr)end_handwriting, KEY_2, KEY_EVENT_UP); pixtel_UI_BLT_double_buffer(0,0,UI_device_width,UI_device_height); RedrawCategoryFunction = my_test; }

17 17 Exercise: touch panel event (contd) BOOL handwring = FALSE; void draw_point(U8* event_type,U16 y, mmi_pen_point_struct point) { U32 rand_color = rand()%255; gdi_draw_solid_rect(0, y, 176, y+20, DRV_RGB_TO_HW(255,255,255)); gdi_draw_solid_rect(0, 0, 10, 220, DRV_RGB_TO_HW(255,255,255)); pixtel_UI_set_text_color(UI_COLOR_RED); pixtel_UI_move_text_cursor(10,y); pixtel_UI_printf((UI_string_type)"%s {%d, %d}",event_type, point.x, point.y); gdi_draw_solid_rect(3, y + 5, 8, y + 10, DRV_RGB_TO_HW(0,255-rand_color,rand_color)); if (handwring) { gdi_draw_rect(30, 150, 150, 200, DRV_RGB_TO_HW(0,255,0)); gdi_draw_rect(40, 30, 174, 170, DRV_RGB_TO_HW(0,0,255)); } pixtel_UI_BLT_double_buffer(0,0,UI_device_width,UI_device_height); } void my_pen_up_hdlr(mmi_pen_point_struct point){ draw_point("pen up", 5, point); } void my_pen_down_hdlr(mmi_pen_point_struct point){ draw_point("pen down", 30, point); } void my_pen_move_hdlr(mmi_pen_point_struct point){ draw_point("pen move", 55, point); } void my_pen_abort_hdlr(mmi_pen_point_struct point){ draw_point("pen abort", 80, point); } void my_pen_repeat_hdlr(mmi_pen_point_struct point){ draw_point("pen repeat", 105, point); } void my_pen_long_tap_hdlr(mmi_pen_point_struct point){ draw_point("pen long tap", 130, point); }

18 18 Exercise: touch panel event(contd) void my_pen_stroke_down_hdlr(mmi_pen_point_struct point) { draw_point("stroke down", 155, point); } void my_pen_stroke_move_hdlr(mmi_pen_point_struct point) { draw_point("stroke move", 180, point); } void my_pen_stroke_up_hdlr(mmi_pen_point_struct point) { draw_point("stroke up", 205, point); } mmi_pen_point_struct point_array[100]; void start_handwriting() { mmi_pen_handwriting_area_struct stroke_area = {30, 150, 150, 200}; mmi_pen_handwriting_area_struct ext_stroke = {40, 30, 174, 170 }; mmi_pen_start_capture_strokes(100, point_array, 1, &stroke_area, &ext_stroke); mmi_pen_register_stroke_down_handler(my_pen_stroke_down_hdlr); mmi_pen_register_stroke_move_handler(NULL, NULL, my_pen_stroke_move_hdlr); mmi_pen_register_stroke_up_handler(my_pen_stroke_up_hdlr); handwring = TRUE; gdi_draw_rect(30, 150, 150, 200, DRV_RGB_TO_HW(0,255,0)); gdi_draw_rect(40, 30, 174, 170, DRV_RGB_TO_HW(0,0,255)); pixtel_UI_BLT_double_buffer(0,0,UI_device_width,UI_device_height); } void end_handwriting() { mmi_pen_stop_capture_strokes(); handwring = FALSE; clear_screen(); pixtel_UI_BLT_double_buffer(0,0,UI_device_width,UI_device_height); }

19 19 Draw Manager: Introduction The direct benefits of draw manager are that it explicitly lists all UI components inside a category screen. UI Component: Each UI component on the screen is represented as an object. Each UI component has its size and position. Each keypad handler might be mapped to one UI component. One UI component might contains child UI components Each UI components has its pen handlers. Only UI components can interpret coordinates, WGUI does not know complete coordinate information. UI components are a set of basic functions to Create an object entity that has size and position. Provide methods to modify attributes/style of an object. Provide routines to redraw an object. The coordinates sets and control sets are maintained in resource files. The same category screen may have a different coordinates (size) for different applications. (even different control set) The redraw, history and exit functions for all the category screens will be replaced by common functions. dm_redraw_category_screen dm_get_history/dm_get_history_size dm_exit_category_screen

20 20 Draw Manager: Draw flow diagram Settings Category Screen X Draw Manager Phoneboo k …… Application Layer Category Layer UI Layer Resources Layer Coordinate Set Control Set Screen Id 1 Screen Id Category Id Screen Id Category Id Category Id Screen Id 3 Screen Id 2 control coordinate

21 21 Draw Manager: Event flow diagram Draw manager resources (CustCoordinates.c) Coordinate Set Control Set Screen Id Category Id Category Id control coordinate PEN_DOWN PEN_UP PEN_MOVE PEN_LONGTAP PEN_REPEAT STROKE_MOVE STROKE_DOWN STROKE_UP Touch Event Manager WGUI Touch Event Manager WGUI Component | Event | Point WGUI WGUI Touch Event Manager (wgui_touch_screen.c) Touch Event Manager (TouchScreen.c) Driver Event Manager (touch_panel.c)

22 22 Draw manager resource: Controls Map Description: Unique Category ID maps to control set Unique Screen ID maps to coordinate set Categories controls map Struct: typedef struct { U16U16CategoryId;//Unique Category ID U8*U8ControlSet_p;//Control set in current category screen S16*s32DefaultCoordinateSet_p;//Corrdinate set in current category screen S16*s32RotatedCoordinateSet_p;//Unused }CategoryId_ControlSet_struct; Data: const CategoryId_ControlSet_struct g_categories_controls_map[]= { {MMI_CATEGORY5_ID,(U8*)category5,(s16*)coordinate_set5,NULL}, ………… {MMI_CATEGORY_WCLOCK,(U8*)categoryWcScreen,(s16*)coordinate_WcScreen,NULL} }; Screenid coordinate sets map Struct: typedef struct { S32s32ScreenId;//Unique Screen ID S16*s16CoordinateSet_p;//Corrdinate set in current screen }ScreenId_CoordinateSet_struct; Data: const ScreenId_CoordinateSet_struct g_screenid_coordinate_sets_map[]= { {SCR_SEARCH_NAME_ENTRY, (S16*)coordinate_set5}, {SCR_ID_PHOART_TEXT_SELECT,(S16*)coordinate_set57_top_infobox} };

23 23 Draw manager resource: Control sets Description: Unique Category ID maps to control set, Number of controls are decided by category. Some common-used controls could be grouped as a base control set. Some applications control display by itself. These applications should also handle pen events. e.g. Camera, FM Radio, Struct: { no_of_controls, control_1, control_2, control_3, …….. control_n } example: const S32 category101 = {3, TITLE1, LIST1, BUTTON_BAR1}; const S32 category5 = {3, TITLE1, MULTILINE_INPUTBOX1, BUTTON_BAR1};


25 25 Draw manager resource: Coordinate Sets Description: Unique category ID or unique screen ID maps to coordinate set, Position and size of controls are decided by category or screen. Define the coordinates of UI elements in corresponding control set. Struct: Coordinate Structure Details { {category_coordinates}, {control_1_coordinates}, ….. … {control_n_coordinates} }; example: const S32 coordinate_set101[] = { 0, 0, UI_DEVICE_WIDTH, UI_DEVICE_HEIGHT, 0, 0, UI_DEVICE_WIDTH, MMI_TITLE_HEIGHT, 0, 18, 128, 92,//List Coordinates 0, 110, 128, 18, 50//Button Bar Coordinates };

26 26 Exercise: Add new screen(Add resource)) Step 1: Add CATEGORY_ID (wgui_categories_defs.h): enum MMI_CATEGORY_ID_LIST { MMI_LIST_CATEGORY_ID=1, ………… MMI_CATEGORY_TOUCH_SCREEN_EXERCISE_ID }; Step 2: Add categories controls map(CustCoordinates.c): const CategoryId_ControlSet_struct g_categories_controls_map[]= { {MMI_CATEGORY5_ID, (U8*)category5, (s16*)coordinate_set5}, ………… {MMI_CATEGORY_TOUCH_SCREEN_EXERCISE_ID, (U8*)categoryTouchScreen, (s16*)coordinate_TouchScreen} }; Step 3: Add ControlSet(CustCoordinates.c): const U8 categoryTouchScreen[]= { 5, DM_BASE_LAYER_START, DM_BASE_CONTROL_SET1, DM_SLIDE_CONTROL, DM_STRING, DM_CATEGORY_CONTROLLED_AREA }; Step 4: Add CoordinateSet(CustCoordinates.c): const s16 coordinate_TouchScreen[]= { 0,0,MAIN_LCD_DEVICE_WIDTH,MAIN_LCD_DEVICE_HEIGHT,DM_NO_FLAGS,//Category Screen Coordinates MMI_CONTENT_X,MMI_CONTENT_Y + 10,MMI_CONTENT_WIDTH,MMI_CONTENT_Y + 30,DM_CENTRE_ALIGN_X, MMI_CONTENT_X,MMI_CONTENT_Y + 40,MMI_CONTENT_WIDTH,MMI_CONTENT_Y + 70,DM_CENTRE_ALIGN_X, MMI_CONTENT_X+ 38,MMI_CONTENT_Y + 70,100,50,DM_CENTRE_ALIGN_X };

27 27 Exercise: Add new screen(event handler) #include "MMI_features.h" #include "PixtelDataTypes.h" #include "GlobalDefs.h" #include "HistoryGprot.h" #include "wgui_categories.h" #include "gdi_include.h" #include "lcd_sw_rnd.h" #include "wgui_draw_manager.h void ShowCategoryTouchScreen(); S32 slide_value = 30; UI_character_type slide_value_string[50] = L"current value: 30"; void TouchScreen(){ EntryNewScreen(64000,NULL,NULL,NULL); clear_screen(); ShowCategoryTouchScreen(); SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP); pixtel_UI_BLT_double_buffer(0,0,UI_device_width,UI_device_height); RedrawCategoryFunction = my_test; } void draw_control_area(dm_coordinates *coordinate){ pixtel_UI_fill_rectangle(coordinate->s16X,coordinate->s16Y, coordinate->s16X+coordinate->s16Width-1, coordinate->s16Y+coordinate->s16Height-1,UI_COLOR_GREEN); } void slide_value_change_callback(){ pixtel_UI_sprintf(slide_value_string, "current value: %d", slide_value); RedrawCategoryFunction(); } BOOL control_area_pendown(mmi_pen_point_struct point){ if (PEN_CHECK_BOUND(point.x, point.y, MMI_CONTENT_X+ 38,MMI_CONTENT_Y + 70,100,50) ) { pixtel_UI_sprintf(slide_value_string, "current point: {%d, %d}", point.x, point.y); RedrawCategoryFunction(); return TRUE; } return FALSE; }

28 28 Exercise: Add new screen(show screen) void ShowCategoryTouchScreen() { dm_data_structdm_data; pixtel_UI_lock_double_buffer(); MMI_menu_shortcut_number=-1; change_left_softkey(STR_GLOBAL_OK,IMG_GLOBAL_OK); change_right_softkey(STR_GLOBAL_BACK,IMG_GLOBAL_BACK); SetupCategoryKeyHandlers(); MMI_title_string=L"Touch screen"; MMI_title_icon=NULL; //Set slide control dm_add_image(get_image(WGUI_SLIDE_CONTROL_BG_IMAGE_ID),NULL); dm_add_slide_control(0,100,slide_value,slide_value_change_callback); MMI_slide_control_value[0]=&slide_value; MMI_slide_control_value[1]=&slide_value; wgui_slide_control_set_focus(&MMI_slide_control[0]); SetKeyHandler(wgui_slide_control_previous,KEY_LEFT_ARROW,KEY_EVENT_DOWN); SetKeyHandler(wgui_slide_control_next,KEY_RIGHT_ARROW,KEY_EVENT_DOWN); //Set string dm_add_string((UI_string_type)slide_value_string,&MMI_default_font,UI_COLOR_RED,UI_COLOR_GREEN,NULL); //Set category controlled area dm_register_category_controlled_callback(draw_control_area); mmi_wgui_register_category_screen_control_area_pen_handlers(control_area_pendown,MMI_PEN_EVENT_DOWN); dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND; pixtel_UI_unlock_double_buffer(); ExitCategoryFunction=ExitCategoryTouchScreen; dm_setup_category_functions(dm_redraw_category_screen, dm_get_category_history, dm_get_category_history_size); dm_data.s32ScrId = (s32)GetActiveScreenId(); dm_data.s32CatId = MMI_CATEGORY_TOUCH_SCREEN_EXERCISE_ID; dm_setup_data(&dm_data); dm_redraw_category_screen(); }

29 29 Editor and handwriting Make file HAND_WRITING = MMI_HANWANG # MMI_HANWANG, MMI_PENPOWER ifeq ($(strip $(HAND_WRITING)),MMI_HANWANG) COMPOBJS += custom\inputmethod\$(strip $(MMI_VERSION))\lib\hw.a CUS_REL_SRC_COMP += hanwang CUS_REL_OBJ_LIST += custom\inputmethod\$(strip $(MMI_VERSION))\lib\hw.lib CUS_REL_OBJ_LIST += custom\inputmethod\$(strip $(MMI_VERSION))\lib\hws.lib CUS_REL_OBJ_LIST += custom\inputmethod\$(strip $(MMI_VERSION))\lib\hw.dll CUS_REL_OBJ_LIST += custom\inputmethod\$(strip $(MMI_VERSION))\lib\hw.a endif Add component HanWang\src\HanWangInterface.c Add Lib custom\InputMethod\XXXX_MMI\lib\hws.lib custom\InputMethod\XXXX_MMI\lib\MediaTek_Hwre.lib custom\InputMethod\XXXX_MMI\lib\ MediaTek_Hwre_demo.lib

30 30 Editor and handwriting(in Simulator ) Add Handwriting Interface File HanWang\src\HanWangInterface.c Add Handwriting Library File custom\InputMethod\XXXX_MMI\lib\hws.lib custom\InputMethod\XXXX_MMI\lib\MediaTek_Hwre.lib custom\InputMethod\XXXX_MMI\lib\ MediaTek_Hwre_demo.lib Add Preprocessor Preprocessor definitions __MMI_HANWANG__ __MMI_PENPOER__ Additional include directories..\..\custom\InputMethod\XXXX_MMI\inc

31 31 Define /* Delay time for Pen LongTap */ #define MMI_PEN_LONGTAP_TIME(60) /* multiple of 10ms */ /* Delay time for Pen Repeat */ #define MMI_PEN_REPEAT_TIME(30) /* multiple of 10ms */ /* Sampling period of Event-Based pen events (~ 12 samples/sec) */ #define MMI_PEN_SAMPLING_PERIOD_1(8) /* multiple of 10ms */ /* Sampling period of Stroke-Based pen events (50 samples/sec) */ #define MMI_PEN_SAMPLING_PERIOD_2(2) /* multiple of 10ms */ #define MMI_PEN_POLLING_PERIOD(4 * 10) /* ms */ #define MMI_PEN_STROKE_MIN_OFFSET(25) #define MMI_PEN_DEBOUNCE_POLLING_DELAY(1000 / 5 - MMI_PEN_POLLING_PERIOD)

32 32

Download ppt "MTK Touch panel 2010/10/14. 2 Agenda Introduction Features Files Frameworke Driver Touch Panel Introduction Touch Panel Calibration Process Touch panel."

Similar presentations

Ads by Google