Monday, December 11th 2017, 1:02am UTC+1

You are not logged in.

  • Login
  • Register

ErWin

Beginner

Date of registration: May 13th 2016

Posts: 2

1

Friday, May 13th 2016, 10:04am

Stop a running Timer

Hello Segger Forum,

with a simple Testprojet with WM and widgets I see no solution for a task.

In a dialog box, I use three slider and four buttons. The buttons have BMPs
for the pressed and unpressed condition. One button is always in the pressed state. Pressing another button
switches the active state on the new button. For this I use the button callback NotififationCode
BUTTON_RELEASE and turn there, the corresponding button States. At the same time on any renewed pressure on the button, the three sliders
to their Defauldparameter was setting. This works fine.


Now I will open for each button a help window when the button a little longer (1-2sec.) Remains actuated.
Although the starting a timer with NC button-clicks works, but has the disadvantage that, once started Timer
can not be restarted during rapid change to another button. This would require the NotififationCode button release the running timer
be deleted or restarted. This works but unfortunately not.

My Codesnipped WM_NOTIFY_PARENT
//Start the Timer by Button Click
case ID_BUTTON1:
switch(NCode) {
case WM_NOTIFICATION_CLICKED :
helpTimer = WM_CreateTimer(WM_GetClientWindow(pMsg->hWin), 0, HELPTIME, 0);
...


My Codesnipped WM_TIMER
// Open the Helpwindow by Timer
case WM_TIMER:
InfoWin = WM_CreateWindow(20,30,440, 150, WM_CF_SHOW,_cbGeoInfo,sizeof(Data));
break;



Does somebody has any idea. Thank you very much.

This post has been edited 1 times, last edit by "ErWin" (May 13th 2016, 10:09am)


amit251291

Beginner

Date of registration: Oct 28th 2015

Posts: 65

2

Friday, May 13th 2016, 3:50pm

Hi,
I think you need to create a Help Window if button is pressed for some HELP_TIME. Is my understanding correct ? If not please correct me.
In your case, Timer will always be created on your every touch on the button. And on every timer expiry a new window will be created. Just imagine, what would happen if one presses a button say 100 times in HELP_TIME :pinch:


The correct implementation would be having some flag before your create and delete a timer. If timer is expired and you did not get Release Notification then its a Long press. You can have a flag and monitor it while creating the timer and on Release to achieve this.

ErWin

Beginner

Date of registration: May 13th 2016

Posts: 2

3

Friday, May 13th 2016, 5:16pm

Hi amit251291,

thanks for your Answer.

I have testing your solution and it works. But i have a second problem.

By Release Notification from a Button i set "BUTTON_SetPressed(hItem, 1)" to show the Picture for Button-Press always.
But now i can't press this Button a second Time to set the Sliders to the defauldvalues. A pressed Button can't send a Click-Notifcation a second time ?(

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 438

4

Wednesday, May 18th 2016, 3:32pm

Hi ErWin,

you can overwrite the BUTTON widgets callback routine. This way you can define how the button should look like and or behave. This way you might achieve the behavior you are looking for.

Please have a look into the emWin user manual chapter 18.2.3 "Overwriting callback functions".

Regards,
Sven