diff options
author | Pawel Spychalski (DzikuVx) <pspychalski@gmail.com> | 2022-09-18 13:26:32 +0300 |
---|---|---|
committer | Pawel Spychalski (DzikuVx) <pspychalski@gmail.com> | 2022-09-18 13:26:32 +0300 |
commit | 8fd2c5325a9ad94dd3119c149a35e3b158831354 (patch) | |
tree | c899ebee17d020e40709f2b2835407f411733624 /js | |
parent | 95376083c8d706e07d38e92730625bab8ea78872 (diff) | |
parent | a22e0a59c9f741384df620fff6d502d0fb8ee9f7 (diff) |
Merge remote-tracking branch 'origin/release_5.1.0'
Diffstat (limited to 'js')
-rw-r--r-- | js/defaults_dialog.js | 76 | ||||
-rw-r--r-- | js/fc.js | 2 | ||||
-rw-r--r-- | js/gui.js | 15 | ||||
-rw-r--r-- | js/helpers.js | 3 | ||||
-rw-r--r-- | js/logicCondition.js | 3 | ||||
-rw-r--r-- | js/logicConditionsCollection.js | 4 | ||||
-rw-r--r-- | js/settings.js | 72 |
7 files changed, 134 insertions, 41 deletions
diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js index 19bca033..4c3e81e2 100644 --- a/js/defaults_dialog.js +++ b/js/defaults_dialog.js @@ -287,19 +287,23 @@ helper.defaultsDialog = (function () { }, { key: "nav_fw_pos_z_p", - value: 15 + value: 25 }, { - key: "nav_fw_pos_z_d", + key: "nav_fw_pos_z_i", value: 5 }, { + key: "nav_fw_pos_z_d", + value: 8 + }, + { key: "nav_fw_pos_xy_p", - value: 60 + value: 55 }, { key: "fw_turn_assist_pitch_gain", - value: 0.5 + value: 0.4 }, { key: "max_angle_inclination_rll", @@ -359,11 +363,19 @@ helper.defaultsDialog = (function () { }, { key: "imu_acc_ignore_rate", - value: 9 + value: 7 }, { key: "imu_acc_ignore_slope", - value: 5 + value: 4 + }, + { + key: "imu_dcm_kp", + value: 1000 + }, + { + key: "imu_dcm_ki", + value: 0 }, { key: "airmode_type", @@ -393,6 +405,22 @@ helper.defaultsDialog = (function () { key: "nav_wp_radius", value: 5000 }, + { + key: "nav_fw_launch_max_angle", + value: 45 + }, + { + key: "nav_fw_launch_motor_delay", + value: 100 + }, + { + key: "nav_fw_launch_max_altitude", + value: 5000 + }, + { + key: "nav_fw_launch_climb_angle", + value: 25 + }, ], "features": [ { @@ -486,19 +514,23 @@ helper.defaultsDialog = (function () { }, { key: "nav_fw_pos_z_p", - value: 15 + value: 35 }, { - key: "nav_fw_pos_z_d", + key: "nav_fw_pos_z_i", value: 5 }, { + key: "nav_fw_pos_z_d", + value: 10 + }, + { key: "nav_fw_pos_xy_p", - value: 60 + value: 70 }, { key: "fw_turn_assist_pitch_gain", - value: 0.2 + value: 0.3 }, { key: "max_angle_inclination_rll", @@ -565,6 +597,14 @@ helper.defaultsDialog = (function () { value: 5 }, { + key: "imu_dcm_kp", + value: 1000 + }, + { + key: "imu_dcm_ki", + value: 0 + }, + { key: "airmode_type", value: "STICK_CENTER_ONCE" }, @@ -592,6 +632,22 @@ helper.defaultsDialog = (function () { key: "nav_wp_radius", value: 5000 }, + { + key: "nav_fw_launch_max_angle", + value: 75 + }, + { + key: "nav_fw_launch_motor_delay", + value: 100 + }, + { + key: "nav_fw_launch_max_altitude", + value: 5000 + }, + { + key: "nav_fw_launch_climb_angle", + value: 25 + }, ], "features": [ { @@ -1246,7 +1246,7 @@ var FC = { 4: { name: "Logic Condition", type: "range", - range: [0, 31], + range: [0, (LOGIC_CONDITIONS.getMaxLogicConditionCount()-1)], default: 0 }, 5: { @@ -300,16 +300,27 @@ GUI_control.prototype.renderOperandValue = function ($container, operandMetadata * @param {function} onChange * @param {boolean} withAlways */ -GUI_control.prototype.renderLogicConditionSelect = function ($container, logicConditions, current, onChange, withAlways) { +GUI_control.prototype.renderLogicConditionSelect = function ($container, logicConditions, current, onChange, withAlways, onlyEnabled) { let $select = $container.append('<select class="mix-rule-condition">').find("select"), lcCount = logicConditions.getCount(); + option = ""; if (withAlways) { $select.append('<option value="-1">Always</option>') } for (let i = 0; i < lcCount ; i++) { - $select.append('<option value="' + i + '">Logic Condition ' + i + ' </option>'); + if (!onlyEnabled || i === current || (logicConditions.isEnabled(i))) { + option = '<option'; + + if (i === current && !logicConditions.isEnabled(i)) { + option+= ' class="lc_disabled"'; + } + + option+= ' value="' + i + '">Logic Condition ' + i + ' </option>'; + + $select.append(option); + } } $select.val(current).change(onChange); diff --git a/js/helpers.js b/js/helpers.js index 8b611898..914fbbaa 100644 --- a/js/helpers.js +++ b/js/helpers.js @@ -42,8 +42,9 @@ function generateFilename(prefix, suffix) { if (CONFIG) { if (CONFIG.flightControllerIdentifier) { - filename = CONFIG.flightControllerIdentifier + '_' + filename; + filename = CONFIG.flightControllerIdentifier + '_' + CONFIG.flightControllerVersion + "_" + filename; } + if (CONFIG.name && CONFIG.name.trim() !== '') { filename = filename + '_' + CONFIG.name.trim().replace(' ', '_'); } diff --git a/js/logicCondition.js b/js/logicCondition.js index e5a5de3e..8409476b 100644 --- a/js/logicCondition.js +++ b/js/logicCondition.js @@ -218,9 +218,10 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op if (self.getEnabled()) { GUI.renderLogicConditionSelect( $e, - LOGIC_CONDITIONS, + LOGIC_CONDITIONS, self.getActivatorId, self.onActivatorChange, + true, true ); } else { diff --git a/js/logicConditionsCollection.js b/js/logicConditionsCollection.js index 84ccc8ce..9412362c 100644 --- a/js/logicConditionsCollection.js +++ b/js/logicConditionsCollection.js @@ -28,6 +28,10 @@ let LogicConditionsCollection = function () { return data.length }; + self.isEnabled = function (lcID) { + return data[lcID].getEnabled(); + } + self.open = function () { self.render(); $container.show(); diff --git a/js/settings.js b/js/settings.js index e54fe492..36816ed9 100644 --- a/js/settings.js +++ b/js/settings.js @@ -173,19 +173,20 @@ var Settings = (function () { let dataStep = input.data("step"); - if (dataStep !== undefined) { - input.attr('step', dataStep); - } else { - input.attr('step', "0.01"); + if (typeof dataStep === 'undefined') { + dataStep = self.countDecimals(s.value); + dataStep = 1 / Math.pow(10, dataStep); + input.data("step", dataStep); } + input.attr('step', dataStep); input.attr('min', s.setting.min); input.attr('max', s.setting.max); - input.val(s.value.toFixed(2)); - + input.val(s.value.toFixed(self.countDecimals(dataStep))); } else { var multiplier = parseFloat(input.data('setting-multiplier') || 1); + input.data("step", 1); input.val((s.value / multiplier).toFixed(Math.log10(multiplier))); input.attr('type', 'number'); if (typeof s.setting.min !== 'undefined' && s.setting.min !== null) { @@ -449,7 +450,7 @@ var Settings = (function () { 'm-lrg' : 'mi', 'cms' : 'mph', 'v-cms' : 'fts', - 'decadegps' : 'degpd', + 'decadegps' : 'degps', 'decideg' : 'deg', 'decideg-lrg' : 'deg', 'msec' : 'sec', @@ -498,38 +499,33 @@ var Settings = (function () { const multiplier = multiObj.multiplier; const unitName = multiObj.unitName; + let decimalPlaces = 0; // Update the step, min, and max; as we have the multiplier here. if (element.attr('type') == 'number') { - let step = element.attr('step') || 1; - let decimalPlaces = 0; - - step = step / multiplier; + let step = parseFloat(element.attr('step')) || 1; - if (step < 1) { - decimalPlaces = step.toString().length - step.toString().indexOf(".") - 1; - if (parseInt(step.toString().slice(-1)) > 1 ) { - decimalPlaces--; - } + if (multiplier !== 1) { + decimalPlaces = Math.min(Math.ceil(multiplier / 100), 3); step = 1 / Math.pow(10, decimalPlaces); } element.attr('step', step.toFixed(decimalPlaces)); - if (multiplier != 'FAHREN') { - element.attr('min', (element.attr('min') / multiplier).toFixed(decimalPlaces)); - element.attr('max', (element.attr('max') / multiplier).toFixed(decimalPlaces)); + if (multiplier !== 'FAHREN' && multiplier !== 1) { + element.attr('min', (parseFloat(element.attr('min')) / multiplier).toFixed(decimalPlaces)); + element.attr('max', (parseFloat(element.attr('max')) / multiplier).toFixed(decimalPlaces)); } } // Update the input with a new formatted unit let newValue = ""; - if (multiplier == 'FAHREN') { - element.attr('min', toFahrenheit(element.attr('min')).toFixed(2)); - element.attr('max', toFahrenheit(element.attr('max')).toFixed(2)); - newValue = toFahrenheit(oldValue).toFixed(2); + if (multiplier === 'FAHREN') { + element.attr('min', toFahrenheit(element.attr('min')).toFixed(decimalPlaces)); + element.attr('max', toFahrenheit(element.attr('max')).toFixed(decimalPlaces)); + newValue = toFahrenheit(oldValue).toFixed(decimalPlaces); } else { - const convertedValue = Number((oldValue / multiplier).toFixed(2)); - newValue = Number.isInteger(convertedValue) ? Math.round(convertedValue) : convertedValue; + newValue = Number((oldValue / multiplier)).toFixed(decimalPlaces); } + element.val(newValue); element.data('setting-multiplier', multiplier); @@ -564,12 +560,36 @@ var Settings = (function () { value = Math.round(((parseFloat(input.val())-32) / 1.8) * 10); } else { multiplier = parseFloat(multiplier); - value = Math.round(parseFloat(input.val()) * multiplier); + + let presicion = input.data("step") || 1; // data-step is always based on the default firmware units. + presicion = self.countDecimals(presicion); + + if (presicion === 0) { + value = Math.round(parseFloat(input.val()) * multiplier); + } else { + value = Math.round((parseFloat(input.val()) * multiplier) * Math.pow(10, presicion)) / Math.pow(10, presicion); + } } } + return mspHelper.setSetting(settingName, value); }; + self.countDecimals = function(value) { + let text = value.toString() + // verify if number 0.000005 is represented as "5e-6" + if (text.indexOf('e-') > -1) { + let [base, trail] = text.split('e-'); + let deg = parseInt(trail, 10); + return deg; + } + // count decimals for number in representation like "0.123456" + if (Math.floor(value) !== value) { + return value.toString().split(".")[1].length || 0; + } + return 0; + }; + self.saveInputs = function() { var inputs = []; $('[data-setting!=""][data-setting]').each(function() { |