Processing: Difference between revisions

From OLPC
Jump to navigation Jump to search
Line 120: Line 120:
# cd /path/to/the/downloaded/java/rpm/
# cd /path/to/the/downloaded/java/rpm/
# ./jre-1_5_0_13-linux-i586-rpm.bin
# ./jre-1_5_0_13-linux-i586-rpm.bin

*'''Enable Java in Opera'''
Start Opera, open the Opera menu, go to Tools->Preferences. Click the advanced Tab and select the content section. Check the Enable Java checkbox. Click the Java Options button, and enter /usr/java/jre1.5.0_13/lib/i386/ in the text field.

<ref name="opera">[[Opera]]</ref>

*'''Setting the paths'''
Open .bashrc in a text editor.
# nano /home/olpc/.bashrc

Add the lines:
export JAVA_HOME=/usr/java/jre1.5.0_13/
export PATH=$PATH:$JAVA_HOME/bin

<ref>OLPC runs Processing and Arduino, [http://villamil.org/?p=106 villamil.org/?p=106], 04/17/2010


===XO-1.5===
===XO-1.5===

Revision as of 18:46, 17 September 2010

Processing

Processing IDE

Processing is a tool consisting of a Java framework and a mini IDE. The framework allows the fast development of visual, animated, interactive sketches. An empty window for example is created without requiring the user to write a single line of code. The commands to create graphical elements, such as rectangles or ellipses, are short and easy to use. It is easy to color and animate these elements. Furthermore, methods to catch a variety of interaction events are provided.

Processing exporting an applet

The framework is well documented, but the documentation is currently available in English only. The User Interface is simple and similar to Pippy’s. One of its biggest advantages though, is the huge user and contributor base that provides many plugins for the simplification of a wide variety of tasks. For further information see <ref group="nb">www.processing.org</ref>. As Processing is based on Java it requires the existence of a Java Runtime. It is not necessary to install this Runtime separately though, as Processing for Linux brings its JRE along. This makes Processing a rather large install, about 160 MB<ref group="nb">Including the OpenCV plugin and examples</ref> , which causes problems with the XOs' limited resources. Having installed Processing on release 10.1.2 build os852 leaves about 140 MB of free disk<ref group="nb">The term disk will be used as a convenient way to address any form of mass storage</ref> space. This is on an otherwise clean install with an almost empty Journal on the XO-1. The situation on the XO-1.5 is far less dramatic as a lot more disk space is available. Processing’s performance on the XO-1 running build 767 and XFCE was poor but it worked. On the XO-1 running build os852 and Gnome it was intolerable. On the XO-1.5 it is not great but comparatively good. See #Performance for more details. Processing interacts with the XO’s hardware features without additional efforts. The additional buttons are recognized and can be addressed as key events, connecting to the camera via OpenCV works right away. Accessing the microphone and the speakers, using the Minim library, which is included in Processing, worked out of the box as well.



Accessing the camera via Processing and OpenCV


Mobile Processing

Mobile Processing is a derivate of Processing that allows to create sketches for mobile phones. It is currently available for Windows and Mac OS only. According to its website<ref group="nb">mobile.processing.org</ref> the project is no longer significantly active.



Alternatives to Processing

Regarding Processing’s problematic size and performance, some alternatives have been examined as well.

Processing derivates

Apart from currently being not more than a proof of concept, Python Processing appeared to be promising. Python is installed on the XOs anyway as Sugar is based on it. Having a closer look, it shows that it worsens the problem as it just wraps around Processing using Jython and thus requires Java plus Jython. Similar scenario for Ruby Processing and Scala Processing. <ref>i.document » Blog Archive » python processing proof of concept, http://goo.gl/opyT, Retrieved: 07/18/2010</ref> <ref>Neat Graphics with Scala Processing | The Scala Programming Language, http://goo.gl/jUKI, Retrieved: 07/18/2010</ref> <ref>jashkenas's ruby-processing at master - GitHub, http://goo.gl/BwPm, Retrieved: 07/18/2010</ref>


OpenFrameworks

OpenFrameworks is the C++ equivalent to Processing. Unlike Processing it does not provide its own simplified IDE, but requires an installation of either XCode on Mac OS, Visual Studio or Code::Blocks on Windows, or Code::Blocks on Linux.

Installation

XO-1

The following steps describe the necessary steps to install Processing on build 767. It is advised to read #Performance before following these steps. To install Processing on build os852/Gnome follow the steps as described for the XO-1.5. This is not recommended though, due to its poor #Performance.

XFCE

As Processing is not sugarized, an additional Desktop system needs to be installed. Available lightweight desktops are XFCE <ref group="nb">www.xfce.org</ref> and LXDE <ref group="nb">lxde.org</ref>. Installing XFCE on the XO was straight forward. To add a convenient way of switching back and forth between XFCE and Sugar, some additional tweaks are necessary. Compared to e.g. Gnome, XFCE is rather ugly. It is more lightweight though and thus better suitable for an installation on the XO-1. Installing LXDE has not been examined.

  • Open the Terminal
  • Get root user privileges
$ su
#

Using sudo instead of su is considered more secure and thus recommended if it is available. In contrary to su, sudo enables the root user for the current command only and thus needs to be repeated in front of most of the following commands. If you are following these steps using su you are advised to leave the superuser level by calling exit before you switch to other tasks.

  • Install XFCE using yum
# yum install xfdesktop xfce-utils xfce-mcs-plugins xfce4-session xfce4-icon-theme
  • Set XFCE as the default desktop

Switch to the /home/olpc/ directory and copy the file .xsession-example to .xsession

# cd /home/olpc/
# cp .xsession-example .xsession
  • Open the new file with your favorite text editor
# nano .xsession

Find the line that says: #exec xterm and add the following code below: exec startxfce4 Save and exit nano (Ctrl-x) and restart X (CTRL+ALT+BACKSPACE), starting XFCE. If the system stops during the boot process, just type startxfce into the prompt.

  • Prevent getting stuck in the boot animation

Switch to /etc/init.d and open the file 0-boot-anim-start in your favorite text editor.

# cd /etc/init.d/
# nano 0-boot-anim-start

Search for the line that reads "# i'm the child". Replace if os.fork() == 0: with if os.fork() == 'debug':

  • Install a desktop switcher control panel in Sugar to switch between Sugar and XFCE and integrate a Sugar control panel to switch the other way round

Install the necessary files using yum and rpm.

# yum install gnome-icon-theme
# rpm -ivh http://dev.laptop.org/~cscott/xfce/sugar-xfce-control-0.2-1.noarch.rpm  
# rpm -ivh http://dev.laptop.org/~cscott/xfce/sugar-mcs-plugin-1.1.0-1.fc9.i386.rpm

Open the file /usr/share/icons/sugar/index.theme in a text editor

# nano /usr/share/icons/sugar/index.theme

Add Inherits=gnome after the line [Icon Theme]

Open /usr/bin/olpc-session in a text editor

# nano /usr/bin/olpc-session

and add

[ -f "$HOME/.xsession-xfce" ] && . "$HOME/.xsession-xfce"

before the line

exec /usr/bin/ck-xinit-session

Watch out for the spaces.

<ref>XFCE</ref> <ref>XFCE and Sugar</ref>

Switching from Sugar to XFCE and back

Firefox / Opera

Having installed the desktop system, the next step is to install a browser. This is an important step as Processing’s documentation is available in HTML format, online and offline. Installing Firefox failed with: Missing Dependency: gecko-libs 1.9.0.11. Several proposed solutions have been tried. None of them worked. Therefore it was decided to install Opera instead, which worked fine. After the installation Opera will ask you to upgrade to a newer version. Don't do it.

# rpm -ivh ftp://ftp.opera.com/pub/opera/linux/964/final/en/i386/static/opera-9.64.gcc4-static-qt3.i386.rpm

<ref>Opera</ref>

Java

Installing Java actually is not necessary to run Processing. Processing for Linux comes with its own version of Java. So the following steps can be omitted. Considered the available disk space on the XO, it is recommended not to install the additional JRE. The price that has to be paid for this is that you cannot run the exported applications or applets. You can run the sketches from within Processing though.

To install the JRE follow these instructions: Only JRE 1.5 is working in this setting. <ref>Restricted formats</ref> Get jre-1_5_0_13-linux-i586-rpm.bin at java.sun.com/products/archive/j2se/5.0_13/ Click on the link Download JRE, select Linux as platform, agree to the license, and click continue. Download the RPM. Switch to the terminal. If you do not have root privileges still, get root privileges. Change to the directory where you downloaded the JRE installer. Run the installer.

# cd /path/to/the/downloaded/java/rpm/
# ./jre-1_5_0_13-linux-i586-rpm.bin
  • Enable Java in Opera

Start Opera, open the Opera menu, go to Tools->Preferences. Click the advanced Tab and select the content section. Check the Enable Java checkbox. Click the Java Options button, and enter /usr/java/jre1.5.0_13/lib/i386/ in the text field.

<ref name="opera">Opera</ref>

  • Setting the paths

Open .bashrc in a text editor.

# nano /home/olpc/.bashrc

Add the lines: export JAVA_HOME=/usr/java/jre1.5.0_13/ export PATH=$PATH:$JAVA_HOME/bin

<ref>OLPC runs Processing and Arduino, villamil.org/?p=106, 04/17/2010

XO-1.5

Performance

Notes

<references group="nb" />

References

<references />