mtk touch panel 2010/10/14. 2 agenda introduction features files frameworke driver touch panel...

32
MTK Touch panel 2010/10/14

Upload: jasmine-mckenna

Post on 26-Mar-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

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

MTK Touch panel

2010/10/14

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

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

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

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

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

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)

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

5

Framework

System :

MMI : MMI Application

Category screens

WGUI

GUI

Draw ManagerProtocol / Keypad /

Interrupt event manager

Touch panel event

manager

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

6

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

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

7

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

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

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 ModeSingle-Ended Mode

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

9

Driver: 2-points Calibration(1/2)

dcYQ

baXP

YX

QP

ignored be to enough small is errorlinearity The :2 Assumption

ecorrelativ not are Y X, :1 Assumption

coodrinare panel Touch

coodrinare LCD

:),(

:),(

),( YX

x

y),( QP

p

q

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

10

Driver: 2-points Calibration(2/2)

dcYQ

baXP

a, b, c, d get to points ncalibratio

predefined two need weHence

distance distance

axis-X LCD at Coord.

axis-X ACDat Coord.

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

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)

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

12

Driver: MTK Calibration(2/2)

TPFT

Callback(para)

touch_panel_cb_registration(callback, para)

Touch event

touch_panel_read_adc(x, y)

Factory Mode

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

13

Driver: Custom const variablesMembers Description

TOUCH_PANEL_ADC_X_START ADC of the left-upper x coordinate

TOUCH_PANEL_ADC_X_EDN ADC of the right-lower x coordinate

TOUCH_PANEL_ADC_Y_START ADC of the left-upper y coordinate

TOUCH_PANEL_ADC_Y_EDN ADC of the right-lower y coordinate

TOUCH_PANEL_COORD_X_START Minimum value of the x coordinate

TOUCH_PANEL_COORD_X_EDN Maximum value of the x coordinate

TOUCH_PANEL_COORD_Y_START Minimum value of the y coordinate

TOUCH_PANEL_COORD_Y_EDN Maximum value of the y coordinate

TOUCH_PANEL_START_BIT Start bit setting of touch panel module

TOUCH_PANEL_X_PLUS X plus setting of touch panel module

TOUCH_PANEL_Y_PLUS Y plus setting of touch panel module

TOUCH_PANEL_ADC3 ADC3 setting of touch panel module

TOUCH_PANEL_ADC4 ADC4 setting of touch panel module

TOUCH_PANEL_12BIT_SAMPLE 12 bits sample setting of touch panel module

TOUCH_PANEL_8BIT_SAMPLE 8 bits sample setting of touch panel module

TOUCH_PANEL_DIFF_MODE Differential mode setting of touch panel module

TOUCH_PANEL_SINGLE_MODE Single-ended mode setting of touch panel module

TOUCH_PANEL_PWD_ENBLE Power down enable setting of touch panel module

TOUCH_PANEL_IRQ_DISABLE Interrupt disable setting of touch panel module

TOUCH_PANEL_PWD_DISABLE Power down disable setting of touch panel module

TOUCH_PANEL_PWD_RESER Reset setting of touch panel module

SPI_DIN_PIN GPIO used to be input

SPI_CLK_PIN GPIO used to be clock

SPI_DOUT_PIN GPIO used to be output

SPI_CS_PIN GPIO used to be chip select

SPI_BUSY_PIN GPIO used to be busy signal

TOUCH_PANEL_EINT_DOWN_LEVEL Touch panel interrupt level

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

14

Touch panel event flow(Touch panel task)

HIS

R

Dow

nU

p

Strokemode

Starttimer

TRUEFALSE

Starttimer

Starttimer

Start timer

Strokemode

TRUEFALSE

Stop alltimer

PEN_DOWN

PEN_LONGTAP

PEN_REPEAT

PEN_MOVE

STROKE_DOWN

STROKE_MOVE

PEN_UP STROKE_UP80ms≈

600ms≈

300ms≈

20ms≈

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

15

Touch panel event flow(MMI task)PEN_DOWN

STROKE_DOWNPEN_ABORT

PEN_REPEATPEN_LONGTAPPEN_MOVEPEN_UP

STROKE_MOVE

STROKE_UP

MMI_PEN_EVENT_DOWN

MMI_PEN_EVENT_UP

MMI_PEN_EVENT_MOVE

MMI_PEN_EVENT_LONG_TAP

