A look at getting the Processing programming language and IDE up and running on a Raspberry Pi, and example code working with the TI Chronos eZ430 development kit.
Processing is a programming language that is targeted at “non-programmers” and with a particular focus on artists and designers. But the Processing syntax and IDE will be familiar to many more as they form the basis of the Arduino development environment, and Processing applications are similarly referred to as “sketches”.
Built on top of the Java programming language, Processing provides a much simplified syntax and graphics programming model. And as with Arduino development it can be extended via libraries that make easy work of more advanced things like network programming.
Installing prerequisites on Raspbian/Debian
A JDK is required in order to run Processing but the preferred sun Java 6 JDK is not available for ARM so we have to make do with OpenJDK 6. And if you want to write sketches that talk to a serial port the RXTX library will also be required. These can be installed with:
$ sudo apt-get install openjdk-6-jdk librxtx-java
Setting up Processing
The Linux release of Processing needs to be downloaded and can be extracted to any convenient location. This assumes Intel architecture and so the bundled JVM will have to be deleted and an ARM version of the native RXTX serial port code copied across. To achieve this the following two commands should be run from inside the top level directory of the Processing software:
$ rm -rf java
$ cp /usr/lib/jni/librxtxSerial.so modes/java/libraries/serial/library/linux32/
The first step is required so that the script for launching Processing picks the JVM we have installed rather than attempting to use the Intel architecture one bundled with the software.
The second step is a bit of a hack and there may be a cleaner way of getting Processing to use the RXTX libraries in /usr/lib without having to copy them across to overwrite the bundled libraries.
At this point the Processing IDE can be started up with:
Since the preferred Sun JDK 6 is not being used there will be a warning message on startup but it should be safe to ignore this.
Reading the Chronos eZ430 accelerometers
Oliver Smith has developed a Processing sketch that graphs accelerometer data from a TI Chronos eZ430, but I didn't have much success getting this working and so I tried a simpler example that he'd based his sketch upon and which just outputs accelerometer readings as text.
Although this didn't work straight away either and I had to replace the line:
chronos = new Serial(this, Serial.list(), 115200);
chronos = new Serial(this, "/dev/ttyACM0", 115200);
A fix borrowed from Oliver's sketch!
For information on using the Chronos eZ430 with a Raspberry Pi and the TI supplied software and Python applications see an earlier post.
The user friendly nature of the Arduino owes a great deal to Processing, which provides a rich and approachable environment for the non-programmer, and a great platform for quickly creating highly visual applications that combine elements of network and device input/output.
It should be possible to get Oliver's Chronos accelerometer graphing application running with a little debugging, but I was only really interested in seeing if I could access the watch over the RF link from with Processing running on a Raspberry Pi.Like this Leave a Comment