mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-17 13:25:22 +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 = [{
|
||||
"title": 'Mini Quad with 3"-7" propellers',
|
||||
"id": 2,
|
||||
"settings": {
|
||||
"gyro_lpf": "256HZ",
|
||||
"looptime": 500
|
||||
}
|
||||
"settings": [
|
||||
{
|
||||
key: "gyro_hardware_lpf",
|
||||
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',
|
||||
"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',
|
||||
"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");
|
||||
};
|
||||
|
||||
privateScope.onPresetClick = function(event) {
|
||||
let preset = data[$(event.currentTarget).data("index")];
|
||||
if (preset) {
|
||||
privateScope.setFeaturesBits = function (selectedDefaultPreset) {
|
||||
|
||||
let promises = {};
|
||||
Object.keys(presets.settings).forEach(function(key, ii) {
|
||||
let value = presets.settings[key];
|
||||
promises[key] = mspHelper.setSetting(name, value);
|
||||
if (selectedDefaultPreset.features && selectedDefaultPreset.features.length > 0) {
|
||||
|
||||
for (let i in selectedDefaultPreset.features) {
|
||||
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);
|
||||
// Promise.props(promises).then(function() {
|
||||
// saveChainer.execute();
|
||||
// });
|
||||
privateScope.setSettings = function (selectedDefaultPreset) {
|
||||
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
||||
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() {
|
||||
let $place = $container.find('.defaults-dialog__options');
|
||||
$place.html("");
|
||||
for (let i in data) {
|
||||
if (data.hasOwnProperty(i)) {
|
||||
let preset = data[i];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue