Let’s make a 5-digit voltmeter with a JeeNode, an Analog plug, and JeeMon. But instead of a readout on an LCD screen, I’m going to show the results on the desktop. To start with that last part, here’s my little display on a Mac:
You’re looking at my feeble attempt to create a good-looking / souped-up GUI, btw :)
Anyway. Here’s the sketch I’m running on the JeeNode, with an Analog plug inserted into port 3:
Trivial stuff. It sends out lines with “VOLT <value>” readings twice per second.
The important part is that this sketch starts up with “[analogPlug]” as greeting. To hook up to this sketch, all we need to do is create a directory called “analogPlug”, with a file called “host.tcl” in it.
This new “analogPlug” directory is a sub-directory of “JeeMon-sketches”. This directory, in turn, has been registered as being used for sketches – with this command in my main application code:
Back to the “JeeMon-sketches/analogPlug/host.tcl” file. Here’s its contents:
That’s the whole kaboodle.
Now, whenever I plug in a JeeNode running the above “analogPlug.pde” sketch, a window pops up showing readings in real-time. When I unplug the JeeNode, the window is closed again. It’s all automatic, as long as JeeMon is kept running.
This mechanism is not limited to JeeNodes or Analog plugs, of course.