mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-19 14:25:13 +03:00
Basic framework to work with features
This commit is contained in:
parent
0fbdc439ce
commit
78fbb84f9e
3 changed files with 76 additions and 10 deletions
|
@ -1,3 +1,4 @@
|
|||
/*global mspHelper,$,GUI,MSP,BF_CONFIG,chrome*/
|
||||
'use strict';
|
||||
|
||||
var helper = helper || {};
|
||||
|
@ -192,20 +193,17 @@ helper.defaultsDialog = (function() {
|
|||
privateScope.setFeaturesBits = function (selectedDefaultPreset) {
|
||||
|
||||
if (selectedDefaultPreset.features && selectedDefaultPreset.features.length > 0) {
|
||||
helper.features.reset();
|
||||
|
||||
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);
|
||||
}
|
||||
for (const feature of selectedDefaultPreset.features) {
|
||||
if (feature.state) {
|
||||
helper.features.set(feature.bit);
|
||||
} else {
|
||||
helper.features.unset(feature.bit);
|
||||
}
|
||||
}
|
||||
|
||||
mspHelper.saveBfConfig(function () {
|
||||
helper.features.execute(function () {
|
||||
privateScope.setSettings(selectedDefaultPreset);
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue