added MSP support for sensor orientation, some fixes for 3D backup and restore

10.3.x-maintenance
NightHawk32 2015-12-14 18:06:25 -05:00
parent 1c671f26bf
commit 067999c5e8
5 changed files with 98 additions and 7 deletions

View File

@ -105,6 +105,9 @@ function configuration_backup(callback) {
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
uniqueData.push(MSP_codes.MSP_3D);
}
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
uniqueData.push(MSP_codes.MSP_SENSOR_ALIGNMENT);
}
}
update_unique_data_list();
@ -132,6 +135,9 @@ function configuration_backup(callback) {
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
configuration._3D = jQuery.extend(true, {}, _3D);
}
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
configuration.SENSOR_ALIGNMENT = jQuery.extend(true, {}, SENSOR_ALIGNMENT);
}
save();
}
@ -513,8 +519,9 @@ function configuration_restore(callback) {
appliedMigrationsCount++;
}
if (compareVersions(migratedVersion, '0.66.0') && !compareVersions(configuration.apiVersion, '1.15.0')) {
// api 1.14 exposes deadband and yaw_deadband
// api 1.15 exposes RCcontrols and sensor alignment
for (var profileIndex = 0; profileIndex < configuration.profiles.length; profileIndex++) {
@ -527,6 +534,13 @@ function configuration_restore(callback) {
};
}
}
if (configuration.SENSOR_ALIGNMENT == undefined) {
configuration.SENSOR_ALIGNMENT = {
align_gyro: 0,
align_acc: 0,
align_mag: 0
};
}
appliedMigrationsCount++;
}
@ -645,6 +659,9 @@ function configuration_restore(callback) {
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
uniqueData.push(MSP_codes.MSP_SET_3D);
}
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
uniqueData.push(MSP_codes.MSP_SET_SENSOR_ALIGNMENT);
}
}
function load_objects() {
@ -656,6 +673,7 @@ function configuration_restore(callback) {
ARMING_CONFIG = configuration.ARMING_CONFIG;
FC_CONFIG = configuration.FC_CONFIG;
_3D = configuration._3D;
SENSOR_ALIGNMENT = configuration.SENSOR_ALIGNMENT;
}
function send_unique_data_item() {

View File

@ -185,3 +185,9 @@ var RC_controls = {
alt_hold_deadband: 0,
alt_hold_fast_change: 0
};
var SENSOR_ALIGNMENT = {
align_gyro: 0,
align_acc: 0,
align_mag: 0
};

View File

@ -54,6 +54,7 @@ var MSP_codes = {
MSP_SERVO_CONFIGURATIONS: 120,
MSP_3D: 124,
MSP_RC_CONTROLS: 125,
MSP_SENSOR_ALIGNMENT: 126,
MSP_SET_RAW_RC: 200,
MSP_SET_RAW_GPS: 201,
@ -72,6 +73,7 @@ var MSP_codes = {
MSP_SET_3D: 217,
MSP_SET_RC_CONTROLS: 218,
MSP_SET_RESET_CURR_PID: 219,
MSP_SET_SENSOR_ALIGNMENT: 220,
// MSP_BIND: 240,
@ -524,6 +526,12 @@ var MSP = {
RC_controls.alt_hold_deadband = data.getUint8(offset++, 1);
RC_controls.alt_hold_fast_change = data.getUint8(offset++, 1);
break;
case MSP_codes.MSP_SENSOR_ALIGNMENT:
var offset = 0;
SENSOR_ALIGNMENT.align_gyro = data.getUint8(offset++, 1);
SENSOR_ALIGNMENT.align_acc = data.getUint8(offset++, 1);
SENSOR_ALIGNMENT.align_mag = data.getUint8(offset++, 1);
break;
case MSP_codes.MSP_SET_RAW_RC:
break;
case MSP_codes.MSP_SET_RAW_GPS:
@ -863,6 +871,12 @@ var MSP = {
case MSP_codes.MSP_SET_RESET_CURR_PID:
console.log('Current PID profile reset');
break;
case MSP_codes.MSP_SET_3D:
console.log('3D settings saved');
break;
case MSP_codes.MSP_SET_SENSOR_ALIGNMENT:
console.log('Sensor alignment saved');
break;
default:
console.log('Unknown code detected: ' + code);
@ -1175,6 +1189,12 @@ MSP.crunch = function (code) {
buffer.push(RC_controls.alt_hold_fast_change);
break;
case MSP_codes.MSP_SET_SENSOR_ALIGNMENT:
buffer.push(SENSOR_ALIGNMENT.align_gyro);
buffer.push(SENSOR_ALIGNMENT.align_acc);
buffer.push(SENSOR_ALIGNMENT.align_mag);
break
default:
return false;
}

View File

@ -132,19 +132,19 @@
<div class="sensoralignment" style="width:40%; float:left;">
<div class="number">
<select class="gyroalign">
<option>Gyro Alignment</option>
<option value="0">Gyro Alignment</option>
<!-- list generated here -->
</select>
</div>
<div class="number">
<select class="accalign">
<option>Acc Alignment</option>
<option value="0">Acc Alignment</option>
<!-- list generated here -->
</select>
</div>
<div class="number">
<select class="magalign">
<option>Mag Alignment</option>
<option value="0">Mag Alignment</option>
<!-- list generated here -->
</select>
</div>

View File

@ -54,13 +54,22 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_3d() {
var next_callback = load_html;
if (semver.lt(CONFIG.apiVersion, "1.14.0")) {
var next_callback = load_sensor_alignment;
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
MSP.send_message(MSP_codes.MSP_3D, false, false, next_callback);
} else {
next_callback();
}
}
function load_sensor_alignment() {
var next_callback = load_html;
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
MSP.send_message(MSP_codes.MSP_SENSOR_ALIGNMENT, false, false, next_callback);
} else {
next_callback();
}
}
function load_html() {
$('#content').load("./tabs/configuration.html", process_html);
@ -193,6 +202,35 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
});
}
var alignments = [
'CW0',
'CW90',
'CW180',
'CW270',
'CW0FLIP',
'CW90FLIP',
'CW180FLIP',
'CW270FLIP'
];
if (semver.lt(CONFIG.apiVersion, "1.15.0")) {
$('.tab-configuration .sensoralignment').hide();
} else {
var orientation_gyro_e = $('select.gyroalign');
var orientation_acc_e = $('select.accalign');
var orientation_mag_e = $('select.magalign');
for (var i = 0; i < alignments.length; i++) {
orientation_gyro_e.append('<option value="' + (i+1) + '">' + alignments[i] + '</option>');
orientation_acc_e.append('<option value="' + (i+1) + '">' + alignments[i] + '</option>');
orientation_mag_e.append('<option value="' + (i+1) + '">' + alignments[i] + '</option>');
}
orientation_gyro_e.val(SENSOR_ALIGNMENT.align_gyro);
orientation_acc_e.val(SENSOR_ALIGNMENT.align_acc);
orientation_mag_e.val(SENSOR_ALIGNMENT.align_mag);
}
// generate GPS
var gpsProtocols = [
'NMEA',
@ -216,6 +254,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
'Indian GAGAN'
];
var gps_protocol_e = $('select.gps_protocol');
for (var i = 0; i < gpsProtocols.length; i++) {
gps_protocol_e.append('<option value="' + i + '">' + gpsProtocols[i] + '</option>');
@ -422,6 +461,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
_3D.neutral3d = parseInt($('input[name="3dneutral"]').val());
_3D.deadband3d_throttle = ($('input[name="3ddeadbandthrottle"]').val());
SENSOR_ALIGNMENT.align_gyro = parseInt(orientation_gyro_e.val());
SENSOR_ALIGNMENT.align_acc = parseInt(orientation_acc_e.val());
SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val());
function save_serial_config() {
if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
MSP.send_message(MSP_codes.MSP_SET_CF_SERIAL_CONFIG, MSP.crunch(MSP_codes.MSP_SET_CF_SERIAL_CONFIG), false, save_misc);
@ -435,7 +478,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_3d() {
MSP.send_message(MSP_codes.MSP_SET_3D, MSP.crunch(MSP_codes.MSP_SET_3D), false, save_acc_trim);
MSP.send_message(MSP_codes.MSP_SET_3D, MSP.crunch(MSP_codes.MSP_SET_3D), false, save_sensor_alignment);
}
function save_sensor_alignment() {
MSP.send_message(MSP_codes.MSP_SET_SENSOR_ALIGNMENT, MSP.crunch(MSP_codes.MSP_SET_SENSOR_ALIGNMENT), false, save_acc_trim);
}
function save_acc_trim() {