mpf
mpf copied to clipboard
Advice on config builder for lights
(I was going to post this to MPF Users, but figured it might be better here)
The last two games I've done, my process has been to get all the hardware (mechs, lights, switches) installed, then start wiring. In each situation, I've done lights first, but without noting which lights are which in a usable way when building a config. (Mainly this is because the order inevitably changes as I splice something in.) So, where I build the config as I wire up each switch and coil, my lights are not documented.
What I'd like to do, and what I'm working on now, is to make a mode that lets me step through each light with the flipper buttons (forward and backward) so I can see which light is in which position. Currently, all the lights have generic names based on their config number, like l_0-1 or l_2-13.
I moved a scriptlet that Brian and I worked on for BnD into my Attract mode code and updated it for Python 3 (yeah, it was THAT old!). I've got it stepping through lights and showing the config name in the MC window. As it is, I can move through each light and write down the "real" name so I can edit config later.
What I'd like to do, though, is be able to type in the new name and have it build out a new config that I could copy and paste into my machine config. I could do that with the old script using the raw_input() function, but so much has changed about MPF that it's not feasible anymore (even if I use the Python 3 input() function).
Is there any way at all to get a text input field? I can do the job with what I have in an hour, so it's not that big of a deal, but if it would be useful for others (say, as a separate light_config mode or something), I can put more work into it. I just don't know how to proceed. I know Kivy has a textbox function, but I don't know if we can use it or how.
Anyway, thought I'd ask you guys and see what you think. You can see the mode code I've got working at: https://github.com/GabeKnuth/HPpin/blob/master/modes/attract/code/attract.py
Thanks!
Hi Gabe,
I like the idea!
Have a look at the service mode. It already supports cycling through lights. Also have a look at the service cli: http://docs.missionpinball.org/en/dev/tools/service_cli/index.html.
What do you think about building a command like tool like "mpf config light add your_light number"? Similar to how ruby on rails or other frameworks scaffold/edit configs. We can instantiate our yaml lib in write mode which would maintain all comments and whitespaces.
What do you think?
Jan
Interesting. I'll take a look and see if I can follow along. Might be over my head, but I'll see what I can put together. This could work for switches, too. In either case, you still need to build the generic config, but then you could step through the lights or hit a switch to edit its name.
What about using Monitor? The text fields that show the light names already appear editable if you double click on it, it's just that changing them does nothing. We have the code in there to add X/Y position to the config...can we do something similar to change the name?
Monitor would work as well. I would like to have such a tool. I can support you with any BCP calls or yaml editing. I'm very bad at building GUIs and I don't like it. I can help with anything else. We probably have to restart after adding/editing switches.
Ok, cool. That's where I wanted to do it first. The mode thought was kind of a compromise. You still have to be in front of the machine for either of these, but I like the point & click interface. People can use a generic lights config that just goes from l_0-1 to l_3-63 (in the case of Fast) and start from there.
To do this, at least two things need to happen:
- You need to be able to turn on a light in the Monitor Device Tree. Default 'on' color should be fine.
- Double clicking on the light name and changing it needs to save it to config.
For #2, that change probably has to happen in two steps. Maybe the changes you make only appear in Monitor and aren't actually saved to config until you click a button. Can this be done while still preserving white space? Would it make more sense to have have the double-click operation bring up the entire config for that light so you can adjust all the parameters (default color, tags, etc.)?
I've never looked through the Monitor code before. I'll see what I can figure out, but don't hold your breath. I've never been much of a coder :) However, I do think I'd make an ok UI designer, so maybe this will work out!
We probably need a button to start service mode in the monitor. At least currently some actions only work in service mode.
Since we're talking about cracking open Monitor, it would probably make sense to incorporate your monitor_to_config script functionality and put the X/Y coords into config, too.
Also, by "I'd make an ok UI designer," I mean I think I know what would work well...not necessarily how to do it :) I've got some time, though, so I can take a peek.