I want to use Edit Widget with two buttons for changing values Up and Down.
In attachment is example and it works but it change value only for one when I press Up or Down button.
I need auto increment or decrement function if I press and hold Up or Down button.
I try to implement auto repeat function with use of WM_CreateTimer() and it works but not as I want.
When I press Up or Down Button first time, first pause before Button repeat should be 500msec and all next pauses before Button repeat should be 100msec.
Timer function is not included in attached example.
I need suggestion how to implement button auto repeat function.
Thanks
Display All
In attachment is example and it works but it change value only for one when I press Up or Down button.
I need auto increment or decrement function if I press and hold Up or Down button.
I try to implement auto repeat function with use of WM_CreateTimer() and it works but not as I want.
When I press Up or Down Button first time, first pause before Button repeat should be 500msec and all next pauses before Button repeat should be 100msec.
Timer function is not included in attached example.
I need suggestion how to implement button auto repeat function.
Thanks
C Source Code
- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.14 *
- * Compiled Jan 12 2012, 10:28:50 *
- * (c) 2011 Segger Microcontroller GmbH & Co. KG *
- * *
- **********************************************************************
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- */
- // USER START (Optionally insert additional includes)
- // USER END
- #include "DIALOG.h"
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define ID_WINDOW_0 (GUI_ID_USER + 0x06)
- #define ID_EDIT_0 (GUI_ID_USER + 0x07)
- #define ID_BUTTON_0 (GUI_ID_USER + 0x08)
- #define ID_BUTTON_1 (GUI_ID_USER + 0x09)
- // USER START (Optionally insert additional defines)
- // USER END
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static data)
- // USER END
- /*********************************************************************
- *
- * _aDialogCreate
- */
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
- { WINDOW_CreateIndirect, "EditTest", ID_WINDOW_0, 0, 0, 320, 240, 0, 0, 0 },
- { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 90, 40, 130, 40, 0, 5, 0 },
- { BUTTON_CreateIndirect, "-", ID_BUTTON_0, 50, 120, 80, 20, 0, 0, 0 },
- { BUTTON_CreateIndirect, "+", ID_BUTTON_1, 180, 120, 80, 20, 0, 0, 0 },
- // USER START (Optionally insert additional widgets)
- // USER END
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static code)
- // USER END
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- int Id, NCode;
- // USER START (Optionally insert additional variables)
- // USER END
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Edit'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
- EDIT_SetText(hItem, "1000");
- EDIT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER);
- EDIT_SetFont(hItem, GUI_FONT_D24X32);
- EDIT_SetFloatMode(hItem, 0 , 0 , 99.99, 2, 2);
- EDIT_SetCursorAtChar(hItem , 3);
- //
- // Initialization of '-'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
- BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
- BUTTON_SetFocussable(hItem,0);
- //
- // Initialization of '+'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
- BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
- BUTTON_SetFocussable(hItem,0);
- // USER START (Optionally insert additional code for further widget initialization)
- // USER END
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch(Id) {
- case ID_EDIT_0: // Notifications sent by 'Edit'
- switch(NCode) {
- case WM_NOTIFICATION_CLICKED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- case WM_NOTIFICATION_RELEASED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- case WM_NOTIFICATION_VALUE_CHANGED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- // USER START (Optionally insert additional code for further notification handling)
- // USER END
- }
- break;
- case ID_BUTTON_0: // Notifications sent by '-'
- switch(NCode) {
- case WM_NOTIFICATION_CLICKED:
- // USER START (Optionally insert code for reacting on notification message)
- GUI_SendKeyMsg(GUI_KEY_DOWN, 1); // Send a key message to the focussed window
- // USER END
- break;
- case WM_NOTIFICATION_RELEASED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- // USER START (Optionally insert additional code for further notification handling)
- // USER END
- }
- break;
- case ID_BUTTON_1: // Notifications sent by '+'
- switch(NCode) {
- case WM_NOTIFICATION_CLICKED:
- // USER START (Optionally insert code for reacting on notification message)
- GUI_SendKeyMsg(GUI_KEY_UP, 1); // Send a key message to the focussed window
- // USER END
- break;
- case WM_NOTIFICATION_RELEASED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- // USER START (Optionally insert additional code for further notification handling)
- // USER END
- }
- break;
- // USER START (Optionally insert additional code for further Ids)
- // USER END
- }
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * CreateEditTest
- */
- WM_HWIN CreateEditTest(void);
- WM_HWIN CreateEditTest(void) {
- WM_HWIN hWin;
- hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, WM_HBKWIN, 0, 0);
- return hWin;
- }
- // USER START (Optionally insert additional public code)
- void MainTask(void)
- {
- GUI_Init();
- CreateEditTest();
- while(1)
- GUI_Exec();
- }
- // USER END
- /*************************** End of file ****************************/