Example #1
0
	setTimeout(function() {
		console.log(speedData);
		console.log(latLng);
		console.log(cumulative_dist + " mi");

		stick.close();
	}, 30000);
Example #2
0
'use strict';

//Import Ant+ module
var Ant = require('C:/Program Files/nodejs/node_modules/ant-plus');
//Create Stick
var stick = new Ant.GarminStick3;
//Add Cadence Sensor
var speedCadenceSensor = new Ant.SpeedCadenceSensor(stick);
var dev_id = 0;

//Global vars
var t_start = Date.now();
var speedData = [];
var i = 0;
var cumulative_dist = 0;

//Initial Latitude and Longitude value
//Earth Radius in (3959mi)/(6371km)
var initLat = 40.0148127;
var initLng = -83.0101563;
var r = 3959;

//Bearing, lat, lng
var b = 0;
var latLng = [{"lat": initLat, "lng": initLng}];

//Define what to do when receiving data
speedCadenceSensor.on('speedData', function (data) {
	//Add time and spped to array
	var t = ((Date.now() - t_start)/1000);
	var s = data.CalculatedSpeed;