use of com.robo4j.hw.rpi.serial.gps.GPS in project robo4j by Robo4J.
the class GPSTest method main.
public static void main(String[] args) throws InterruptedException, IOException {
GPS gps = new GPS();
gps.addListener(new GPSListener() {
@Override
public void onEvent(PositionEvent event) {
System.out.println(event);
}
@Override
public void onEvent(VelocityEvent event) {
System.out.println(event);
}
});
gps.startAutoUpdate();
System.out.println("Press enter to quit!");
System.in.read();
gps.shutdown();
}
use of com.robo4j.hw.rpi.serial.gps.GPS in project robo4j by Robo4J.
the class GPSUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
readInterval = configuration.getInteger("readInterval", DEFAULT_READ_INTERVAL);
String scheduler = configuration.getString("scheduler", PROPERTY_VALUE_PLATFORM_SCHEDULER);
boolean usePlatformScheduler = PROPERTY_VALUE_PLATFORM_SCHEDULER.equals(scheduler) ? true : false;
try {
gps = new GPS(readInterval);
} catch (IOException e) {
throw new ConfigurationException("Could not instantiate GPS!", e);
}
if (usePlatformScheduler) {
scheduledFuture = getContext().getScheduler().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
gps.update();
}
}, 10, readInterval, TimeUnit.MILLISECONDS);
} else {
gps.startAutoUpdate();
}
}
Aggregations