(home)

Learning About Arduino IDE and Jython

Introduction

In relation to some ideas around regression testing I began looking at adapting the preprocessing/compilation portion of the Arduino IDE so that it could be run from the command line.

Under the assumption it would be easier (and more fun) to be using Python rather than Java but still wanting to leverage the existing Java code I began to explore using Jython.

Project Log

( 20 March 2009 )

export CLASSPATH=/<path>/arduino-0013/Arduino\ 13.app/Contents/Resources/Java/Arduino.jar:/<path>/arduino-0013/Arduino\ 13.app/Contents/Resources/Java/oro.jar:/<path>/arduino-0013/Arduino\ 13.app/Contents/Resources/Java/antlr.jar 
from processing.app.preproc import PdePreprocessor

from processing.app import Target

theTarget = Target("/<path>/arduino-0013/hardware/cores/", "arduino")

thePreprocessor = PdePreprocessor()

theProgram = """                                                                
void setup() {                                                                  
  pinMode(13, OUTPUT);                                                          
}                                                                               

void loop() {                                                                   
  digitalWrite(13, HIGH);                                                       
  delay(100);                                                                   
  digitalWrite(13, LOW);                                                        
  delay(100);                                                                   
}                                                                               
"""

thePreprocessor.write(theProgram, "/tmp/", "foo", [], theTarget)
./jython arduino_prep.py
If a Java superclass is not explicitly initialized, its empty constructor is called at the 
completion of a Jython subclass's __init__ method. 
code@rancidbacon.com