servo tab cleanup

pull/332/head
Pawel Spychalski (DzikuVx) 7 years ago
parent 4e5fd3b2b7
commit 60497a03e6

@ -23,29 +23,6 @@
</div> </div>
</div> </div>
<div class="clear-both"></div> <div class="clear-both"></div>
<div id="servo-mix-table-wrapper" class="margin-top">
<div class="tab_title" data-i18n="servoMixer">Servo mixer</div>
<div class="btn default_btn narrow pull-right" style="margin-bottom: 15px">
<a href="#" data-role="role-add" data-i18n="servoMixerAdd"></a>
</div>
<table id="servo-mix-table">
<thead>
<tr>
<th style="width: 75px">Servo</th>
<th>Input</th>
<th>Weight</th>
<th>Speed</th>
<th style="width: 75px"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="btn default_btn narrow pull-right" style="margin-bottom: 15px">
<a href="#" data-role="role-add" data-i18n="servoMixerAdd"></a>
</div>
</div>
</div> </div>
<div class="content_toolbar"> <div class="content_toolbar">
<div class="btn save_btn"> <div class="btn save_btn">

@ -15,7 +15,6 @@ TABS.servos.initialize = function (callback) {
mspHelper.loadServoConfiguration, mspHelper.loadServoConfiguration,
mspHelper.loadRcData, mspHelper.loadRcData,
mspHelper.loadBfConfig, mspHelper.loadBfConfig,
mspHelper.loadServoMixRules
]); ]);
loadChainer.setExitPoint(load_html); loadChainer.setExitPoint(load_html);
@ -25,71 +24,17 @@ TABS.servos.initialize = function (callback) {
saveChainer.setChain([ saveChainer.setChain([
mspHelper.sendServoConfigurations, mspHelper.sendServoConfigurations,
mspHelper.sendServoMixer,
mspHelper.saveToEeprom mspHelper.saveToEeprom
]); ]);
saveChainer.setExitPoint(function () { saveChainer.setExitPoint(function () {
GUI.log(chrome.i18n.getMessage('servosEepromSave')); GUI.log(chrome.i18n.getMessage('servosEepromSave'));
SERVO_RULES.cleanup();
renderServoMixRules();
}); });
function load_html() { function load_html() {
$('#content').load("./tabs/servos.html", process_html); $('#content').load("./tabs/servos.html", process_html);
} }
function renderServoMixRules() {
let $servoMixTable = $('#servo-mix-table'),
$servoMixTableBody = $servoMixTable.find('tbody');
/*
* Process servo mix table UI
*/
let rules = SERVO_RULES.get();
$servoMixTableBody.find("*").remove();
for (let servoRuleIndex in rules) {
if (rules.hasOwnProperty(servoRuleIndex)) {
const servoRule = rules[servoRuleIndex];
$servoMixTableBody.append('\
<tr>\
<td><input type="number" class="mix-rule-servo" step="1" min="0" max="7" /></td>\
<td><select class="mix-rule-input"></select></td>\
<td><input type="number" class="mix-rule-rate" step="1" min="-100" max="100" /></td>\
<td><input type="number" class="mix-rule-speed" step="1" min="0" max="255" /></td>\
<td><span class="btn default_btn narrow"><a href="#" data-role="role-delete" data-i18n="servoMixerDelete"></a></span></td>\
</tr>\
');
const $row = $servoMixTableBody.find('tr:last');
GUI.fillSelect($row.find(".mix-rule-input"), FC.getServoMixInputNames(), servoRule.getInput());
$row.find(".mix-rule-input").val(servoRule.getInput()).change(function () {
servoRule.setInput($(this).val());
});
$row.find(".mix-rule-servo").val(servoRule.getTarget()).change(function () {
servoRule.setTarget($(this).val());
});
$row.find(".mix-rule-rate").val(servoRule.getRate()).change(function () {
servoRule.setRate($(this).val());
});
$row.find(".mix-rule-speed").val(servoRule.getSpeed()).change(function () {
servoRule.setSpeed($(this).val());
});
$row.find("[data-role='role-delete']").attr("data-index", servoRuleIndex);
}
}
localize();
}
function update_ui() { function update_ui() {
let i, let i,
@ -179,10 +124,7 @@ TABS.servos.initialize = function (callback) {
}); });
//Save configuration to FC //Save configuration to FC
SERVO_RULES.cleanup();
SERVO_RULES.inflate();
saveChainer.execute(); saveChainer.execute();
} }
// drop previous table // drop previous table
@ -204,19 +146,6 @@ TABS.servos.initialize = function (callback) {
servos_update(true); servos_update(true);
}); });
$servoMixTableBody.on('click', "[data-role='role-delete']", function (event) {
SERVO_RULES.drop($(event.currentTarget).attr("data-index"));
renderServoMixRules();
});
$("[data-role='role-add']").click(function () {
if (SERVO_RULES.hasFreeSlots()) {
SERVO_RULES.put(new ServoMixRule(0, 0, 0, 0));
renderServoMixRules();
}
});
renderServoMixRules();
} }
function process_html() { function process_html() {

Loading…
Cancel
Save