diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 992af658..4b8c1bde 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -3224,5 +3224,11 @@ }, "vtxDisclaimer": { "message": "Use only bands, channels and power levels that are legal in a place you fly! Always refer to VTX user manual and local regulations!" + }, + "defaultsDialogTitle": { + "message": "Default values" + }, + "defaultsDialogInfo": { + "message": "INAV Configurator would like to know which kind of UAV you are configuring. Based on this information it will modify some default values to unlock the best flying performance. " } } diff --git a/gulpfile.js b/gulpfile.js index e1f3fc30..4df300a5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -50,7 +50,8 @@ sources.css = [ './js/libraries/switchery/switchery.css', './js/libraries/jbox/jBox.css', './node_modules/openlayers/dist/ol.css', - './src/css/logic.css' + './src/css/logic.css', + './src/css/defaults_dialog.css' ]; sources.js = [ @@ -113,6 +114,7 @@ sources.js = [ './tabs/advanced_tuning.js', './js/peripherals.js', './js/appUpdater.js', + './js/defaults_dialog.js', './node_modules/openlayers/dist/ol.js' ]; diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js new file mode 100644 index 00000000..61f5ca88 --- /dev/null +++ b/js/defaults_dialog.js @@ -0,0 +1,79 @@ +'use strict'; + +var helper = helper || {}; + +helper.defaultsDialog = (function() { + + let publicScope = {}, + privateScope = {}; + + let $container; + + let data = [{ + "title": 'Mini Quad with 3"-7" propellers', + "id": 2, + "settings": { + "gyro_lpf": "256HZ", + "looptime": 500 + } + }, + { + "title": 'Airplane', + "id": 3 + }, + { + "title": 'Custom UAV - INAV legacy defaults', + "id": 1 + } + ] + + publicScope.init = function() { + mspHelper.getSetting("applied_defaults").then(privateScope.onInitSettingReturned); + $container = $("#defaults-wrapper"); + }; + + privateScope.onPresetClick = function(event) { + let preset = data[$(event.currentTarget).data("index")]; + if (preset) { + + let promises = {}; + Object.keys(presets.settings).forEach(function(key, ii) { + let value = presets.settings[key]; + promises[key] = mspHelper.setSetting(name, value); + }); + + console.log(promises); + // Promise.props(promises).then(function() { + // saveChainer.execute(); + // }); + + } + }; + + privateScope.render = function() { + let $place = $container.find('.defaults-dialog__options'); + for (let i in data) { + if (data.hasOwnProperty(i)) { + let preset = data[i]; + let $element = $("
\ + \ +
") + + $element.find("a").html(preset.title); + $element.data("index", i).click(privateScope.onPresetClick) + $element.appendTo($place); + } + } + } + + privateScope.onInitSettingReturned = function(promise) { + if (promise.value > 0) { + return; //Defaults were applied, we can just ignore + } + + privateScope.render(); + $container.show(); + } + + return publicScope; +})(); \ No newline at end of file diff --git a/js/serial_backend.js b/js/serial_backend.js index 7061992c..ee8530d5 100755 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -336,6 +336,7 @@ function onConnect() { }, 100); helper.interval.add('global_data_refresh', helper.periodicStatusUpdater.run, helper.periodicStatusUpdater.getUpdateInterval(serial.bitrate), false); + helper.defaultsDialog.init(); } function onClosed(result) { diff --git a/main.html b/main.html index cc1445d4..b749fcf6 100755 --- a/main.html +++ b/main.html @@ -1,56 +1,57 @@ + - - + + - -
- -
- - -
-
-
- -
- + +
+ -
-
-
- Show Log -
-
-
-
-
-
-
    -
  • -
  • -
  • -
  • -
-
    -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • - -
  • -
  • -
  • -
  • -
  • -
  • - -
  • -
  • -
  • -
  • -
  • - - - -
-
-
-
-
- 0 +
+
+ Show Log +
+
+
-
- 0 +
+
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • + +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • + +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • + + + +
+
+
-
- 0 +
+
+
+ 0 +
+
+ 0 +
+
+ 0 +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- +
+
+

Waiting for data ...

+
-
-
-

Waiting for data ...

+ + -
- - + + \ No newline at end of file diff --git a/src/css/defaults_dialog.css b/src/css/defaults_dialog.css new file mode 100644 index 00000000..bd6e1e44 --- /dev/null +++ b/src/css/defaults_dialog.css @@ -0,0 +1,45 @@ +.defaults-dialog__background { + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + background: black; + opacity: 0.75; + z-index: 2001; +} + +.defaults-dialog__content { + background-color: #efefef; + border-radius: 2px; + z-index: 2002; + position: absolute; + width: 500px; + height: 280px; + overflow-y: auto; + top: 0; + bottom: 0; + left: 0; + right: 0; + margin: auto; + padding: 1em; +} + +.defaults-dialog__content--wrapper { + overflow-y: auto; +} + +.defaults-dialog__info { + font-size: 1.3em; +} + +.defaults_btn { + float: none; + display: block; + margin-top: 1em; +} + +.defaults_btn a { + font-size: 1.4em; + line-height: 25px; +} \ No newline at end of file