1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-24 00:35:20 +03:00

Improve Outputs handling

This commit is contained in:
Pawel Spychalski (DzikuVx) 2019-11-21 19:52:28 +01:00
parent 73015617c7
commit 34a4057f79
2 changed files with 14 additions and 30 deletions

View file

@ -45,6 +45,13 @@ helper.features = (function() {
toUnset.push(bit);
};
publicScope.updateUI = function ($container, values) {
$container.find('[data-bit].feature').each(function () {
let $this = $(this);
$this.prop('checked', bit_check(values, $this.attr("data-bit")));
});
};
publicScope.fromUI = function ($container) {
$container.find('[data-bit].feature').each(function () {

View file

@ -150,34 +150,7 @@ TABS.motors.initialize = function (callback) {
$('#servo-rate-container').show();
/*
* Set all features ON/OFF
*/
let features = FC.getFeatures();
for (let i in features) {
if (features.hasOwnProperty(i)) {
let $html = $(".feature[data-bit='" +features[i].bit + "']");
if ($html.length) {
$html.prop('checked', bit_check(BF_CONFIG.features, features[i].bit));
}
}
}
/*
$('input[type="checkbox"].feature').change(function () {
let element = $(this),
index = element.data('bit'),
state = element.is(':checked');
if (state) {
BF_CONFIG.features = bit_set(BF_CONFIG.features, index);
} else {
BF_CONFIG.features = bit_clear(BF_CONFIG.features, index);
}
});
*/
helper.features.updateUI($('.tab-motors'), BF_CONFIG.features);
GUI.simpleBind();
}
@ -349,7 +322,9 @@ TABS.motors.initialize = function (callback) {
});
$('a.update').click(function () {
servos_update();
helper.features.reset();
helper.features.fromUI($('.tab-motors'));
helper.features.execute(servos_update);
});
$('a.save').click(function () {
saveChainer.setExitPoint(function () {
@ -363,7 +338,9 @@ TABS.motors.initialize = function (callback) {
});
});
});
servos_update();
helper.features.reset();
helper.features.fromUI($('.tab-motors'));
helper.features.execute(servos_update);
});
}