PiFace scratch integration sucks, so I rewrote it.

The python script for rpi/scratch integration was not only buggy but just o utright unusable. I did what any self-respecting coder would do in that si tuation. I rewrote it and threw in the kitchen sink (in the form of a Star Trek TNG "LCARS" interface)

formatting link

This requires Java 8, and if you want to run the GUI mode from the Pi then you'll need a display physically connected (LVDS/HDMI) and you'll have to d rop the OpenJFK bits in the Java install directory (google it)

How this works: First you clone the git repo and then build using Maven an d Java 8. Once you've built this from source you wind up with a jar file i n the target folder. Executing is simply: "java -jar piface-integration-1.

0.jar [options...]" where [options...] are the command line options. This will invoke the launcher with the modes you specify

The launcher takes several options, the most useful of which are -? or -h a nd these provide full help in case you need it.

There are two modes, gui or text. Text does not require JavaFX and is idea l for running a headless integration in conjunction with the server option.

Next you should specify if you want to connect to the Scratch mesh or not. If you don't then use --nomesh to disable it. Otherwise you can provide h ost:port with -m

There are three piface connections you can choose from: Local, Client, or M ock. Local means you are running this from a Pi and are physically hooked up to a PiFace module. Consequently this option also requires you run the program as root. Client mode lets you connect to another piface-integratio n server using the -r option to provide host:port. Finally Mock lets you f ake it like you are hooked up to a Piface but you're really not. This is u seful for testing or just launching GUI with a fancy TNG interface to make people think you're doing something really out of this world (see also: Mov ie OS)

Lastly, if you want to allow other programs to connect to this instance the n specify --server and -p to specify the port you are listening in on.

That covers launching it, now here's some combinations of using it:

Option 1: All-in-one. You just launch it with default options (no paramete rs) and this produces a JavaFX GUI and tries to connect to scratch running on the same machine. If you are using the Pi with a monitor hooked up to i t and don't need the scratch part then it could be useful but you should sp ecify --nomesh so it doesn't try to connect to Scratch.

Option 2: Client/server. Run the integrator on the Pi using --server --tex t --nomesh and on the client using --gui --client -r RPI_IP:1701. Also lau nch Scratch on the client machine and host the mesh network from there.

Option 3: Impress your friends: Run this from a PC using --gui --mock and t hen launch scratch to toggle the outputs up and down

Option 4: Ghost in the machine -- Like Option 2 except also specify --serve r on the client machine. Then go to a third machine while someone is using the client and start sending requests to the client at port 1701 to change the outputs. This will confuse them and make them think the computer is f reaking out. Also modify the code to be sensitive to various broadcast mes sages from scratch and connect directly to scratch and send your own broadc asts on the same mesh. These will show up on the integrator GUI as alerts too.

Oh, and I should explain the variables used in scratch:

out0..out7 are outputs. 0 = off. Anything >0 = on. pwm0..pwm7 are PWM encoded outputs. 0 = off. 100 = fully on. Everyth ing in between is relative to that scale. The PWM timer is a bit funky for a few seconds when it starts but it levels off decently after the JIT opti mizer kicks in. Java's like that, sorry (not sorry.)

Signals from the PI are provided on in0..in7

I will be adding broadcast support for things like "all stop" and so on to fit the theme but it's a work in progress. Stay tuned!

I'll be updating the site with more information, screenshots, etc. Please fork and submit pull requests if you find ways to make it better. Also sub mit issues if you find things that are not working right. I think I got mo st of the bugs out.

Live Long and Prosper!

-Brendan

Reply to
Brendan Robert
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.