From eafbaa5d06c65cc9b8d5ee338ba6a8387e29d6cd Mon Sep 17 00:00:00 2001 From: mikeller Date: Wed, 24 Aug 2016 00:34:51 +1200 Subject: [PATCH] Added expert mode. Moved FAILSAFE feature back into failsafe tab. --- _locales/en/messages.json | 20 +- js/Features.js | 11 +- js/injected_methods.js | 42 +++- main.css | 8 + main.html | 504 ++++++++++++++++++++------------------ main.js | 169 ++++++++----- tabs/failsafe.css | 31 +++ tabs/failsafe.html | 10 + tabs/failsafe.js | 20 ++ tabs/options.html | 4 +- 10 files changed, 496 insertions(+), 323 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 27c73db2..9a323d82 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -11,10 +11,6 @@ "options_receive_app_notifications": { "message": "Receive desktop notification when application updates" }, - "options_improve_configurator": { - "message": "Send anonymous usage data to the developer team" - }, - "connect": { "message": "Connect" }, @@ -33,6 +29,12 @@ "autoConnectDisabled": { "message": "Auto-Connect: Disabled - User needs to select the correct serial port and click \"Connect\" button on its own" }, + "expertMode": { + "message": "Enable Expert Mode" + }, + "permanentExpertMode": { + "message": "Permanently enable Expert Mode" + }, "deviceRebooting": { "message": "Device - Rebooting" }, @@ -544,10 +546,16 @@ "message": "On Screen Display" }, "featureFAILSAFE": { - "message": "Override failsafe behaviour on RX signal loss" + "message": "Enable Failsafe Stage 2" + }, + "featureFAILSAFEOld": { + "message": "Enable Failsafe" }, "featureFAILSAFETip": { - "message": "Warning: Use this only if you know what you are doing. The default behaviour on RX signal loss (deactivate all motors to bring craft to the ground) is the safest option in most situations." + "message": "Note: When Stage 2 is DISABLED, the fallback setting Auto is used instead of the user settings for all flightchannels (Roll, Pitch, Yaw and Throttle)." + }, + "featureFAILSAFEOldTip": { + "message": "Apply Failsafe settings on RX signal loss" }, "configurationFeatureEnabled": { "message": "Enabled" diff --git a/js/Features.js b/js/Features.js index 94155d93..b8d39198 100644 --- a/js/Features.js +++ b/js/Features.js @@ -12,7 +12,6 @@ var Features = function (config) { {bit: 5, group: 'other', name: 'SERVO_TILT'}, {bit: 6, group: 'other', name: 'SOFTSERIAL', haveTip: true}, {bit: 7, group: 'gps', name: 'GPS', haveTip: true}, - {bit: 8, group: 'other', name: 'FAILSAFE', haveTip: true}, {bit: 9, group: 'other', name: 'SONAR'}, {bit: 10, group: 'other', name: 'TELEMETRY'}, {bit: 11, group: 'batteryCurrent', name: 'CURRENT_METER'}, @@ -31,6 +30,16 @@ var Features = function (config) { ); } + if (semver.gte(config.apiVersion, "1.15.0")) { + features.push( + {bit: 8, group: 'rxFailsafe', name: 'FAILSAFE', haveTip: true} + ); + } else { + features.push( + {bit: 8, group: 'rxFailsafe', name: 'FAILSAFE', haveTip: true} + ); + } + if (semver.gte(config.apiVersion, "1.16.0")) { features.push( {bit: 21, group: 'other', name: 'TRANSPONDER', haveTip: true} diff --git a/js/injected_methods.js b/js/injected_methods.js index d6d7697f..5bce5a18 100644 --- a/js/injected_methods.js +++ b/js/injected_methods.js @@ -1,7 +1,28 @@ +Number.prototype.clamp = function(min, max) { + return Math.min(Math.max(this, min), max); +}; + +/** + * String formatting now supports currying (partial application). + * For a format string with N replacement indices, you can call .format + * with M <= N arguments. The result is going to be a format string + * with N-M replacement indices, properly counting from 0 .. N-M. + * The following Example should explain the usage of partial applied format: + * "{0}:{1}:{2}".format("a","b","c") === "{0}:{1}:{2}".format("a","b").format("c") + * "{0}:{1}:{2}".format("a").format("b").format("c") === "{0}:{1}:{2}".format("a").format("b", "c") + **/ +String.prototype.format = function () { + var args = arguments; + return this.replace(/\{(\d+)\}/g, function (t, i) { + return args[i] !== void 0 ? args[i] : "{"+(i-args.length)+"}"; + }); +}; + Array.prototype.push8 = function(val) { this.push(0xFF & val); return this; }; + Array.prototype.push16 = function(val) { // low byte this.push(0x00FF & val); @@ -10,13 +31,15 @@ Array.prototype.push16 = function(val) { // chainable return this; }; + Array.prototype.push32 = function(val) { this.push8(val) .push8(val >> 8) .push8(val >> 16) .push8(val >> 24); return this; -} +}; + DataView.prototype.offset = 0; DataView.prototype.readU8 = function() { if (this.byteLength >= this.offset+1) { @@ -24,28 +47,32 @@ DataView.prototype.readU8 = function() { } else { return null; } -} +}; + DataView.prototype.readU16 = function() { if (this.byteLength >= this.offset+2) { return this.readU8() + this.readU8()*256; } else { return null; } -} +}; + DataView.prototype.readU32 = function() { if (this.byteLength >= this.offset+4) { return this.readU16() + this.readU16()*65536; } else { return null; } -} +}; + DataView.prototype.read8 = function() { if (this.byteLength >= this.offset+1) { return this.getInt8(this.offset++, 1); } else { return null; } -} +}; + DataView.prototype.read16 = function() { this.offset += 2; if (this.byteLength >= this.offset) { @@ -53,7 +80,8 @@ DataView.prototype.read16 = function() { } else { return null; } -} +}; + DataView.prototype.read32 = function() { this.offset += 4; if (this.byteLength >= this.offset) { @@ -61,4 +89,4 @@ DataView.prototype.read32 = function() { } else { return null; } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/main.css b/main.css index f715b9bc..b31e5aaa 100644 --- a/main.css +++ b/main.css @@ -1581,6 +1581,14 @@ dialog { display:none; } +#expertMode { + color: #ddd; + margin-top: 16px; + width:125px; + float: right; + margin-right: 0px; + line-height: 12px; +} /* Battery element styling*/ diff --git a/main.html b/main.html index c06305e1..47f0fc23 100755 --- a/main.html +++ b/main.html @@ -1,261 +1,281 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
-
-