cancel
Showing results for 
Search instead for 
Did you mean: 

TFT LCD touch screen mapping by external keypad

Tran Minh Cong
Associate II
Posted on July 12, 2018 at 07:02

Dear every body,

I'm doing project about lcd tft 7inch 800x480 and stm32f746.

Currently, i want use external keypad (or external button), not use touch screen pannel.

Example: 

http://hshop.vn/products/ban-phim-ma-tran-mem-4x4

 

I have 1 button on LCD:

// { BUTTON_CreateIndirect, 'Browse', ID_BUTTON_0, 13, 8, 100, 20, 0, 0x0, 0 },

(x,y) =  (13,8).

width = 100.

height = 20.

=> (x,y) center = (13+100/2 = 63,8+20/2=18).

When 1 keypad or button pressed, i checked that ok.

How to mapping 1 key pressed to WM_NOTIFICATION_CLICKED event of 

ID_BUTTON_0 (ID_BUTTON_0 is displayed on LCD)? After that, emwin will do something: show dialog...

Can you tell me solutions, please?

Thank you so much!

#tft-lcd-touch-screen-mapping-by-external-keypad
39 REPLIES 39
Posted on July 12, 2018 at 08:31

You can emulate key press with

GUI_TOUCH_StoreStateEx

Tran Minh Cong
Associate II
Posted on July 12, 2018 at 08:40

Dear Vitaliy Chernobay,

Via link project:

en.stm32cubef7\STM32Cube_FW_F7_V1.6.0\Projects\STM32756G_EVAL\Applications\STemWin\STemWin_SampleDem

I modified to my project (not use touch_update), dummy data (Simulation).

Can you check it, please?

int gui_keyboard_update(void) {

static GUI_PID_STATE TS_State = { 0, 0, 0, 0 };

GUI_PID_STATE last_TS_State = { 0, 0, 0, 0 };

static int state = 0;

static uint32_t prev_time = 0;

// typedef struct {

// int x,y;

// U8 Pressed;

// U8 Layer;

// } GUI_PID_STATE;

// { BUTTON_CreateIndirect, 'Browse', ID_BUTTON_0, 13, 8, 100, 20, 0, 0x0, 0 },

switch (state) {

case 0:

if (HAL_GetTick() - prev_time > 5000) {//After 5s to dummy press external key.

prev_time = HAL_GetTick();

printf('S0\r\n');

state = 1;

}

break;

case 1:

TS_State.Pressed = 1;

TS_State.Layer = 0;

TS_State.x = 63;

TS_State.y = 18;

GUI_TOUCH_StoreStateEx(&TS_State);

//GUI_PID_StoreState(&TS_State);

prev_time = HAL_GetTick();

printf('S1\r\n');

state = 2;

break;

case 2:

if (HAL_GetTick() - prev_time > 100) {//hold pressed 100ms

prev_time = HAL_GetTick();

printf('S2\r\n');

state = 3;

}

break;

case 3:

TS_State.Pressed = 0;

TS_State.Layer = 0;

TS_State.x = 63;

TS_State.y = 18;

GUI_TOUCH_StoreStateEx(&TS_State);

//GUI_PID_StoreState(&TS_State);

printf('S3\r\n');

state = 4;

break;

case 4:

state = 4;

break;

default:

break;

}

}

But haven't WM_NOTIFICATION_CLICKED event!

Thank you!

Posted on July 12, 2018 at 08:50

like that example

while(1){

pState.x = 200;

pState.y = 120;

pState.Pressed = 1;

 pState.Layer = 0;

GUI_TOUCH_StoreStateEx(&pState);

GUI_Exec();

GUI_Delay(200);

pState.x = -1;

pState.y = -1;

pState.Pressed = 0;

pState.Layer = 0;

GUI_TOUCH_StoreStateEx(&pState);

GUI_Exec();

GUI_Delay(200);

}

Posted on July 12, 2018 at 09:06

Dear you,

I'll try solution that you said.

Thanks.

Posted on July 12, 2018 at 09:16

x & y must be inside the coordinates of the square of the button

Tran Minh Cong
Associate II
Posted on July 13, 2018 at 03:16

Dear Vitaliy Chernobay,

I tried solution that you said.

It is ok.

Thank you so much!

Tran Minh Cong
Associate II
Posted on July 13, 2018 at 07:04

Dear Vitaliy Chernobay,

Currently, I want 4 external button Up, Down, OK, Cancel to select file in USB (only 4 file saved in USB, no folder hold 4 file). These files is showed by TREEVIEW.

0:\

   file1.txt

   file2.txt

   file3.txt

   file4.txt

Up/Down button to up/down file name in list file on TREEVIEW.

Ok button to select file (name of hItem to next funtion).

Can you tell me how to do that, please?

How to get text content in the row?

Thank you!

Tran Minh Cong
Associate II
Posted on July 13, 2018 at 08:27

Dear Vitaliy Chernobay,

I can get event ID_BUTTON_0, ID_BUTTON_1, ID_BUTTON_2, ID_BUTTON_3 by external key, show list file , by show_files() function.

Link about WindowDLG_Test.c.

https://drive.google.com/drive/folders/1dHgIe4uFZUElhIBmTC-IFxvM4C0D2oIs?usp=sharing

 

Please check static void _cbDialog(WM_MESSAGE * pMsg) {}

Thank you so much!

Tran Minh Cong
Associate II
Posted on July 13, 2018 at 09:32

Dear you,

I changed code like that you said but not success.

I updated file WindowDLG.c original, before coding.

Can you check it, please!

Thanks.