If anybody would like to try programming the Arduino Uno in Java, I have been working on a project (HVM) that supports this (http://www.icelab.dk). It includes full Eclipse integration - debugging on the way.
Just for your information,
Stephan
A LED blinking program written in Java for the Arduino:
package arduino;
public class Arduino {
public static native void delay_ms(short i);
public static void main(String[] args) {
Port p = new Port(0x20);
p.DDRD = 0x20;
while (true) {
p.PORTD |= 0x20;
delay_ms((short) 400);
p.PORTD &= ~0x20;
delay_ms((short) 400);
}
}
}
And this runs on the Arduino Uno as well:
package test.icecapvm.minitests;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import devices.Console;
public class TestArrayList {
/**
* @param args
*/
public static void main(String[] args) {
args = test(args);
}
public static String[] test(String[] args) {
ArrayList<String> list = new ArrayList<String>();
list.add("hej");
list.add("med");
list.add("dig");
list.add("Stephan");
list.add("Korsholm");
Object[] array = list.toArray();
Arrays.sort(array);
list = new ArrayList<String>();
for (int i = 0; i < array.length; i++) {
list.add((String) array[i]);
}
if (array.length == 5) {
Iterator<String> sortedNames = list.iterator();
String previous = null;
String next;
while (sortedNames.hasNext()) {
next = sortedNames.next();
if (previous != null) {
if (previous.compareTo(next) > 0) {
return args;
}
}
Console.println(next);
previous = next;
}
return null;
}
return args;
}
}
janost, I don't understand when you say you need the compiler 'onboard'? Are you thinking about a JIT compiler? In that case you might want to check out the CACAO JIT compiler - which is a Java JIT for embedded systems, with a lower footprint (in terms of resource requirements) than the standard desktop Java environment from Oracle. CACAO still requires several MBs of flash and RAM though, but maybe that's fine for you. Oracle also has a JIT based Java environment for embedded systems, with a lower footprint than the desktop version. The Jamaica VM might also be an option, or the Perc Pico from Atego.
stephankorsholm:
robtillaart, I just inserted some code tags.
janost, I don't understand when you say you need the compiler 'onboard'? Are you thinking about a JIT compiler? In that case you might want to check out the CACAO JIT compiler - which is a Java JIT for embedded systems, with a lower footprint (in terms of resource requirements) than the standard desktop Java environment from Oracle. CACAO still requires several MBs of flash and RAM though, but maybe that's fine for you. Oracle also has a JIT based Java environment for embedded systems, with a lower footprint than the desktop version. The Jamaica VM might also be an option, or the Perc Pico from Atego.
The Bambino has onboard Video and keyboard ports.
A selfcontained developement platform that doesnt need a PC.
But the architecture of the AVR-chip doesnt allow it to run code stored in SRAM.
So it needs a bytecode VM if one wants to run a compiled language.
And thus a compiler onboard.
But I'll probably end up running an interpreted language.
To have a start:
From inspecting your source I see some intend to define your JVM completely in Java itself. Is that right? If so, how far you have brought that?
In addition, its funny to see, how we developed similar ideas to directly map a global C variable into JAVA space via annotating a JAVA variable with:
You -> @IcecapCVar
Me -> @NativeCVariable