X

Geertjan's Blog

Tinkerforge Rotation/LCD & JavaFX Plans

Geertjan Wielenga
Product Manager
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.

Join the discussion

Comments ( 1 )
  • Javier Ortiz Saturday, September 22, 2012

    This looks so cool! With some spare time it would be fun making your house smart.

    I would do something like Tinkerforge set up at home, Server with Marauroa, and a Maauroa Client. It would be awesome!

    How do the bricks comunicate with each other? Hardwire? Wireless?


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha