mpf icon indicating copy to clipboard operation
mpf copied to clipboard

Additional control events for timers

Open toomanybrians opened this issue 8 years ago • 5 comments

Propose adding two new control events:

timed_pause: which pauses the timer for a specified amount of time, then automatically resumes.

Example is if you have a hurry up timer, but you want to pause the timer while the ball is in the pop bumpers. You want the timer to resume 1s after the last pop bumper hit, but you don't want to just +1s on every hit because that would add too much time. So it's almost a sliding window pause. (Similar to how timed switch sequences work.)

Also we need a way to add time to a timer but to respect a cap, like "add 2 but never go above 15 total" This could potentially be solved with player var limits also

toomanybrians avatar Sep 20 '16 16:09 toomanybrians

Hey, this issue is pretty old, so i was wondering whether it was actually still open? If so, i might be interested at having a look at it. Cheers

scared-fish avatar Nov 14 '21 22:11 scared-fish

Hey @scared-fish. Welcome! Looks like this has not been implemented yet. We got pause (https://github.com/missionpinball/mpf/blob/dev/mpf/devices/timer.py#L149) but not timed_pause. So this is still open :-). There is a unit test here: https://github.com/missionpinball/mpf/blob/dev/mpf/tests/test_Timer.py.

Jan

jabdoa2 avatar Nov 15 '21 00:11 jabdoa2

Hi,

I have developed a rather simple approach to the first part of the feature request and was wondering if anyone could confirm that this would work and actually cover the request:

I would add a function to timer.py (timed_pause), which really just does the same thing as the already existing pause function, but instead of calling a delay.add, I would have it call a delay.reset. This way, the pause would reset every time the function is called and resume the timer x seconds after the last call.

Regards, Lars

scared-fish avatar Nov 17 '21 23:11 scared-fish

That sounds very reasonable. Guess we have to stop the delay when disabling the timer. Also maybe on manual resume or pause.

jabdoa2 avatar Nov 18 '21 00:11 jabdoa2

[I sadly did not have much time lately (vacation etc.) to work on this issue much...]

I wanted to write a Unit test for the new function... But first I tried to understand the testing environment (or at least the test_timer.py). But I cannot even find a test for the standard pause() function. Am i missing something, or is this test missing? I kinda wanted to find that test in order to have something to lean on basically...

scared-fish avatar Nov 28 '21 23:11 scared-fish