2014-08-09 18:01:17 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-08-12 13:51:31 +00:00
|
|
|
TABS.gps = {};
|
2014-08-12 14:05:22 +00:00
|
|
|
TABS.gps.initialize = function (callback) {
|
2014-10-01 10:58:09 +00:00
|
|
|
var self = this;
|
|
|
|
|
2014-10-01 11:16:22 +00:00
|
|
|
if (GUI.active_tab != 'gps') {
|
|
|
|
GUI.active_tab = 'gps';
|
2014-10-30 11:33:39 +00:00
|
|
|
googleAnalytics.sendAppView('GPS');
|
2014-10-01 11:16:22 +00:00
|
|
|
}
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
function load_html() {
|
|
|
|
$('#content').load("./tabs/gps.html", process_html);
|
|
|
|
}
|
|
|
|
|
2015-02-23 21:27:55 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_STATUS, false, false, load_html);
|
2014-08-14 14:48:16 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
function process_html() {
|
2014-05-06 14:48:46 +00:00
|
|
|
// translate to user-selected language
|
|
|
|
localize();
|
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
function get_raw_gps_data() {
|
2014-11-17 18:58:12 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_RAW_GPS, false, false, get_comp_gps_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_comp_gps_data() {
|
|
|
|
MSP.send_message(MSP_codes.MSP_COMP_GPS, false, false, get_gpsvinfo_data);
|
2014-03-22 23:28:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_gpsvinfo_data() {
|
2015-01-04 09:34:56 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_GPS_SV_INFO, false, false, update_ui);
|
2014-03-22 23:28:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function update_ui() {
|
2014-05-20 19:01:44 +00:00
|
|
|
var lat = GPS_DATA.lat / 10000000;
|
|
|
|
var lon = GPS_DATA.lon / 10000000;
|
2014-05-06 00:08:55 +00:00
|
|
|
var url = 'https://maps.google.com/?q=' + lat + ',' + lon;
|
|
|
|
|
2014-05-08 08:56:41 +00:00
|
|
|
$('.GPS_info td.fix').html((GPS_DATA.fix) ? chrome.i18n.getMessage('gpsFixTrue') : chrome.i18n.getMessage('gpsFixFalse'));
|
2014-05-04 11:27:12 +00:00
|
|
|
$('.GPS_info td.alt').text(GPS_DATA.alt + ' m');
|
2014-05-06 00:08:55 +00:00
|
|
|
$('.GPS_info td.lat a').prop('href', url).text(lat.toFixed(4) + ' deg');
|
|
|
|
$('.GPS_info td.lon a').prop('href', url).text(lon.toFixed(4) + ' deg');
|
2014-05-04 11:27:12 +00:00
|
|
|
$('.GPS_info td.speed').text(GPS_DATA.speed + ' cm/s');
|
|
|
|
$('.GPS_info td.sats').text(GPS_DATA.numSat);
|
|
|
|
$('.GPS_info td.distToHome').text(GPS_DATA.distanceToHome + ' m');
|
2014-03-22 23:28:41 +00:00
|
|
|
|
|
|
|
// Update GPS Signal Strengths
|
|
|
|
var e_ss_table = $('div.GPS_signal_strength table tr:not(.titles)');
|
|
|
|
|
|
|
|
for (var i = 0; i < GPS_DATA.chn.length; i++) {
|
|
|
|
var row = e_ss_table.eq(i);
|
|
|
|
|
2014-05-04 11:27:12 +00:00
|
|
|
$('td', row).eq(0).text(GPS_DATA.svid[i]);
|
|
|
|
$('td', row).eq(1).text(GPS_DATA.quality[i]);
|
2014-03-22 23:28:41 +00:00
|
|
|
$('td', row).eq(2).find('progress').val(GPS_DATA.cno[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// enable data pulling
|
2015-02-23 21:27:55 +00:00
|
|
|
GUI.interval_add('gps_pull', function gps_update() {
|
|
|
|
// avoid usage of the GPS commands until a GPS sensor is detected for targets that are compiled without GPS support.
|
|
|
|
if (!have_sensor(CONFIG.activeSensors, 'gps')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
get_raw_gps_data();
|
|
|
|
}, 75, true);
|
2014-03-30 09:51:16 +00:00
|
|
|
|
|
|
|
// status data pulled via separate timer with static speed
|
2014-10-01 10:58:09 +00:00
|
|
|
GUI.interval_add('status_pull', function status_pull() {
|
2014-06-01 12:10:18 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_STATUS);
|
2014-03-30 09:51:16 +00:00
|
|
|
}, 250, true);
|
2014-07-10 16:27:04 +00:00
|
|
|
|
2015-11-11 21:01:22 +00:00
|
|
|
GUI.content_ready(callback);
|
2014-03-22 23:28:41 +00:00
|
|
|
}
|
2014-07-10 16:27:04 +00:00
|
|
|
};
|
|
|
|
|
2014-08-12 14:05:22 +00:00
|
|
|
TABS.gps.cleanup = function (callback) {
|
2014-07-10 16:27:04 +00:00
|
|
|
if (callback) callback();
|
|
|
|
};
|