MMI_PEN_EVENT_REPEAT

MMI_PEN_EVENT_ABORT

Strokemode TRUEFALSE

MMI_PEN_EVENT_DOWN

Push stroke point

MMI_PEN_STROKE_DOWN

Strokemode

FALSETRUE

Strokemode TRUEFALSE

MMI_PEN_EVENT_UP

Push stroke end

MMI_PEN_STROKE_UP

Push stroke point

MMI_PEN_STROKE_MOVE

Move distance >stroke min offset

TRUE

MMI_PEN_EVENT_ABORT

Push stroke point

MMI_PEN_STROKE_DOWN

Push stroke point

MMI_PEN_STROKE_MOVE

Enable stroke mode

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

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;

}

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

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);}

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

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);

}

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

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

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

20

Draw Manager: Draw flow diagram

Settings

Category

Screen X

Draw Manag

er

Phonebook

……

Application

Layer

Category

Layer

UI

Layer

Resources

Layer

Coordinate

Set

ControlSet

Screen Id 1

Screen Id

Category Id

Screen Id Category Id

Category IdScreen Id 3

Screen Id 2 control

coordinate

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

21

Draw Manager: Event flow diagram

Draw manager resources

(CustCoordinates.c)

Coordinate

Set

ControlSet

Screen Id Category Id

Category Id

control

coordinatePEN_DOWN

PEN_UP PEN_MOVE

PEN_LONGTAP

PEN_REPEAT

STROKE_MOVE

STROKE_DOWN

STROKE_UP

Touch Event

Manager

WGUI Touch Event

Manager

WGUIComponent | Event | Point

WGUIWGUI Touch Event Manager

(wgui_touch_screen.c)

Touch Event Manager

(TouchScreen.c)

Driver Event Manager

(touch_panel.c)

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

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{

U16 U16CategoryId; //Unique Category ID U8* U8ControlSet_p; //Control set in current category screenS16* s32DefaultCoordinateSet_p; //Corrdinate set in current category screenS16* 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{

S32 s32ScreenId; //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}

};

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

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};

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

24

Draw manager resource: Control type Category component

DM_CIRCULAR_MENU1,DM_LIST1,DM_ROTATE_MENU1,DM_INLINE_FIXED_LIST1,DM_DYNAMIC_LIST1,DM_ASYNCDYNAMIC_LIST1,DM_MATRIX_MENU1,DM_SINGLELINE_INPUTBOX1,DM_MULTILINE_INPUTBOX1,DM_EMS_INPUTBOX1,DM_DIALER_INPUT_BOX1,DM_TAB_CONTROL,DM_HORIZONTAL_TAB_BAR,DM_DATE_TIME_DISPLAY,DM_TITLE1,DM_STATUS_BAR1,DM_LSK,DM_RSK,DM_CSK,DM_BUTTON,DM_CALENDAR,DM_SLIDE_CONTROL,DM_NWAY_STOPWATCH,DM_TYPICAL_STOPWATCH,

Category PrimitiveDM_STRING,DM_IMAGE,DM_LINE,DM_RECTANGLE,DM_BACK_FILL_AREA,

Category control setDM_BASE_CONTROL_SET1,DM_BASE_CONTROL_SET2,DM_BUTTON_BAR1,

Other typeDM_BASE_LAYER_START DM_BASE_LAYER_END,DM_NEW_LAYER_START,DM_NEW_LAYER_END,DM_ALIGNED_AREA_START,DM_ALIGNED_AREA_END,DM_SCR_BG,DM_WALL_PAPERDM_POPUP_BACKGROUND,DM_CATEGORY_CONTROLLED_AREA,

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

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};

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

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 CoordinatesMMI_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

};

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

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;

}

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

28

Exercise: Add new screen(show screen)

void ShowCategoryTouchScreen(){

dm_data_struct dm_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 controldm_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 stringdm_add_string((UI_string_type)slide_value_string,&MMI_default_font,UI_COLOR_RED,UI_COLOR_GREEN,NULL);

//Set category controlled areadm_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();

}

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

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.aendif

Add componentHanWang\src\HanWangInterface.c

Add Libcustom\InputMethod\XXXX_MMI\lib\hws.libcustom\InputMethod\XXXX_MMI\lib\MediaTek_Hwre.libcustom\InputMethod\XXXX_MMI\lib\ MediaTek_Hwre_demo.lib

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

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

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

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)

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

32

谢谢!