self.machine.coils.*

class mpf.devices.driver.Driver(machine: mpf.core.machine.MachineController, name: str)

Bases: mpf.core.system_wide_device.SystemWideDevice

Generic class that holds driver objects.

A 'driver' is any device controlled from a driver board which is typically the high-voltage stuff like coils and flashers.

This class exposes the methods you should use on these driver types of devices. Each platform module (i.e. P-ROC, FAST, etc.) subclasses this class to actually communicate with the physical hardware and perform the actions.

Args: Same as the Device parent class

Accessing coils in code

The device collection which contains the coils in your machine is available via self.machine.coils. For example, to access one called "foo", you would use self.machine.coils.foo. You can also access coils in dictionary form, e.g. self.machine.coils['foo'].

You can also get devices by tag or hardware number. See the DeviceCollection documentation for details.

Methods & Attributes

Coils have the following methods & attributes available. Note that methods & attributes inherited from base classes are not included here.

clear_hw_rule(switch: mpf.devices.switch.Switch)

Clear all rules for switch and this driver.

Parameters:switch -- Switch to clear on this driver.
disable(**kwargs)

Disable this driver.

enable(**kwargs)

Enable a driver by holding it 'on'.

If this driver is configured with a holdpatter, then this method will use that holdpatter to pwm pulse the driver.

If not, then this method will just enable the driver. As a safety precaution, if you want to enable() this driver without pwm, then you have to add the following option to this driver in your machine configuration files:

allow_enable: True

get_configured_driver()

Return a configured hw driver.

pulse(milliseconds: int = None, power: float = None, **kwargs)

Pulse this driver.

Parameters:
  • milliseconds -- The number of milliseconds the driver should be enabled for. If no value is provided, the driver will be enabled for the value specified in the config dictionary.
  • power -- A multiplier that will be applied to the default pulse time, typically a float between 0.0 and 1.0. (Note this is can only be used if milliseconds is also specified.)
set_pulse_on_hit_and_enable_and_release_and_disable_rule(enable_switch: mpf.devices.switch.Switch, disable_switch: mpf.devices.switch.Switch)

Add pulse on hit and enable and release and disable rule to driver.

Pulse and then enable driver. Cancel pulse and enable when switch is released or a disable switch is hit.

Parameters:
  • enable_switch -- Switch which triggers the rule.
  • disable_switch -- Switch which disables the rule.
set_pulse_on_hit_and_enable_and_release_rule(enable_switch: mpf.devices.switch.Switch)

Add pulse on hit and enable and relase rule to driver.

Pulse and enable a driver. Cancel pulse and enable if switch is released.

Parameters:enable_switch -- Switch which triggers the rule.
set_pulse_on_hit_and_release_rule(enable_switch: mpf.devices.switch.Switch)

Add pulse on hit and relase rule to driver.

Pulse a driver but cancel pulse when switch is released.

Parameters:enable_switch -- Switch which triggers the rule.
set_pulse_on_hit_rule(enable_switch: mpf.devices.switch.Switch)

Add pulse on hit rule to driver.

Alway do the full pulse. Even when the switch is released.

Parameters:enable_switch -- Switch which triggers the rule.