mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Avoid using GPS commands for targets that do not have GPS support
compiled in.
This commit is contained in:
parent
831e4a848e
commit
7bdd010eb0
3 changed files with 81 additions and 45 deletions
|
@ -247,44 +247,67 @@ function sensor_status(sensors_detected) {
|
|||
}
|
||||
|
||||
// update UI (if necessary)
|
||||
if (sensor_status.previous_sensors_detected != sensors_detected) {
|
||||
if (sensor_status.previous_sensors_detected == sensors_detected) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set current value
|
||||
sensor_status.previous_sensors_detected = sensors_detected;
|
||||
|
||||
var e_sensor_status = $('div#sensor-status');
|
||||
|
||||
if (bit_check(sensors_detected, 0)) { // Gyroscope & accel detected
|
||||
$('.gyro', e_sensor_status).addClass('on');
|
||||
if (have_sensor(sensors_detected, 'acc')) {
|
||||
$('.accel', e_sensor_status).addClass('on');
|
||||
} else {
|
||||
$('.gyro', e_sensor_status).removeClass('on');
|
||||
$('.accel', e_sensor_status).removeClass('on');
|
||||
}
|
||||
|
||||
if (bit_check(sensors_detected, 1)) { // Barometer detected
|
||||
if (have_sensor(sensors_detected, 'gyro')) {
|
||||
$('.gyro', e_sensor_status).addClass('on');
|
||||
} else {
|
||||
$('.gyro', e_sensor_status).removeClass('on');
|
||||
}
|
||||
|
||||
if (have_sensor(sensors_detected, 'baro')) {
|
||||
$('.baro', e_sensor_status).addClass('on');
|
||||
} else {
|
||||
$('.baro', e_sensor_status).removeClass('on');
|
||||
}
|
||||
|
||||
if (bit_check(sensors_detected, 2)) { // Magnetometer detected
|
||||
if (have_sensor(sensors_detected, 'mag')) {
|
||||
$('.mag', e_sensor_status).addClass('on');
|
||||
} else {
|
||||
$('.mag', e_sensor_status).removeClass('on');
|
||||
}
|
||||
|
||||
if (bit_check(sensors_detected, 3)) { // GPS detected
|
||||
if (have_sensor(sensors_detected, 'gps')) {
|
||||
$('.gps', e_sensor_status).addClass('on');
|
||||
} else {
|
||||
$('.gps', e_sensor_status).removeClass('on');
|
||||
}
|
||||
|
||||
if (bit_check(sensors_detected, 4)) { // Sonar detected
|
||||
if (have_sensor(sensors_detected, 'sonar')) {
|
||||
$('.sonar', e_sensor_status).addClass('on');
|
||||
} else {
|
||||
$('.sonar', e_sensor_status).removeClass('on');
|
||||
}
|
||||
|
||||
// set current value
|
||||
sensor_status.previous_sensors_detected = sensors_detected;
|
||||
}
|
||||
|
||||
function have_sensor(sensors_detected, sensor_code) {
|
||||
switch(sensor_code) {
|
||||
case 'acc':
|
||||
case 'gyro':
|
||||
return bit_check(sensors_detected, 0);
|
||||
case 'baro':
|
||||
return bit_check(sensors_detected, 1);
|
||||
case 'mag':
|
||||
return bit_check(sensors_detected, 2);
|
||||
case 'gps':
|
||||
return bit_check(sensors_detected, 3);
|
||||
case 'sonar':
|
||||
return bit_check(sensors_detected, 4);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function highByte(num) {
|
||||
|
|
11
tabs/gps.js
11
tabs/gps.js
|
@ -13,7 +13,7 @@ TABS.gps.initialize = function (callback) {
|
|||
$('#content').load("./tabs/gps.html", process_html);
|
||||
}
|
||||
|
||||
MSP.send_message(MSP_codes.MSP_RAW_GPS, false, false, load_html);
|
||||
MSP.send_message(MSP_codes.MSP_STATUS, false, false, load_html);
|
||||
|
||||
function process_html() {
|
||||
// translate to user-selected language
|
||||
|
@ -57,7 +57,14 @@ TABS.gps.initialize = function (callback) {
|
|||
}
|
||||
|
||||
// enable data pulling
|
||||
GUI.interval_add('gps_pull', get_raw_gps_data, 75, true);
|
||||
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);
|
||||
|
||||
// status data pulled via separate timer with static speed
|
||||
GUI.interval_add('status_pull', function status_pull() {
|
||||
|
|
|
@ -163,6 +163,7 @@ TABS.setup.initialize = function (callback) {
|
|||
rssi_e.text(chrome.i18n.getMessage('initialSetupRSSIValue', [((ANALOG.rssi / 1023) * 100).toFixed(0)]));
|
||||
});
|
||||
|
||||
if (have_sensor(CONFIG.activeSensors, 'gps')) {
|
||||
MSP.send_message(MSP_codes.MSP_RAW_GPS, false, false, function () {
|
||||
gpsFix_e.html((GPS_DATA.fix) ? chrome.i18n.getMessage('gpsFixTrue') : chrome.i18n.getMessage('gpsFixFalse'));
|
||||
gpsSats_e.text(GPS_DATA.numSat);
|
||||
|
@ -170,6 +171,7 @@ TABS.setup.initialize = function (callback) {
|
|||
gpsLon_e.text((GPS_DATA.lon / 10000000).toFixed(4) + ' deg');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function get_fast_data() {
|
||||
MSP.send_message(MSP_codes.MSP_ATTITUDE, false, false, function () {
|
||||
|
@ -269,6 +271,10 @@ TABS.setup.initialize3D = function (compatibility) {
|
|||
scene.add(modelWrapper);
|
||||
|
||||
this.render3D = function () {
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
|
||||
// compute the changes
|
||||
model.rotation.x = (SENSOR_DATA.kinematics[1] * -1.0) * 0.017453292519943295;
|
||||
modelWrapper.rotation.y = ((SENSOR_DATA.kinematics[2] * -1.0) - self.yaw_fix) * 0.017453292519943295;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue