|
|
|
|
OSC provides an intuitive way to organize the elements on the board, and specify which messages go to which parts of the board. OSC messages for the Make Controller Kit all look similar - they specify an address, and then give the value that should be sent to that address. They adhere to the format of:
/subsystem/device/property argument
Sending a message to the board is simple enough - you simply send it, and that's that. For reading values, you have two options:
We'll continue here to document the first method, sending a request message. So how does the board know whether your message is a request or a write? Write messages include an argument value, as in the example above. If a message doesn't include an argument, then the board interprets it as a request.
Example
So, to tell the board to turn on LED number one on the Application board, we would send the message
/appled/1/state 1
Notice that
If we wanted to read back the current value of the LED, we'd send the request message
/appled/1/state
Notice that we didn't send a value this time, so we expect the board to send back a message that looks like
/appled/1/state 0
if the LED is currently off, or
/appled/1/state 1
if the LED is currently turned on.
To continuously read values from the board, we simply continuously send request messages to the board.
You can also send messages to the Make Controller Kit to find out what OSC devices it knows about using the same approach as with normal OSC reads. For example, to see all the subsystems that the board knows about (the highest level of the address), send the message
/
Then when you see which subsystems the board knows about, you can ask that subsystem how many indexes it has. For the analogin system, for example, send the message
/analogin
Lastly, to find out the properties for a given index within a subsystem, you can ask for those too by sending the message
/analogin/0
This way, you always know which OSC messages your board understands and knows how to respond to.
Quite often, you'll have a situation in which you're reading or writing messages to several devices on the board. It gets pretty inefficient pretty quickly to send a separate message for each of these devices. The way around this is to use OSC bundles whenever possible.
An OSC bundle is simply a group of normal messages all wrapped up in a single bundle and sent at once. Different programming environments deal with bundles in different ways, so you'll need to check out how to create and send them in the environment you're working in. Information on how to do this should be included in the documentation for that environment.
OSC also provides a nice, flexible way to send single messages to more than one address.
One of the most frequently used methods of doing this is using the * character as a wildcard. The wildcard matches all available entries for a given element in the OSC address. So if we wanted to read all the analog ins using a single message, we would send the message
/analogin/*/value
and the board would return a bundle with messages giving us the values of each of the analog inputs. Or, if we wanted to set all the servos to the same position, we could send the message
/servo/*/position 512
You can also specify a range of values, instead of just asking for all of them. Do this by specifying the range as the lower limit followed by a hyphen, followed by the upper limit, and enclosing the range in square brackets. So, to ask for analog ins 4 through 7, we'd send the message
/analogin/[4-7]/value
and to turn off LEDs 1 through 3, we'd send the message
/appled/[1-3]/state 0
This is a very handy feature of OSC and allows us to send messages to the board more efficiently - try to use these conventions whenever possible to reduce the number of messages to and form the board. It's not too difficult to overwhelm the board with too much traffic, and these techniques help avoid that.
So where's the master list of all the OSC messages the Make Controller knows how to respond to? You can browse the documentation here for info about each of the subsystems on the board that you can communicate with via OSC.
