1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-13 19:40:22 +03:00

chainer for motors tab

This commit is contained in:
Pawel Spychalski (DzikuVx) 2018-02-01 15:45:23 +01:00
parent 80dfe85930
commit eb208af39d
5 changed files with 42 additions and 17 deletions

View file

@ -1172,7 +1172,6 @@
"servosEepromSave": {
"message": "EEPROM <span style=\"color: #37a8db\">saved</span>"
},
"gpsHead": {
"message": "GPS"
},

View file

@ -6,6 +6,16 @@ var MotorMixerRuleCollection = function () {
var self = {};
var data = [];
self.motorCount = 0;
self.setMotorCount = function (value) {
self.motorCount = value;
};
self.getMotorCount = function () {
return self.motorCount;
};
self.put = function (element) {
data.push(element);
};
@ -42,7 +52,7 @@ var MotorMixerRuleCollection = function () {
};
self.hasFreeSlots = function () {
return data.length < 8;
return data.length < self.getMotorCount();
};
return self;

View file

@ -177,6 +177,7 @@ var mspHelper = (function (gui) {
needle += 2;
}
MOTOR_RULES.setMotorCount(motorCount);
break;
case MSPCodes.MSP_RC:
RC.active_channels = dataHandler.message_length_expected / 2;
@ -2603,6 +2604,10 @@ var mspHelper = (function (gui) {
}
};
self.loadMotors = function (callback) {
MSP.send_message(MSPCodes.MSP_MOTOR, false, false, callback);
};
self.getCraftName = function(callback) {
if (semver.gt(CONFIG.flightControllerVersion, "1.8.0")) {
MSP.send_message(MSPCodes.MSP_NAME, false, false, function(resp) {

View file

@ -19,25 +19,36 @@ TABS.motors.initialize = function (callback) {
googleAnalytics.sendAppView('Motors');
}
function load_config() {
MSP.send_message(MSPCodes.MSP_BF_CONFIG, false, false, load_3d);
}
function load_3d() {
MSP.send_message(MSPCodes.MSP_3D, false, false, get_motor_data);
}
function get_motor_data() {
update_arm_status();
MSP.send_message(MSPCodes.MSP_MOTOR, false, false, load_html);
}
var loadChainer = new MSPChainerClass();
loadChainer.setChain([
mspHelper.loadMisc,
mspHelper.loadBfConfig,
mspHelper.load3dConfig,
mspHelper.loadMotors,
mspHelper.loadMotorMixRules
]);
loadChainer.setExitPoint(load_html);
loadChainer.execute();
update_arm_status();
var saveChainer = new MSPChainerClass();
saveChainer.setChain([
mspHelper.sendMotorMixer,
mspHelper.saveToEeprom
]);
saveChainer.setExitPoint(function () {
GUI.log(chrome.i18n.getMessage('eeprom_saved_ok'));
MOTOR_RULES.cleanup();
// renderServoMixRules(); //TODO render after save
});
function load_html() {
$('#content').load("./tabs/motors.html", process_html);
}
MSP.send_message(MSPCodes.MSP_MISC, false, false, load_config);
function update_arm_status() {
self.armed = bit_check(CONFIG.mode, 0);
}

View file

@ -47,7 +47,7 @@ TABS.servos.initialize = function (callback) {
*/
var rules = SERVO_RULES.get();
$servoMixTableBody.find("*").remove();
for (servoRuleIndex in rules) {
for (var servoRuleIndex in rules) {
if (rules.hasOwnProperty(servoRuleIndex)) {
const servoRule = rules[servoRuleIndex];