The first time I integrated two Tinkerforge bricklets, the day before yesterday, was pretty cool:
import com.tinkerforge.BrickMaster;
import com.tinkerforge.BrickletLCD20x4;
import com.tinkerforge.BrickletRotaryPoti;
import com.tinkerforge.IPConnection;
import java.util.Calendar;
public class TFConnectionDemo {
private static final String HOST = "localhost";
private static final int PORT = 4223;
private static final String MASTERBRICKUID = "somethingabc";
private static final String LCDUID = "somethingabc";
private static final String ROTIUID = "somethingabc";
private static IPConnection ipc;
private static BrickMaster master = new BrickMaster(MASTERBRICKUID);
private static BrickletLCD20x4 lcd = new BrickletLCD20x4(LCDUID);
private static BrickletRotaryPoti poti = new BrickletRotaryPoti(ROTIUID);
public static void main(String[] args) {
try {
ipc = new IPConnection(HOST, PORT);
ipc.addDevice(master);
ipc.addDevice(lcd);
ipc.addDevice(poti);
poti.setPositionCallbackPeriod(50);
poti.addListener(new BrickletRotaryPoti.PositionListener() {
@Override
public void position(short position) {
lcd.clearDisplay();
Calendar cal = Calendar.getInstance();
lcd.writeLine((short) 0, (short) 0, cal.getTime().toString());
lcd.writeLine((short) 1, (short) 0, "Rotation: " + position);
}
});
} catch (Exception e) {
}
}
}
The result is that the display text in the LCD bricklet changes while I turn the rotation bricklet:
Now imagine that you have some JavaFX charts and, while you turn the rotation bricklet (i.e., the dial thing that I'm turning above), the values of the charts change. That would be pretty cool because you'd be able to animate the JavaFX charts by rotating an object externally, i.e., without even touching the keyboard. That would be pretty cool to see and shouldn't be hard to implement.