mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-19 22:35:15 +03:00
Setup miniquad defaults
This commit is contained in:
parent
c27d956323
commit
91ffb96e1e
2 changed files with 217 additions and 19 deletions
|
@ -11,19 +11,176 @@ helper.defaultsDialog = (function() {
|
||||||
|
|
||||||
let data = [{
|
let data = [{
|
||||||
"title": 'Mini Quad with 3"-7" propellers',
|
"title": 'Mini Quad with 3"-7" propellers',
|
||||||
"id": 2,
|
"settings": [
|
||||||
"settings": {
|
{
|
||||||
"gyro_lpf": "256HZ",
|
key: "gyro_hardware_lpf",
|
||||||
"looptime": 500
|
value: "256HZ"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
key: "looptime",
|
||||||
|
value: 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "gyro_lpf_hz",
|
||||||
|
value: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "gyro_lpf_type",
|
||||||
|
value: "PT1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "gyro_stage2_lowpass_hz",
|
||||||
|
value: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "dterm_lpf_hz",
|
||||||
|
value: 90
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "use_dterm_fir_filter",
|
||||||
|
value: "OFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_iterm_relax_type",
|
||||||
|
value: "RP"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "d_boost_factor",
|
||||||
|
value: 1.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "antigravity_gain",
|
||||||
|
value: 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "antigravity_accelerator",
|
||||||
|
value: 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "rc_yaw_expo",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "rc_expo",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "roll_rate",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "pitch_rate",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "yaw_rate",
|
||||||
|
value: 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_p_pitch",
|
||||||
|
value: 44
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_i_pitch",
|
||||||
|
value: 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_d_pitch",
|
||||||
|
value: 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_p_roll",
|
||||||
|
value: 40
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_i_roll",
|
||||||
|
value: 50
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_d_roll",
|
||||||
|
value: 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_p_yaw",
|
||||||
|
value: 45
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_i_yaw",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_airmode_type",
|
||||||
|
value: "THROTTLE_THRESHOLD"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "applied_defaults",
|
||||||
|
value: 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"features":[
|
||||||
|
{
|
||||||
|
bit: 5, // Enable DYNAMIC_FILTERS
|
||||||
|
state: true
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": 'Airplane',
|
"title": 'Airplane',
|
||||||
"id": 3
|
"id": 3,
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
key: "rc_yaw_expo",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "rc_expo",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "roll_rate",
|
||||||
|
value: 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "pitch_rate",
|
||||||
|
value: 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "yaw_rate",
|
||||||
|
value: 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "small_angle",
|
||||||
|
value: 180
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "applied_defaults",
|
||||||
|
value: 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"features":[
|
||||||
|
{
|
||||||
|
bit: 4, // Enable MOTOR_STOP
|
||||||
|
state: true
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": 'Custom UAV - INAV legacy defaults',
|
"title": 'Custom UAV - INAV legacy defaults',
|
||||||
"id": 1
|
"settings": [
|
||||||
|
{
|
||||||
|
key: "applied_defaults",
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": 'Keep current settings',
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
key: "applied_defaults",
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -32,26 +189,67 @@ helper.defaultsDialog = (function() {
|
||||||
$container = $("#defaults-wrapper");
|
$container = $("#defaults-wrapper");
|
||||||
};
|
};
|
||||||
|
|
||||||
privateScope.onPresetClick = function(event) {
|
privateScope.setFeaturesBits = function (selectedDefaultPreset) {
|
||||||
let preset = data[$(event.currentTarget).data("index")];
|
|
||||||
if (preset) {
|
|
||||||
|
|
||||||
let promises = {};
|
if (selectedDefaultPreset.features && selectedDefaultPreset.features.length > 0) {
|
||||||
Object.keys(presets.settings).forEach(function(key, ii) {
|
|
||||||
let value = presets.settings[key];
|
for (let i in selectedDefaultPreset.features) {
|
||||||
promises[key] = mspHelper.setSetting(name, value);
|
if (selectedDefaultPreset.features.hasOwnProperty(i)) {
|
||||||
|
let feature = selectedDefaultPreset.features[i];
|
||||||
|
|
||||||
|
if (feature.state) {
|
||||||
|
BF_CONFIG.features = bit_set(BF_CONFIG.features, feature.bit);
|
||||||
|
} else {
|
||||||
|
BF_CONFIG.features = bit_clear(BF_CONFIG.features, feature.bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mspHelper.saveBfConfig(function () {
|
||||||
|
privateScope.setSettings(selectedDefaultPreset);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
privateScope.setSettings(selectedDefaultPreset);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
console.log(promises);
|
privateScope.setSettings = function (selectedDefaultPreset) {
|
||||||
// Promise.props(promises).then(function() {
|
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
||||||
// saveChainer.execute();
|
return mspHelper.getSetting(input.key);
|
||||||
// });
|
}).then(function () {
|
||||||
|
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
||||||
|
return mspHelper.setSetting(input.key, input.value);
|
||||||
|
}).then(function () {
|
||||||
|
mspHelper.saveToEeprom(function () {
|
||||||
|
//noinspection JSUnresolvedVariable
|
||||||
|
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
|
GUI.tab_switch_cleanup(function() {
|
||||||
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
|
||||||
|
//noinspection JSUnresolvedVariable
|
||||||
|
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
||||||
|
GUI.handleReconnect();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
privateScope.onPresetClick = function(event) {
|
||||||
|
$container.hide();
|
||||||
|
let selectedDefaultPreset = data[$(event.currentTarget).data("index")];
|
||||||
|
if (selectedDefaultPreset && selectedDefaultPreset.settings) {
|
||||||
|
|
||||||
|
mspHelper.loadBfConfig(function () {
|
||||||
|
privateScope.setFeaturesBits(selectedDefaultPreset)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
privateScope.render = function() {
|
privateScope.render = function() {
|
||||||
let $place = $container.find('.defaults-dialog__options');
|
let $place = $container.find('.defaults-dialog__options');
|
||||||
|
$place.html("");
|
||||||
for (let i in data) {
|
for (let i in data) {
|
||||||
if (data.hasOwnProperty(i)) {
|
if (data.hasOwnProperty(i)) {
|
||||||
let preset = data[i];
|
let preset = data[i];
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
z-index: 2002;
|
z-index: 2002;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 500px;
|
width: 500px;
|
||||||
height: 280px;
|
height: 320px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue