Skip to main content
Tran Minh Cong
Associate III
July 12, 2018
Question

TFT LCD touch screen mapping by external keypad

  • July 12, 2018
  • 39 replies
  • 5979 views
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
This topic has been closed for replies.

39 replies

Vitaliy Chernobay
Senior
July 12, 2018
Posted on July 12, 2018 at 08:31

You can emulate key press with

GUI_TOUCH_StoreStateEx

Tran Minh Cong
Associate III
July 12, 2018
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!

Vitaliy Chernobay
Senior
July 12, 2018
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);

}

Tran Minh Cong
Associate III
July 12, 2018
Posted on July 12, 2018 at 09:06

Dear you,

I'll try solution that you said.

Thanks.

Tran Minh Cong
Associate III
July 13, 2018
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 III
July 13, 2018
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!

Vitaliy Chernobay
Senior
July 13, 2018
Posted on July 13, 2018 at 07:37

Publish your project

Tran Minh Cong
Associate III
July 13, 2018
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!

Vitaliy Chernobay
Senior
July 13, 2018
Posted on July 13, 2018 at 09:02

I can not open your  

WindowDLG_Test.c. 

using the program GUIBuilder.

You must modify this file only insert your code only between

// USER START

.....your code

// USER END

Tran Minh Cong
Associate III
July 13, 2018
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.

Tran Minh Cong
Associate III
July 13, 2018
Vitaliy Chernobay
Senior
July 13, 2018
Posted on July 13, 2018 at 09:44

I correct your file by add this 

//

// Initialization of 'USB'

//

hItem = WM_GetDialogItem(pMsg->hWin, ID_TREEVIEW_0);

hTreeItemCur = TREEVIEW_GetItem(hItem, 0, TREEVIEW_GET_LAST);

hTreeItemNew = TREEVIEW_ITEM_Create(TREEVIEW_ITEM_TYPE_NODE, ' file1.txt', 0);

TREEVIEW_AttachItem(hItem, hTreeItemNew, hTreeItemCur, TREEVIEW_INSERT_BELOW);

hTreeItemCur = TREEVIEW_GetItem(hItem, 0, TREEVIEW_GET_LAST);

hTreeItemNew = TREEVIEW_ITEM_Create(TREEVIEW_ITEM_TYPE_NODE, ' file2.txt', 0);

TREEVIEW_AttachItem(hItem, hTreeItemNew, hTreeItemCur, TREEVIEW_INSERT_BELOW);

hTreeItemCur = TREEVIEW_GetItem(hItem, 0, TREEVIEW_GET_LAST);

hTreeItemNew = TREEVIEW_ITEM_Create(TREEVIEW_ITEM_TYPE_NODE, ' file3.txt', 0);

TREEVIEW_AttachItem(hItem, hTreeItemNew, hTreeItemCur, TREEVIEW_INSERT_BELOW);

hTreeItemCur = TREEVIEW_GetItem(hItem, 0, TREEVIEW_GET_LAST);

hTreeItemNew = TREEVIEW_ITEM_Create(TREEVIEW_ITEM_TYPE_NODE, ' file4.txt', 0);

TREEVIEW_AttachItem(hItem, hTreeItemNew, hTreeItemCur, TREEVIEW_INSERT_BELOW);

//

// Initialization of 'OK'

//
Tran Minh Cong
Associate III
July 13, 2018
Posted on July 13, 2018 at 09:51

Oh, many thanks. 

Next step, i'm hearing you tell me about:

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

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

Vitaliy Chernobay
Senior
July 13, 2018
Posted on July 13, 2018 at 10:08

Buttons must emulate pressed on 

TREEVIEW area

Vitaliy Chernobay
Senior
July 13, 2018
Posted on July 13, 2018 at 10:11

I would make it easier

I would create three buttons with names file1 file2 file3 

& and would emulate their pressing

Tran Minh Cong
Associate III
July 13, 2018
Posted on July 13, 2018 at 11:04

Dear you,

When you finish code, you please update link for me.

Thank you.