mpf.core.mode_timer

class mpf.core.mode_timer.ModeTimer(machine, mode, name, config)

Parent class for a mode timer.

Parameters:
  • machine – The main MPF MachineController object.
  • mode – The parent mode object that this timer belongs to.
  • name – The string name of this timer.
  • config – A Python dictionary which contains the configuration settings for this timer.
add_time(timer_value, **kwargs)

Adds ticks to this timer.

Parameters:
  • timer_value – The number of ticks you want to add to this timer’s current value.
  • kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
change_tick_interval(change=0.0, **kwargs)

Changes the interval for each “tick” of this timer.

Parameters:
  • change – Float or int of the change you want to make to this timer’s tick rate. Note this value is added to the current tick interval. To set an absolute value, use the set_tick_interval() method. To shorten the tick rate, use a negative value.
  • **kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
kill()

Stops this timer and also removes all the control events.

pause(timer_value=0, **kwargs)

Pauses the timer and posts the ‘timer_<name>_paused’ event

Parameters:
  • timer_value – How many seconds you want to pause the timer for. Note that this pause time is real-world seconds and does not take into consideration this timer’s tick interval.
  • **kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
reset(**kwargs)

Resets this timer based to the starting value that’s already been configured. Does not start or stop the timer.

Parameters:**kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
restart(**kwargs)

Restarts the timer by resetting it and then starting it. Essentially this is just a reset() then a start()

Parameters:**kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
set_current_time(timer_value, **kwargs)

Sets the current amount of time of this timer. This value is expressed in “ticks” since the interval per tick can be something other than 1 second).

Parameters:
  • timer_value – Integer of the current value you want this timer to be.
  • **kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
set_tick_interval(timer_value, **kwargs)

Sets the number of seconds between ticks for this timer. This is an absolute setting. To apply a change to the current value, use the change_tick_interval() method.

Parameters:
  • timer_value – The new number of seconds between each tick of this timer. This value should always be positive.
  • **kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
start(**kwargs)

Starts this timer based on the starting value that’s already been configured. Use set_current_time() if you want to set the starting time value.

Parameters:**kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
stop(**kwargs)

Stops the timer and posts the ‘timer_<name>_stopped’ event.

Parameters:**kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
subtract_time(timer_value, **kwargs)

Subtracts ticks from this timer.

Parameters:
  • timer_value – The number of ticks you want to subtract from this timer’s current value.
  • **kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.
timer_complete(**kwargs)

Automatically called when this timer completes. Posts the ‘timer_<name>_complete’ event. Can be manually called to mark this timer as complete.

Parameters:**kwargs – Not used in this method. Only exists since this method is often registered as an event handler which may contain additional keyword arguments.