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

correctly set number of motors and servos

This commit is contained in:
Pawel Spychalski (DzikuVx) 2018-04-04 19:42:14 +02:00
parent 640d0b39a3
commit 34c13c5010
5 changed files with 31 additions and 13 deletions

3
.gitignore vendored
View file

@ -13,4 +13,5 @@ inav-configurator.iml
/dist
# Path where the NW.js apps get built
/apps
/.vscode/
/.vscode/
.eslintrc.json

View file

@ -171,7 +171,9 @@ var FC = {
yawJumpPreventionLimit: 0,
platformType: -1,
hasFlaps: false,
appliedMixerPreset: -1
appliedMixerPreset: -1,
numberOfMotors: 0,
numberOfServos: 0
},
SERIAL_CONFIG = {

View file

@ -3,17 +3,16 @@
var MotorMixerRuleCollection = function () {
var self = {};
var data = [];
self.motorCount = 0;
let self = {},
data = [],
maxMotorCount = 8;
self.setMotorCount = function (value) {
self.motorCount = value;
maxMotorCount = value;
};
self.getMotorCount = function () {
return self.motorCount;
return maxMotorCount;
};
self.put = function (element) {

View file

@ -183,7 +183,6 @@ var mspHelper = (function (gui) {
needle += 2;
}
MOTOR_RULES.setMotorCount(motorCount);
break;
case MSPCodes.MSP_RC:
RC.active_channels = dataHandler.message_length_expected / 2;
@ -1299,8 +1298,12 @@ var mspHelper = (function (gui) {
MIXER_CONFIG.yawMotorDirection = data.getInt8(0);
MIXER_CONFIG.yawJumpPreventionLimit = data.getUint16(1, true);
MIXER_CONFIG.platformType = data.getInt8(3);
MIXER_CONFIG.hasFlaps = data.getInt8(4)
MIXER_CONFIG.hasFlaps = data.getInt8(4);
MIXER_CONFIG.appliedMixerPreset = data.getInt16(5, true);
MIXER_CONFIG.numberOfMotors = data.getInt8(7);
MIXER_CONFIG.numberOfServos = data.getInt8(8);
MOTOR_RULES.setMotorCount(MIXER_CONFIG.numberOfMotors);
SERVO_RULES.setServoCount(MIXER_CONFIG.numberOfServos);
break;
case MSPCodes.MSP2_INAV_SET_MIXER:

View file

@ -3,8 +3,21 @@
var ServoMixerRuleCollection = function () {
var self = {};
var data = [];
let self = {},
data = [],
maxServoCount = 8;
self.setServoCount = function (value) {
maxServoCount = value;
};
self.getServoCount = function () {
return maxServoCount;
}
self.getServoRulesCount = function () {
return self.getServoCount() * 2;
}
self.put = function (element) {
data.push(element);
@ -42,7 +55,7 @@ var ServoMixerRuleCollection = function () {
};
self.hasFreeSlots = function () {
return data.length < 16;
return data.length < self.getServoRulesCount();
};
return self;