Intelix, TouchOSC and Processing

As mentioned in a previous post, I use the Intelix 4×4 matrix switch for distributing HDMI video throughout the house. The only issue (not a major one) is the remote for switching between sources is never close to where I’m sitting, whereas my iPad or my wife’s iPhone is always within arms reach.

The switch can be controlled by one of the following methods

  • Infrared, this is how the remote works, utilizing an IR eye on the front of the TV which routes the IR to the matrix switch via the balun etc. an IR blaster could be used, but I don’t really want to go down this route.
  • RS-232, the switch has a port on the back which can be used to control the switch via simple commands. Hands up those with a spare RS-232 port on their computer, or any RS-232 port for that matter. I could get a USB to RS-232 adaptor, I already use one for talking to the home security system.
  • LAN, the Intelix 4×4 has a standard lag port an can be controlled remotely via the same simple commands used with RS-232, but from anywhere, no new hardware needed!!

So, network control it is. Now I had to figure out how to connect the iPad (or iPhone) up to the matrix switch. While I’m a software guy, I’m not too experienced programming for OSX, something I want to rectify, but finding the time …

Options:

  • Learn Objective C, long term goal!
  • Use MonoTouch, this looks great, leverages my C# and .Net knowledge and prototyping is free, the downside is that to be able to get the applications on the iPad rather than the emulator would cost $199.  I created a prototype, classes etc. that allow me to interrogate the matrix switch and change sources, but the last step of getting the app on the iPad … too expensive for replacing a single remote control.
  • On Hackaday.com I came across an article about controlling an Arduino with TouchOSC, this seemed promising. Control the Arduino from the iPad, have the Arduino talk to the switch via either the RS-232 or an Ethernet shield. Then the lightbulb lit up. Between TouchOSC and the Arduino was some Processing code, why pass the messages to the Arduino when Processing could talk to the Intelix switch directly.

Final Solution:

iPad/iPhone running TouchOSC ($4.99 on the app store), free TouchOSC editor, and 5 minutes to create the user interface and have it running on the iPad.

Processing module, first running on my Macbook Pro (did all this sitting on the sofa) then on the home control PC (the longest part of all this was un-zipping Processing on the  PC). which used an OSC library to receive the commands from the TouchOSC application and allow me to do stuff in Processing. The code opens a network connection to my switch and sends commands when buttons are pressed on the iPad.

Total cost, $4.99 for the iPad software, 20 minutes of my time coding and configuring. Now I have control from both the iPad and iPhone.

import processing.serial.*;
import processing.net.*;
import oscP5.*;
import netP5.*;

OscP5 oscP5;
int alphaValue;
Serial arduinoPort;
Client intelixClient;
byte[] byteBuffer = new byte[20];

float v_push1 = 0.0f;
float v_push2 = 0.0f;
float v_push3 = 0.0f;
float v_push4 = 0.0f;
float v_push5 = 0.0f;
float v_push6 = 0.0f;
float v_push7 = 0.0f;
float v_push8 = 0.0f;

void setup() {
    size(320, 440);
    frameRate(25);

    oscP5 = new OscP5(this, 8000);
    intelixClient = new Client(this, "x.x.x.x", 23);
}

void oscEvent(OscMessage theOscMessage)
{
    String addr = theOscMessage.addrPattern();
    float val = theOscMessage.get(0).floatValue();

    if (addr.equals("/1/push1")) {
        v_push1 = val;
    }
    else if (addr.equals("/1/push2")) {
        v_push2 = val;
    }
    else if (addr.equals("/1/push3")) {
        v_push3 = val;
    }
    else if (addr.equals("/1/push4")) {
        v_push4 = val;
    }
    else if (addr.equals("/1/push5")) {
        v_push5 = val;
    }
    else if (addr.equals("/1/push6")) {
        v_push6 = val;
    }
    else if (addr.equals("/1/push7")) {
        v_push7 = val;
    }
    else if (addr.equals("/1/push8")) {
        v_push8 = val;
    }
}

void SendCommand(String command)
{
    intelixClient.write(command);
}

void draw() {
    background(0);
    if (intelixClient.available() > 0) {
        // Read in the bytes
        int byteCount = intelixClient.readBytes(byteBuffer);
        if (byteCount > 0 ) {
           // Convert the byte array to a String
           String myString = new String(byteBuffer);
           // Show it text area
           println(myString);
        }
    }

    fill(0);
    stroke(0, 196, 168);
    rect(17, 21, 287, 55);
    rect(17, 369, 60, 50);
    rect(92, 369, 60, 50);
    rect(168, 369, 60, 50);
    rect(244, 369, 60, 50);

    fill(0, 196, 168);
    if (v_push1 == 1.0f) {
        rect(22, 374, 50, 40);
        SendCommand("a09");
    }

    if (v_push2 == 1.0f) {
        rect(97, 374, 50, 40);
        SendCommand("a1D");
    }

    if (v_push3 == 1.0f) {
        rect(173, 374, 50, 40);
        SendCommand("a1F");
    }

    if (v_push4 == 1.0f) {
        rect(249, 374, 50, 40);
        SendCommand("a0D");
    }

    /* Code for other 4 buttons here */
}
This entry was posted in hardware, Home Automation, Network, software and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">