Skip to content

Instantly share code, notes, and snippets.

@missionpinball
missionpinball / gist:5d34dcd21ce1aa906ab4
Created March 19, 2015 17:38
Config file for Demo Man pinball using the Mission Pinball Framework: 2 hours in
# Demo Man config file for MPF 0.15.2
Plugins:
- shots.ShotController
- keyboard.Keyboard
- ball_search.BallSearch
- logic_blocks.LogicBlocks
- scoring.ScoreController
- auditor.Auditor
- sound.SoundController
@missionpinball
missionpinball / gist:d455a59e507ec53ca1de
Last active August 29, 2015 14:16
MPF Scriplet to pulse a coil based on a switch activation
# Attract mode Scriptlet to fire coil
from mpf.system.scriptlet import Scriptlet
class PulseCoil(Scriptlet):
def on_load(self):
self.machine.events.add_handler('machineflow_Attract_start', self.start)
@missionpinball
missionpinball / switch_simulator.py
Created March 19, 2014 22:44
Python script to simulate switch events for a P-ROC pinball machine.
# switch_simulator.py
# By Brian Madden
# v0.1, March 19, 2014
# Requires our "OSC" game mode, see here:
# http://www.pinballcontrollers.com/forum/index.php?topic=983
import logging
logging.basicConfig(level=logging.INFO, filename="switch_simulator.log", format="%(asctime)s - %(name)s - %(message)s", datefmt="%H:%M:%S", filemode='w')
console = logging.StreamHandler()
@missionpinball
missionpinball / logplayer.py
Created March 19, 2014 15:44
This snippet plays back switch events from log files for the P-ROC pinball platform. It's useful for "replaying" games for bug hunting, testing, etc. It works with fakepinproc and with physical P-ROC games.
# logplayer.py
# By Brian Madden
# v0.1, March 19, 2014
# Plays back switch events from log files for the P-ROC pinball platform
# Requires file-based logging, see here for more info:
# http://www.pinballcontrollers.com/forum/index.php?topic=1130
# Also require's our "OSC" game mode, see here:
# http://www.pinballcontrollers.com/forum/index.php?topic=983
@missionpinball
missionpinball / int2pwm.py
Last active December 29, 2015 09:39
Convert an integer / ratio to a PWM bitmask for setting LED brightness
ratio = .7 # the ratio we'd like to convert to pwm. Must be between 0 and 1.
whole_num = 0 # tracks our whole number
output = 0 # our output 32-bit mask
count = 0 # our current count
for _i in range(32):
count += ratio
if int(count) > whole_num:
output = output | 1