Author Topic: Announcing: a Graphical switch sender and lamp visualizer (for OSC mode)  (Read 11823 times)

MOcean

  • P3 Developers
  • *
  • Posts: 822
  • Michael Ocean
    • View Profile
https://github.com/mjocean/OscSwitchMatrixGUI

What is it?
A wxPython-based Graphical switch matrix that lets you send switch events to the OSC mode for PyProcGame, and receive lamp updates from the game, visualized on top of an image of the playfield.

The tool reads your machine yaml for switch definitions. Left click a switch to toggle it (mouse down for active, mouse up for inactive), and right click to turn it on. 

Turn on layout mode to position your switches and lamps

Turn on lamp updates (and set the update rate) to see the lamps "light up" on your playfield image.

Minimally run with:
Code: [Select]
python switchMatrixClient.py -y [your_yaml_file] -p [port_of_OSC_server]

This has been tested with Williams machines and PDB boards. Both switch number types are supported.

You will need:
1) a working PyProcGame game with the OSC mode from Brian. Read more: http://www.pinballcontrollers.com/forum/index.php?topic=983.0

2) wxPython. http://www.wxpython.org/download.php

Notes/Etc:
I've been toying with this idea for a while.  I needed to learn some Python GUI programming and and when I saw the conversation about a graphical switch matrix to send switch inputs, I decided to make one.  To be clear, I already love this tool and am totally addicted to it.  I thought the OSC mode coupled with the tablet app was great, but I think this is much better.

Grid-mode, switches only:



For graphical mode, run with:
Code: [Select]
python switchMatrixClient.py -y [your_yaml_file] -i [playfield_image.png]

Enjoy!

- Michael
« Last Edit: March 20, 2015, 04:21:38 PM by MOcean »

Curbfeeler

  • Wizard
  • *****
  • Posts: 239
  • Dan - Des Moines, IA
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #1 on: December 24, 2014, 03:48:51 PM »
This thing is really amazing!  I was lucky enough to test out an early version of it, and for desktop development (heck, even in a real game when you don't want to lift the playfield and try to reach the impossible switch), it's just what the doctor ordered.  Thanks so much Michael for just a great tool for our toolboxes.

Dan

Brian Madden

  • Wizard
  • *****
  • Posts: 498
  • Mission Pinball
    • View Profile
    • Mission Pinball
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #2 on: December 26, 2014, 02:35:35 AM »
Whoa dude this is great. Nice!

I like that this is standalone so you can run it in its own window or even on a different computer. Really it's like a desktop OSC client written in Python which means we can customize it like crazy.

Awesome.
Brian
The Mission Pinball Framework (MPF) Project*
Twitter
* Disclaimer: MPF is a work-in-progress!

MOcean

  • P3 Developers
  • *
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #3 on: December 26, 2014, 07:57:24 AM »
Glad you like it. I thought you might :)

If nothing else, it's easier than remembering where on unlabeled keyboard or unlabeled OSC app where each switch is.

Dan already has me working on showing the switches in arbitrary positions on top of a Playfield image. The locations can be in the yaml without pyprocgame noticing, so this isn't that hard on me, but is still annoying for a user to have to specify where the switches should sit (physically). I'm trying to work out an interactive mode to store locations but I'm not too keen on  changing someone's yaml file yet.

This is part of my larger, crazy person plan of creating a "new game wizard" which I can't do without a gui framework. wxPython is easily the best I've found by a mile. Had I used this when I was working on my dmd paint software, I might not have scrapped it.

Brian Madden

  • Wizard
  • *****
  • Posts: 498
  • Mission Pinball
    • View Profile
    • Mission Pinball
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #4 on: December 26, 2014, 12:38:00 PM »
For the "New Game Wizard," have you heard of Dabo? It's a 3-tier desktop application framework for Python. (It uses wxPython for the display tier and then adds a business logic and data tier.) I've been thinking about a GUI config file tool too, an it would be cool to put business rules (probably also configured via the YAML files) in the app, so drop downs could populate with device lists, you could maybe automatically change the behavior of clicking switches depending on how they were tagged, different options would be enabled/disabled/set to default depending on other settings, etc. (For the data tier I was just thinking I'd use the Python dictionary.. so it won't be ODBC but I think it will be easy enough to hook it in so it can read and save values to/from the business tier.)

