3 var batteryVoltageStream;
6 var engineCoolantStream;
8 var intakeAirTempStream;
19 function calcAverageMpg(newMpg) {
20 prevMpg += parseInt(newMpg);
23 var averageMpg = prevMpg / mpgReadings;
24 $("#avgmpg").text(Math.floor(averageMpg));
31 function calcAverageVelocity(newVel) {
32 prevVel += parseInt(newVel);
35 var averageVel = prevVel / velReadings;
36 $("#avgspeed").text(Math.floor(averageVel));
39 window.onload = function()
41 var vehicle = tizen.vehicle
43 var velocityUnits = $('#velocityUnits');
44 velocityUnits.click(function() {
45 if(velocityUnits.text() === "MPH")
47 velocityUnits.text("KPH");
49 else velocityUnits.text("MPH");
52 vehicle.vehicleSpeed.subscribe(function(data) {
53 console.log("Vehicle data" + data.speed);
54 adjvalue = data.speed;
56 var velocityUnits = $('#velocityUnits');
58 if(velocityUnits.text() === "MPH")
59 adjvalue = Math.floor(adjvalue * 0.62137);
61 $('#velocity').text(adjvalue);
63 calcAverageVelocity(adjvalue);
66 vehicle.engineSpeed.subscribe(function(data) {
67 var value = data.speed;
68 if(value > 10000) value =10000;
69 var needleDegs = value / 10000 * 180;
70 $('#rpms').text(value);
71 $('#rpmNeedle').css("-webkit-transform","rotate("+needleDegs+"deg)");
74 vehicle.transmission.subscribe(function(data) {
77 $('#gear').text('Reverse');
79 $('#gear').text('Neutral');
80 else $('#gear').text(value);
84 vehicle.steeringWheel.subscribe(function(data) {
86 $('#wheel').css("-webkit-transform","rotate("+value+"deg)");
87 $('#machinegun').css("-webkit-transform","rotate("+value+"deg)");
90 vehicle.throttlePosition.subscribe(function(data) {
92 var needleDegs = (value / 100 * 180) + 270
94 $('#throttleNeedle').css("-webkit-transform","rotate("+needleDegs+"deg)");
98 vehicle.engineCoolant.subscribe(function(data) {
99 value = data.temperature;
100 var needleDegs = (value / 180 * 70) + 270
102 $('#engineCoolantNeedle').css("-webkit-transform","rotate("+needleDegs+"deg)");