From a6807d5945b2a7619309336ab7fcc52ab6d9b02d Mon Sep 17 00:00:00 2001 From: gael Date: Mon, 18 Apr 2016 23:19:07 +0200 Subject: [PATCH 1/2] Issue #153 finer mag_declination in GUI Allow declination to be set exactly in degrees,minutes (therefore uses exactly the same value as in CLI instead of rounding it) --- js/msp.js | 6 +++--- tabs/configuration.html | 2 +- tabs/configuration.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/js/msp.js b/js/msp.js index 1129052a..a064b1c5 100644 --- a/js/msp.js +++ b/js/msp.js @@ -430,7 +430,7 @@ var MSP = { MISC.multiwiicurrentoutput = data.getUint8(offset++); MISC.rssi_channel = data.getUint8(offset++); MISC.placeholder2 = data.getUint8(offset++); - MISC.mag_declination = data.getInt16(offset, 1) / 10; // -18000-18000 + MISC.mag_declination = data.getInt16(offset, 1) / 100; // -18000-18000 offset += 2; MISC.vbatscale = data.getUint8(offset++, 1); // 10-200 MISC.vbatmincellvoltage = data.getUint8(offset++, 1) / 10; // 10-50 @@ -1232,8 +1232,8 @@ MSP.crunch = function (code) { buffer.push(MISC.multiwiicurrentoutput); buffer.push(MISC.rssi_channel); buffer.push(MISC.placeholder2); - buffer.push(lowByte(Math.round(MISC.mag_declination * 10))); - buffer.push(highByte(Math.round(MISC.mag_declination * 10))); + buffer.push(lowByte(Math.round(MISC.mag_declination * 100))); + buffer.push(highByte(Math.round(MISC.mag_declination * 100))); buffer.push(MISC.vbatscale); buffer.push(Math.round(MISC.vbatmincellvoltage * 10)); buffer.push(Math.round(MISC.vbatmaxcellvoltage * 10)); diff --git a/tabs/configuration.html b/tabs/configuration.html index 89b2224f..ccc59b23 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -384,7 +384,7 @@
-
diff --git a/tabs/configuration.js b/tabs/configuration.js index d9e22a9b..2c3ca833 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -363,7 +363,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $('input[name="pitch"]').val(CONFIG.accelerometerTrims[0]); // fill magnetometer - $('input[name="mag_declination"]').val(MISC.mag_declination); + $('input[name="mag_declination"]').val(MISC.mag_declination.toFixed(2)); //fill motor disarm params and FC loop time if(semver.gte(CONFIG.apiVersion, "1.8.0")) { From 469d174c6896d2b70a87d6940e191cbd0d9a849c Mon Sep 17 00:00:00 2001 From: gael Date: Wed, 20 Apr 2016 22:04:36 +0200 Subject: [PATCH 2/2] Apply old mag_declination method for API < 1.18 --- js/msp.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/js/msp.js b/js/msp.js index a064b1c5..d465f31f 100644 --- a/js/msp.js +++ b/js/msp.js @@ -429,8 +429,11 @@ var MSP = { MISC.gps_ubx_sbas = data.getInt8(offset++); MISC.multiwiicurrentoutput = data.getUint8(offset++); MISC.rssi_channel = data.getUint8(offset++); - MISC.placeholder2 = data.getUint8(offset++); - MISC.mag_declination = data.getInt16(offset, 1) / 100; // -18000-18000 + MISC.placeholder2 = data.getUint8(offset++); + if (semver.lt(CONFIG.apiVersion, "1.18.0")) + MISC.mag_declination = data.getInt16(offset, 1) / 10; // -1800-1800 + else + MISC.mag_declination = data.getInt16(offset, 1) / 100; // -18000-18000 offset += 2; MISC.vbatscale = data.getUint8(offset++, 1); // 10-200 MISC.vbatmincellvoltage = data.getUint8(offset++, 1) / 10; // 10-50 @@ -1232,8 +1235,13 @@ MSP.crunch = function (code) { buffer.push(MISC.multiwiicurrentoutput); buffer.push(MISC.rssi_channel); buffer.push(MISC.placeholder2); - buffer.push(lowByte(Math.round(MISC.mag_declination * 100))); - buffer.push(highByte(Math.round(MISC.mag_declination * 100))); + if (semver.lt(CONFIG.apiVersion, "1.18.0")) { + buffer.push(lowByte(Math.round(MISC.mag_declination * 10))); + buffer.push(highByte(Math.round(MISC.mag_declination * 10))); + } else { + buffer.push(lowByte(Math.round(MISC.mag_declination * 100))); + buffer.push(highByte(Math.round(MISC.mag_declination * 100))); + } buffer.push(MISC.vbatscale); buffer.push(Math.round(MISC.vbatmincellvoltage * 10)); buffer.push(Math.round(MISC.vbatmaxcellvoltage * 10));