Anyway if you're going to be adding more functionality to this, maybe worth checking out? http://dabodev.com/

Brian
The Mission Pinball Framework (MPF) Project*
Twitter
* Disclaimer: MPF is a work-in-progress!

MOcean

  • P3 Developers
  • *
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #5 on: December 29, 2014, 02:37:03 PM »
Here's a preview of the latest (optional) feature I'm working on now: switches laid out on an image of a playfield.  Hoping to have this nailed down in the next day or two.  This screenshot shows the graphical layout helper that helps a user build a switch location layout (only needs to be done once).


bonnevil69

  • P3 Developers
  • *
  • Posts: 698
  • Matthew Bonnema
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #6 on: December 29, 2014, 02:49:32 PM »
wow   very cool    I am always hitting the wrong key on the keyboard      Thanks for putting the time in to make this
DeadPin and Doom

Brian Madden

  • Wizard
  • *****
  • Posts: 498
  • Mission Pinball
    • View Profile
    • Mission Pinball
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #7 on: December 29, 2014, 02:53:37 PM »
Yeah way better than my old solution: :)
Brian
The Mission Pinball Framework (MPF) Project*
Twitter
* Disclaimer: MPF is a work-in-progress!

bonnevil69

  • P3 Developers
  • *
  • Posts: 698
  • Matthew Bonnema
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #8 on: December 29, 2014, 03:02:08 PM »
haha Brian    mine was even worse   a cheat sheet that i always lose when i need it    ;D
DeadPin and Doom

Curbfeeler

  • Wizard
  • *****
  • Posts: 239
  • Dan - Des Moines, IA
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #9 on: December 29, 2014, 03:59:23 PM »
Oh yeah!  That's gonna be boss.  Thanks so much for making it.

MOcean

  • P3 Developers
  • *
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #10 on: December 30, 2014, 11:35:27 AM »
Latest version is checked into GitHub.  Adding the graphical layout, editor, and yaml support was... fun?
Code: [Select]
1 file changed, 448 insertions(+), 170 deletions(-)

Eek.



You still need to specify a yaml file (of course) but now you can start in graphical mode by specifying a playfield image (with -i); if you save your layout (use the layout editor from the menu, then save), you can re-run later with that layout as -l (thats a lower-case "L") and it will bring back all your layout info.

When you first run with a playfield image and no layout file (i.e., new layout) it just dumps all the switches in the top left corner of the image.

Let me know if you find bugs.  I tested against my own yaml file and a pdb yaml file and both seem happy.

Enjoy!!
- Michael

Curbfeeler

  • Wizard
  • *****
  • Posts: 239
  • Dan - Des Moines, IA
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #11 on: December 30, 2014, 03:12:29 PM »
Ummmm.... Seriously?  This is AMAZING!


MOcean

  • P3 Developers
  • *
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #12 on: December 30, 2014, 03:47:27 PM »
Glad to see it put to use so soon :)

If it's not obvious, you can also extend the size of the image of the playfield (wide) and use an image editor to add some labels for service switches, or I guess if you're feeling extra fancy you can add pictures of the service button assembly, coin door, etc. 

Mark Jarzewiak

  • Wizard
  • *****
  • Posts: 244
  • Mark Jarzewiak
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #13 on: December 30, 2014, 06:14:12 PM »
Any good place to get images of playfields like the pinbot one.  I wish I had a low res, but decent image of cyclone from Stu as it would come in handy setting up an illustrator file for laying out changes in VP.  The one I grabbed from the VP table is distorted wide quite a bit.

Curbfeeler

  • Wizard
  • *****
  • Posts: 239
  • Dan - Des Moines, IA
    • View Profile
Re: Announcing: a Graphical switch sender (for OSC mode)
« Reply #14 on: December 30, 2014, 06:52:28 PM »
http://www.vpforums.org/index.php?app=downloads&showfile=2734 is prob your best bet for that game.

EDIT:  These playfield images are put out there to be resources for VP table makers, but it's also an option in VP to export the playfields back out from the game.  Not very hard to do.

Dan
« Last Edit: December 30, 2014, 06:57:08 PM by Curbfeeler »