"use strict";
var Cylon = require("cylon");
Cylon.robot({
connections: {
tessel: { adaptor: "tessel", port: "A" }
},
devices: {
gps: { driver: "gps-a2235h" }
},
work: function(my) {
var satsInRange = 0;
var satsFixed = 0;
console.log("GPS module powered and ready. Waiting for satellites...");
my.gps.on("error", function(err) {
console.log(err);
});
my.gps.on("coordinates", function(c) {
console.log("Lat:", c.lat, "\tLon:", c.lon, "\tTimestamp:", c.timestamp);
});
my.gps.on("altitude", function(alt) {
var a = alt.alt,
t = alt.timestamp;
console.log("Got an altitude of", a, "meters (timestamp: " + t + ")");
});
my.gps.on("satellite-list-partial", function(data) {
satsInRange = data.satsInView;
console.log(satsInRange, "satellites in range,", satsFixed, "fixed.");
});
my.gps.on("fix", function(data) {
satsFixed = data.numSat;
console.log(satsInRange, "satellites in range,", satsFixed, "fixed.");
});
}
}).start();