### Setup MPF Directory and Clone Examples Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/install/virtual-machine/basic-guide.md Create a dedicated directory for MPF and clone the official MPF examples repository to get started. ```shell cd ~ mkdir mpf cd mpf git clone https://github.com/missionpinball/mpf-examples ``` -------------------------------- ### Run Demo Man Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/install/virtual-machine/basic-guide.md Execute the Demo Man example to verify MPF and MPF-MC are installed and running correctly. This command starts both the core framework and the media controller. ```shell cd ~/mpf/mpf-examples/demo_man mpf both -X ``` -------------------------------- ### Run Complete Example Configuration Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/tutorials/legacy_mc/10_run_a_game.md Execute this command from the specified directory to run the complete config.yaml file for the tutorial. This is useful for comparing your setup or testing the tutorial's state. ```doscon C:\mpf-examples\tutorial>mpf both -X ``` -------------------------------- ### Complete MPF Configuration Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/mechs/troughs/classic_single_ball.md This is a comprehensive configuration file example that includes switch definitions, virtual platform settings, coil configurations, ball device setups for drain and plunger lane, and playfield definition. ```yaml #config_version=5 switches: s_drain: number: 01 s_plunger: number: 02 virtual_platform_start_active_switches: s_drain coils: c_drain_eject: number: 03 default_pulse_ms: 20 ball_devices: bd_drain: ball_switches: s_drain eject_coil: c_drain_eject eject_targets: bd_plunger_lane tags: drain, home, trough eject_timeouts: 3s bd_plunger_lane: ball_switches: s_plunger mechanical_eject: true eject_timeouts: 5s playfields: playfield: default_source_device: bd_plunger_lane tags: default ``` -------------------------------- ### MPF Version Output Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/install/linux/xubuntu.md Example output of the 'mpf --version' command, showing the installed MPF version. The actual version number may vary. ```text username@host:~$ mpf --version MPF v0.33.13 ``` -------------------------------- ### Run MPF Demo Man Test Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/install/linux/raspberry.md Navigate to the demo_man directory and start MPF to test the installation with the demo game. ```shell cd ~/mpf-git/mpf-examples/demo_man mpf both -X ``` -------------------------------- ### Running the VirtualBox Guest Additions Installer Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/install/virtual-machine/basic-guide.md Navigate to the mounted CD directory and execute the Guest Additions installation script. The --nox11 flag is used to prevent X11 from starting. ```shell cd /mnt/cdrom sudo sh ./VBoxLinuxAdditions.run --nox11 ``` -------------------------------- ### Run MPF Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/tutorials/legacy_mc/12_add_ball_devices.md Execute the MPF example for this tutorial step by navigating to the example directory and running the 'mpf both' command. ```doscon C:\mpf-examples\tutorial>mpf both ``` -------------------------------- ### Complete Hardware Configuration Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/opp/cobrapin/cobrapin_serial_segment_displays.md A comprehensive MPF configuration file demonstrating the definition of NeoSeg displays, their arrangement into logical segment displays, and color correction profiles for brightness adjustment. This setup enables the use of a 'segment_display_player' for displaying text on events. ```yaml #config_version=5 hardware: platform: opp driverboards: gen2 segment_displays: light_segment_displays #create light group for each NeoSeg display neoseg_displays: neoSeg_0: start_channel: 0-0-0 size: 8digit light_template: type: w subtype: led color_correction_profile: NeoSeg_orange neoSeg_1: start_channel: 0-0-120 size: 8digit light_template: type: w subtype: led color_correction_profile: NeoSeg_white neoSeg_7: start_channel: 0-0-660 size: 2digit light_template: type: w subtype: led color_correction_profile: NeoSeg_blue neoSeg_8: start_channel: 0-0-690 size: 2digit light_template: type: w subtype: led color_correction_profile: NeoSeg_red #use light groups to arrange into a segment display segment_displays: neoSegTop: number: 1 size: 16 integrated_dots: true use_dots_for_commas: true default_transition_update_hz: 30 platform_settings: light_groups: - neoSeg_0 - neoSeg_1 type: 14segment neoSegBot: number: 1 size: 4 integrated_dots: true use_dots_for_commas: true default_transition_update_hz: 30 platform_settings: light_groups: - neoSeg_8 - neoSeg_7 type: 14segment #use color_correction_profile whitepoint to adjust the brightness of each #NeoSeg display light_settings: color_correction_profiles: NeoSeg_red: whitepoint: [.8, .8, .8] NeoSeg_white: whitepoint: [.55, .55, .55] NeoSeg_blue: whitepoint: [.5, .5, .5] NeoSeg_orange: whitepoint: [.9, .9, .9] NeoSeg_yellow: whitepoint: [1, 1, 1] NeoSeg_green: whitepoint: [.5, .5, .5] ``` -------------------------------- ### Example Timer Configuration (Skillshot Mode) Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/timers.md Demonstrates a timer that starts when a ball enters the playfield and another timer used for rotating skillshot targets. One timer has a start value and tick interval, while the other only has a tick interval and is set to start automatically. ```yaml ##! mode: mode1 timers: mode_timer: start_value: 3 end_value: 0 direction: down tick_interval: 1s control_events: - event: balldevice_playfield_ball_enter action: start start_running: false target_rotator: start_running: true tick_interval: 1s ``` -------------------------------- ### Complete MPF Configuration with Virtual Trough Setup Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/mechs/troughs/classic_single_ball_no_shooter_lane.md This is a complete MPF configuration example that includes switch, coil, and ball device definitions, along with the `virtual_platform_start_active_switches` setting to ensure the trough is full in virtual mode. ```yaml #config_version=5 switches: s_drain: number: 01 coils: c_drain_eject: number: 03 default_pulse_ms: 20 ball_devices: bd_drain: ball_switches: s_drain eject_coil: c_drain_eject tags: drain, home, trough eject_timeouts: 3s playfields: playfield: default_source_device: bd_drain tags: default virtual_platform_start_active_switches: s_drain ``` -------------------------------- ### SmartMatrix Example Configuration Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/smartmatrix.md This configuration file can be used to test your SmartMatrix setup. Ensure the `smartmatrix:port:` is updated to match your Teensy's connection. Do not use `-x` or `-X` options when running MPF with this config. ```yaml hardware: rgb_dmd: smartmatrix displays: window: # on screen window width: 600 height: 200 dmd: # source display for the DMD width: 128 height: 32 default: true round_anchor_x: left window: width: 600 height: 200 title: Mission Pinball Framework smartmatrix: smartmatrix_1: port: com5 # this will most likely be a different port for you baud: 2500000 old_cookie: false rgb_dmds: smartmatrix_1: brightness: .2 slides: window_slide_1: # slide we'll show in the on-screen window - type: display # this widget shows the DMD content in this slide too effects: - type: color_dmd width: 512 height: 128 - type: text text: MISSION PINBALL FRAMEWORK anchor_y: top y: top-3 font_size: 30 color: white - type: rectangle width: 514 height: 130 color: 444444 dmd_slide_1: # slide we'll show on the physical DMD - type: text text: IT WORKS! font_size: 30 color: red slide_player: init_done: window_slide_1: target: window dmd_slide_1: target: dmd ``` -------------------------------- ### Basic Light Configuration and Player Setup Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/mechs/lights/index.md This configuration defines LEDs, their properties, and how to control them via events in the light_player. It includes examples for direct color setting, named colors, group control, and fading effects. Use keyboard keys 1-5 to trigger different light events. ```yaml #config_version=5 hardware: platform: opp driverboards: gen2 opp: ports: /dev/ttyACM0, /dev/ttyACM1 lights: led_strip_0_led_1: number: 0-0-1 subtype: led type: rgb tags: group1 led_strip_0_led_2: number: 0-0-2 subtype: led type: rgb tags: group1 led_strip_0_led_3: previous: led_strip_0_led_2 subtype: led type: rgb tags: group1 light_player: led_code: led_strip_0_led_1: DFFF00 led_off: led_strip_0_led_1: off led_strip_0_led_2: off led_strip_0_led_3: off led_name: led_strip_0_led_1: LightSalmon group_light: group1: green led_fade: led_strip_0_led_1: color: slateblue fade: 2000ms keyboard: 1: event: led_off 2: event: led_code 3: event: led_name 4: event: group_light 5: event: led_fade ``` -------------------------------- ### Install MPF and Verify Source: https://context7.com/missionpinball/mpf-docs/llms.txt Commands to create a virtual environment, install MPF using pip, and verify the installation. ```shell python -m venv mpf-venv source mpf-venv/bin/activate # Linux/macOS mpf-venv\Scripts\activate.bat # Windows pip install mpf --pre pip install mpf mpf --version ``` -------------------------------- ### setUp() Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/code/api_reference/testing_class_api/MpfBcpTestCase.md Sets up the test environment. ```APIDOC ## setUp() ### Description Setup test. ``` -------------------------------- ### Example Version Conflict Error Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/install/linux/xubuntu.md This error indicates an incompatible version of `ruamel.yaml` is installed, preventing MPF from starting. Check your installed MPF, MPF-MC, and MPF-Monitor versions and ensure they are compatible. ```doscon pkg_resources.VersionConflict: (ruamel.yaml 0.15.37 (c:\\users\\robert\\appdata\\local\\programs\\python\\python36\\lib\\site-packages), Requirement.parse('ruamel.yaml<0.11,>=0.10') ``` -------------------------------- ### Run MPF MC from mpf-examples Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/install/windows.md Navigate to the 'demo_man' directory within the 'mpf-examples-0.57.x' folder and run this command to start the MPF Media Controller. This is useful for testing the MC's loading process and BCP server functionality. ```doscon mpf mc ``` -------------------------------- ### Get Counter Start Value Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/code/api_reference/devices/counters.md Returns the initial value from which the counter started counting. ```python get_start_value() -> int ``` -------------------------------- ### Example Response for Get Segment Display Count (0x06) Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/lisy/protocol.md An example illustrating the response to the Get Segment Display Count command, showing that the platform supports 6 segment displays numbered 0 to 5. ```text ----------------------------------------------------------------------- Byte Length Example Comment ----------- ----------- ----------- ----------------------------------- 0 1 6 Platform supports 6 segment displays with numbers 0 to 5. ----------------------------------------------------------------------- ``` -------------------------------- ### Run MPF Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/tutorials/legacy_mc/14_add_a_mode.md Execute the complete MPF configuration file from the tutorial's example directory. Ensure you are in the correct directory before running. ```doscon C:\\mpf-examples\\tutorial_step_14>mpf both ``` -------------------------------- ### Clone and Install MPF-MC Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/install/linux/raspberry.md Clone the MPF-MC repository and install it using pip. This is the initial setup for MPF-MC. ```shell git clone -b 0.56.x https://github.com/missionpinball/mpf-mc.git ~/mpf-git/mpf-mc cd ~/mpf-git/mpf-mc pip install -e . ``` -------------------------------- ### Example Response for Get Changed Switches (0x29) Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/lisy/protocol.md An example response indicating that switch 10 has been turned off. ```text ----------------------------------------------------------------------- Byte Length Example Comment ----------- ----------- ----------- ----------------------------------- 0 1 10 Switch 10 turned off ----------------------------------------------------------------------- ``` -------------------------------- ### Initialize and Configure OPP Board via gen2test.py Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/opp/oppcombo/index.md Command-line examples for initializing, configuring, and saving settings for an OPP board using the gen2test.py utility. ```shell ./gen2test.py --serial 0 ./gen2test.py --config opp16o16icfg.py ./gen2test.py --save ``` -------------------------------- ### MPF Command Not Found Error (Mac/Linux) Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/tutorials/legacy_mc/2_creating_a_new_machine.md This error indicates MPF is not installed correctly or not in your PATH. Ensure MPF is installed properly by following the installation guide again. ```shell $ mpf -bash: mpf: command not found ``` -------------------------------- ### Define Switches and Start Active Switches Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/virtual_platform_start_active_switches.md Define your switches in the 'switches:' section and then list which ones should start as active in 'virtual_platform_start_active_switches:'. This example starts two switches as active. ```yaml switches: s_ball_switch1: number: s_ball_switch2: number: s_ball_switch3: number: # Start with two (virtual) balls virtual_platform_start_active_switches: - s_ball_switch1 - s_ball_switch2 ``` -------------------------------- ### Info Lights Configuration Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/info_lights.md This example shows how to configure various info lights, mapping them to specific light devices. It covers match lights, ball indicators, player indicators, tilt, and game over lights. ```yaml #! lights: #! match00: #! number: #! match10: #! number: #! match20: #! number: #! match30: #! number: #! match40: #! number: #! match50: #! number: #! match60: #! number: #! match70: #! number: #! match80: #! number: #! match90: #! number: #! bip1: #! number: #! bip2: #! number: #! bip3: #! number: #! bip4: #! number: #! bip5: #! number: #! player1: #! number: #! player2: #! number: #! tilt: #! number: #! gameOver: #! number: info_lights: match_00: light: match00 match_10: light: match10 match_20: light: match20 match_30: light: match30 match_40: light: match40 match_50: light: match50 match_60: light: match60 match_70: light: match70 match_80: light: match80 match_90: light: match90 ball_1: light: bip1 ball_2: light: bip2 ball_3: light: bip3 ball_4: light: bip4 ball_5: light: bip5 player_1: light: player1 player_2: light: player2 tilt: light: tilt game_over: light: gameOver ``` -------------------------------- ### initialize Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/code/api_reference/hardware_platforms/virtual.md Initializes the virtual hardware platform. ```APIDOC ## initialize() -> None ### Description Initialise platform. ``` -------------------------------- ### MPF Command Not Recognized Error (Windows) Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/tutorials/legacy_mc/2_creating_a_new_machine.md This error means MPF is not installed correctly or not added to your system's PATH. Revisit the MPF installation guide. ```doscon C:\pinball\your_machine>mpf 'mpf' is not recognized as an internal or external command, operable program or batch file. ``` -------------------------------- ### Configure Light with 'start_channel' Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/lights.md Example for configuring a light using 'start_channel' and 'type' when MPF cannot automatically determine the internal address and channel count. Consult your platform's manual for details. ```yaml lights: led_0: start_channel: 0-0 subtype: led type: rgbw ``` -------------------------------- ### SmartMatrix Configuration Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/smartmatrix.md This example shows a basic SmartMatrix configuration, including hardware selection, port and baud rate settings, and display dimensions. Ensure your hardware section is set to 'smartmatrix' and define your display's width and height. ```yaml #config_version=5 hardware: rgb_dmd: smartmatrix smartmatrix: my_smartmatrix: port: com4 baud: 4000000 displays: dmd: width: 128 height: 32 rgb_dmds: my_smartmatrix: hardware_brightness: .5 ``` -------------------------------- ### Lisy Protocol: Example Response to 0x07 - Get Segment Display Details Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/lisy/protocol.md An example of the response bytes received after requesting segment display details. It indicates the display type and its segment width. ```text ----------------------------------------------------------------------- Byte Length Example Comment ----------- ----------- ----------- ----------------------------------- 0 1 1 Segment display is a BCD7 display 1 1 12 Segment display is 12 segments wide ----------------------------------------------------------------------- ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/missionpinball/mpf-docs/blob/main/README.md Run a local web server to preview the documentation site. The site will be accessible at http://localhost:8000. ```bash mkdocs serve ``` -------------------------------- ### Lisy Protocol: Example Command 0x07 - Get Segment Display Details Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/lisy/protocol.md An example of the command bytes sent to request segment display details. It shows the command code and the index of the display to query. ```text ----------------------------------------------------------------------- Byte Length Example Comment ----------- ----------- ----------- ----------------------------------- 0 1 7 Command 7 - Get Segment Display Details 1 1 0 Query the first display ----------------------------------------------------------------------- ``` -------------------------------- ### Light Player Configuration Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config_players/light_player.md Configure lights and their behavior in response to an event using the light_player section in your configuration file. ```yaml #! lights: #! led1: #! number: #! led2: #! number: light_player: some_event: led1: color: red fade: 200ms led2: color: ff0000 fade: 2000ms ``` -------------------------------- ### Run MPF Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/tutorials/legacy_mc/11_add_coils_switches.md This command allows you to run the MPF example configuration for step 11. It's useful for comparing your current configuration with a working example. ```doscon C:\\mpf-examples\\tutorial>mpf both -X ``` -------------------------------- ### Mode Configuration for Ball Events Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/game_logic/ball_start_end.md Configure mode start events and queue relay player actions for ball starting and ending sequences. Use `ball_will_start` for initial setup and `ball_started` for normal mode operation. ```yaml mode: start_events: ball_will_start # in normal mode use ball_started instead priority: 200 queue_relay_player: ball_starting: post: start_ball_starting_show wait_for: mode_ball_starting_show_ended ball_ending: post: start_ball_ending_show wait_for: mode_ball_ending_show_ended ``` -------------------------------- ### Setup Test Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/code/api_reference/testing_class_api/MpfBcpTestCase.md Standard setup method for tests. ```python self.setUp() ``` -------------------------------- ### initialize Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/code/api_reference/hardware_platforms/fast.md Initializes the FAST platform. ```APIDOC ## initialize() ### Description Initializes the platform. ``` -------------------------------- ### Complete Ball Device Configuration Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/mechs/troughs/two_coil_one_switch.md This example provides a comprehensive configuration for both the drain and trough ball devices, including their respective switches, coils, capacities, and timeouts. It serves as a reference for a typical two-coil, one-switch trough setup. ```yaml switches: s_drain: number: 1 s_trough_enter: number: 2 coils: c_drain_eject: number: 3 default_pulse_ms: 20 c_trough_release: number: 4 default_pulse_ms: 20 ball_devices: bd_drain: ball_switches: s_drain eject_coil: c_drain_eject eject_targets: bd_trough tags: drain eject_timeouts: 4s bd_trough: entrance_switch: s_trough_enter entrance_switch_full_timeout: 500ms ball_capacity: 3 eject_coil: c_trough_release tags: trough, home eject_timeouts: 3s ``` -------------------------------- ### Basic Autofire Coil Configuration Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/autofire_coils.md This example shows a basic setup for autofire coils, linking switches to coils for automatic firing. ```yaml switches: s_left_sling: number: 1 s_right_sling: number: 2 coils: c_left_sling: number: 1 default_pulse_ms: 10ms c_right_sling: number: 2 default_pulse_ms: 10ms autofire_coils: left_sling: coil: c_left_sling switch: s_left_sling right_sling: coil: c_right_sling switch: s_right_sling ``` -------------------------------- ### Configure lights using start_channel and type Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/lights.md Use 'start_channel' and 'type' to define the first channel and let MPF sequentially map colors. The 'previous' key can chain lights, allowing MPF to calculate channel numbers automatically. ```yaml lights: rainbow_star: # this will use red: 9-29, green: 9-30 and blue: 9-31 type: rgb start_channel: 9-29 rainbow_star2: # this will use red: 9-33, green: 9-32 and blue: 9-34 type: grb # notice the changed order here previous: rainbow_star ``` -------------------------------- ### Install and enable pigpiod service Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/rpi.md Install the pigpiod service and enable it to run at startup. This service must be running for MPF to control RPi GPIOs. ```shell apt install pigpiod systemctl enable pigpiod.service systemctl start pigpiod.service ``` -------------------------------- ### Configure Machine Settings Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/opp/cobrapin/index.md Set fundamental machine parameters such as the number of balls installed and the minimum number of balls required to start a game. ```yaml machine: balls_installed: 3 #How many balls are physically in your game min_balls: 3 #How few balls can be accounted for before you can start a game ``` -------------------------------- ### initialize Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/code/api_reference/hardware_platforms/spike.md Initialise platform. ```APIDOC ## initialize() ### Description Initialise platform. ### Method `initialize` ``` -------------------------------- ### Event Player for Super Jets Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/cookbook/AFM_super_jets.md Configure event triggers for starting or restarting the Super Jets mode. This setup handles the 'Super_Jets_Go' and 'Super_Jets_Go_Again' events. ```yaml event_player: Super_Jets_Go: start_mode_super_jets Super_Jets_Go_Again: start_mode_super_jets ``` -------------------------------- ### Start Interactive Monitor Tool Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/running/commands/index.md Launch the interactive monitor tool. This requires a separate installation and is used for development tasks alongside a running MPF game. ```shell $ mpf monitor ``` -------------------------------- ### Install MPF from Source Source: https://context7.com/missionpinball/mpf-docs/llms.txt Steps to clone the MPF repository, checkout a specific branch, and install it in editable mode. ```shell git clone https://github.com/missionpinball/mpf cd mpf git checkout 0.80.x pip install -e . ``` -------------------------------- ### Define Transitions for a State Machine Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/state_machines.md Example of defining transitions between states in a state machine. Transitions are triggered by events and can include actions when starting, stopping, or transitioning. ```yaml ##! mode: my_mode state_machines: my_state: states: start: label: Start state step1: label: show_when_active: show: on show_tokens: None events_when_started: step1_start events_when_stopped: step1_stop step2: label: Step2 transitions: - source: start target: step1 events: state_machine_proceed - source: step1 target: step2 events: state_machine_proceed2 events_when_transitioning: going_to_step2 - source: step2 target: start events: state_machine_proceed3 - source: step1, step2 target: start events: state_machine_reset ``` -------------------------------- ### Complete MPF Configuration for Trough and Playfield Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/mechs/troughs/modern_mechanical.md This is a comprehensive configuration example that includes switch, coil, ball device, and playfield settings for a typical trough setup. ```yaml switches: s_trough1: number: 2 s_trough2: number: 3 s_trough3: number: 4 s_trough4: number: 5 s_trough5: number: 6 s_trough6: number: 7 s_trough_jam: number: 8 s_plunger: number: 10 virtual_platform_start_active_switches: s_trough1, s_trough2, s_trough3, s_trough4, s_trough5, s_trough6 coils: c_trough_eject: number: 4 default_pulse_ms: 20 ball_devices: bd_trough: ball_switches: s_trough1, s_trough2, s_trough3, s_trough4, s_trough5, s_trough6, s_trough_jam eject_coil: c_trough_eject tags: trough, home, drain jam_switch: s_trough_jam eject_coil_jam_pulse: 15ms eject_targets: bd_plunger eject_timeouts: 3s bd_plunger: ball_switches: s_plunger mechanical_eject: true eject_timeouts: 5s playfields: playfield: default_source_device: bd_plunger tags: default ``` -------------------------------- ### Example raspberry_pi Configuration Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/raspberry_pi.md This is an example of how to configure the raspberry_pi section in your MPF configuration file. ```yaml raspberry_pi: ip: localhost port: 8888 ``` -------------------------------- ### FAST DMD Example Configuration Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/hardware/fast/dmd.md This configuration file sets up the FAST hardware platform, defines display properties for both the on-screen window and the physical DMD, and configures slides to be displayed. Ensure you update the `ports` to match your actual hardware. ```yaml hardware: platform: fast fast: ports: com3, com4, com5 # be sure to change this to your actual ports driverboards: fast displays: window: # on screen window width: 600 height: 200 dmd: # source display for the DMD width: 128 height: 32 default: true window: width: 600 height: 200 title: Mission Pinball Framework source_display: window dmds: my_dmd: brightness: 1.0 slides: window_slide_1: # slide we'll show in the on-screen window - type: display effects: - type: dmd dot_color: ff5500 width: 512 height: 128 - type: text text: MISSION PINBALL FRAMEWORK anchor_y: top y: top-3 font_size: 30 - type: rectangle width: 514 height: 130 color: 444444 dmd_slide_1: # slide we'll show on the physical DMD - type: text text: IT WORKS! font_size: 25 slide_player: init_done: window_slide_1: target: window dmd_slide_1: target: dmd ``` -------------------------------- ### Configure Machine Ball Settings Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/machine.md Use this snippet to set the total number of balls installed and the minimum required to start a game. Defaults are provided if these settings are omitted. ```yaml machine: balls_installed: 6 min_balls: 3 ``` -------------------------------- ### Timer Control Events Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/timer_control_events.md Configure control events for a timer. When specific events are posted, actions like start, reset, or add time are performed on the timer. ```yaml ##! mode: mode1 timers: my_timer: direction: down start_value: 10 tick_interval: 125s control_events: - event: start_my_timer action: start - event: reset_my_timer action: reset - event: add_5_secs action: add value: 5 ``` -------------------------------- ### Run MPF Examples Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/tutorials/legacy_mc/7_trough.md Command to run the MPF examples from the tutorial folder. This is useful for testing configurations, especially when using the 'virtual' platform. ```doscon C:\mpf-examples\tutorial>mpf both ``` -------------------------------- ### Configure Servo Reset Events Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/servos.md Override the default reset events for a servo. By default, 'ball_starting' is a reset event. This example prevents the servo from resetting on ball start. ```yaml #! servos: #! servo1: #! number: 1 reset_events: machine_reset_phase_3, ball_will_end, service_mode_entered ``` -------------------------------- ### Shot Configuration Example with Show Tokens Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/shots.md Demonstrates how to configure a shot with a profile and use show tokens to dynamically replace placeholder values in shows. This is useful for creating reusable shows. ```yaml #! switches: #! switch1: #! number: ##! mode: mode1 shot_profiles: flash: states: - name: unlit show: "off" - name: lit show: "flash" shots: shot1: switch: switch1 profile: flash show_tokens: leds: led1 ``` -------------------------------- ### initialize Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/code/api_reference/hardware_platforms/opp.md Initializes connections to OPP hardware. This is a crucial first step before interacting with the hardware. ```APIDOC ## initialize ### Description Initialise connections to OPP hardware. ### Method `initialize()` ``` -------------------------------- ### Basic Multiball Lock Configuration Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/multiball_locks.md This example shows the basic setup for a multiball lock named 'bunker'. It specifies the number of balls to lock and the associated ball device. ```yaml #! switches: #! s_ball1: #! number: #! coils: #! c_eject: #! number: ball_devices: bd_bunker: eject_coil: c_eject ball_switches: s_ball1 ##! mode: mode1 multiball_locks: bunker: balls_to_lock: 3 lock_devices: bd_bunker ``` -------------------------------- ### Line Widget Points Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/mc/widgets/line.md Illustrates how to define the 'points' setting for a line widget, specifying start and end coordinates for a single line or multiple points for a complex path. ```yaml points: 10, 10, 200, 50, 300, 200 ``` -------------------------------- ### Bezier Points Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/mc/widgets/bezier.md Illustrates how to define the points for a bezier curve. The first and last pairs are the start and end points, respectively, with intermediate pairs defining control points. ```yaml points: 10, 10, 200, 50, 300, 200 ``` -------------------------------- ### Define States for a State Machine Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/state_machines.md Example of defining states for a state machine, including labels and show conditions. The first state must be 'start' unless 'starting_state' is specified. ```yaml ##! mode: my_mode state_machines: my_state: states: start: label: Start state step1: label: show_when_active: show: on show_tokens: None events_when_started: step1_start events_when_stopped: step1_stop step2: label: Step 2 transitions: ``` -------------------------------- ### Configure Lights, Counters, and Light Player Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/game_logic/logic_blocks/integrating_logic_blocks_and_lights.md Define lights, counters, and their behavior using the light_player. This example shows how to turn on specific lights as a counter's value increases. ```yaml lights: l_chest_matrix_green_2: number: l_chest_matrix_green_3: number: l_chest_matrix_green_4: number: l_chest_matrix_green_5: number: counters: my_counter: starting_count: 0 count_complete_value: 5 count_events: count_up light_player: "{device.counters.my_counter.value > 0}": l_chest_matrix_green_5: green "{device.counters.my_counter.value > 1}": l_chest_matrix_green_4: green "{device.counters.my_counter.value > 2}": l_chest_matrix_green_3: green "{device.counters.my_counter.value > 3}": l_chest_matrix_green_2: green ``` -------------------------------- ### Configure a Stepper Motor Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/steppers.md Example configuration for a stepper motor, including its number, homing mode, and named positions. This setup is typically placed in the main machine configuration file. ```yaml # main config p_roc: use_separate_thread: true pd_led_boards: 6: use_stepper_0: true stepper_speed: 1352400000 # Determine empiricall. Increasing slows pulsesrate switches: s_stepper_home: number: 4/0/5 steppers: ramp_diverter: number: 6-0 homing_mode: switch homing_switch: s_stepper_home homing_direction: clockwise pos_min: 0 # Default. (Neg values are behind home) pos_max: 100 # Default reset_events: machine_reset_phase_3, ball_starting, ball_will_end reset_position: 0 # Default debug: true named_positions: 2: move_to_2 25: move_to_25 45: move_to_45 ##! mode: base # base mode timers: test_diverter: start_value: 0 end_value: 6 start_running: true restart_on_complete: true event_player: timer_test_diverter_tick{device.timers.test_diverter.ticks==1}: move_to_2 timer_test_diverter_tick{device.timers.test_diverter.ticks==3}: move_to_25 timer_test_diverter_tick{device.timers.test_diverter.ticks==5}: move_to_45 ``` -------------------------------- ### Configure Drop Target Bank Reset Events Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/mechs/targets/drop_targets/fixing_drop_target_reset_issues.md This example configures a drop target bank to attempt resetting up to three times on ball start. MPF will not reset targets if they are already up. ```yaml drop_targets: front: switch: s_drop_front middle: switch: s_drop_middle back: switch: s_drop_back drop_target_banks: vuk_bank: drop_targets: front, middle, back reset_coils: c_drop_reset reset_on_complete: 1s reset_events: ball_started.1: 0 ball_started.2: 1s ball_started.3: 2s machine_reset_phase_3: 0 ``` -------------------------------- ### Example Switch Configuration Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/logs/CFE-ConfigValidator-2.md This YAML snippet demonstrates a valid configuration for a switch, including its number, label, and custom tags. It serves as a reference for correct setting names. ```yaml switches: s_flipper_left: number: 1 label: My Left Flipper Switch Example tags: some_custom_tag ``` -------------------------------- ### MPF Automated Test Example Source: https://context7.com/missionpinball/mpf-docs/llms.txt Demonstrates writing automated tests for MPF using MpfTestCase, including starting the game, simulating switch hits, and asserting game state changes. ```python # tests/test_my_game.py from mpf.tests.MpfTestCase import MpfTestCase class TestMyGame(MpfTestCase): def get_config_file(self): return 'config' # loads config/config.yaml def get_machine_path(self): return '../' # relative to this test file def test_skill_shot(self): # Start MPF in virtual mode self.start_game() # Ball starts: plunger lane is active self.assertTrue(self.machine.ball_devices['bd_plunger'].balls == 1) # Simulate switch hit self.hit_switch_and_run('s_inlane_left', 0.1) # Assert event was posted self.assertEventCalled('skill_shot_hit') # Assert player variable was set self.assertEqual(50000, self.machine.game.player['score']) def test_multiball_lock(self): self.start_game() self.hit_and_release_switch('s_lock_1') self.advance_time_and_run(1) self.assertEqual(1, self.machine.ball_devices['bd_lock'].balls) self.hit_and_release_switch('s_lock_1') self.advance_time_and_run(1) self.assertEventCalled('multiball_start') ``` -------------------------------- ### Switch Player Configuration Example Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/config/switch_player.md This example demonstrates how to configure the switch_player to replay a sequence of switch events. It includes defining switches and then specifying the steps for the player, including timing, switch names, and actions. ```yaml #config_version=5 switches: s_test1: number: x: 0.4 y: 0.5 z: 0 s_test2: number: x: 0.6 y: 0.7 s_test3: number: plugins: switch_player switch_player: start_event: test_start steps: - time: 100ms switch: s_test1 action: activate - time: 600ms switch: s_test3 action: hit - time: 100ms switch: s_test1 action: deactivate - time: 1s switch: s_test2 action: activate - time: 1s switch: s_test3 action: hit - time: 100ms switch: s_test2 action: deactivate - time: 1s switch: s_test3 action: hit ``` -------------------------------- ### Super Jets Setup Mode Configuration Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/cookbook/AFM_super_jets.md This configuration defines the 'super_jets_setup' mode, including start events, shots, shot groups, counters, and event/variable players for controlling super jets. ```yaml ##! mode: super_jets_startup #config_version=5 mode: start_events: ball_starting priority: 200 shots: jets: switch: s_right_bumper, s_left_bumper, s_middle_bumper right_rollover: switch: s_right_rollover show_tokens: light: l_right_rollover left_rollover: switch: s_left_rollover show_tokens: light: l_left_rollover shot_groups: rollover_lanes: shots: right_rollover, left_rollover rotate_left_events: s_left_flipper_active rotate_right_events: s_right_flipper_active reset_events: rollover_lanes_lit_complete: 1s counters: lb_jets_count: count_events: jets_hit starting_count: 0 count_complete_value: 100 count_interval: 1 direction: up persist_state: true events_when_complete: Super_Jets_Go debug: true lb_jets_resume: enable_events: mode_base_started{current_player.sj_active>0} count_events: jets_hit starting_count: 0 count_complete_value: 25 count_interval: 1 direction: up persist_state: false events_when_complete: Super_Jets_Resume_Go debug: true reset_on_complete: true lb_rollover_complete_count: count_events: rollover_lanes_complete events_when_hit: rollover_lanes_done starting_count: 0 count_complete_value: 40 reset_on_complete: false direction: up persist_state: false event_player: Super_Jets_Go: start_mode_super_jets Super_Jets_Go_Again: start_mode_super_jets variable_player: s_left_bumper_active: score: 1000000 + (device.counters.lb_rollover_complete_count.value * 50000) s_middle_bumper_active: score: 1000000 + (device.counters.lb_rollover_complete_count.value * 50000) s_right_bumper_active: score: 1000000 + (device.counters.lb_rollover_complete_count.value * 50000) rollover_lanes_complete: score: 1000 mode_super_jets_started: sj_active: int: 1 action: set show_player: mode_super_jets_setup_started{current_player.sj_active>0}: Super_Jets_on: show_tokens: lights: l_super_jets ``` -------------------------------- ### Build Production Bundle Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/finalization/software.md Create pre-compiled configuration bundles for faster MPF startup in production. Recreate these files after any changes to configuration, modes, or shows. ```shell mpf build production_bundle ``` -------------------------------- ### Example MPF Light Show Source: https://github.com/missionpinball/mpf-docs/blob/main/docs/tools/showcreator.md This YAML defines a simple light show where three lights sequentially turn blue over one second. It's useful for basic animations or as a starting point for more complex shows. ```yaml ##! show: my_show #show_version=5 - duration: .25 lights: l_arrow_1: off l_arrow_2: off l_arrow_3: off - duration: .25 lights: l_arrow_1: blue l_arrow_2: off l_arrow_3: off - duration: .25 lights: l_arrow_1: blue l_arrow_2: blue l_arrow_3: off - duration: .25 lights: l_arrow_1: blue l_arrow_2: blue l_arrow_3: blue ```