1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-19 22:35:15 +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

1
.gitignore vendored
View file

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

View file

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

View file

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

View file

@ -183,7 +183,6 @@ var mspHelper = (function (gui) {
needle += 2; needle += 2;
} }
MOTOR_RULES.setMotorCount(motorCount);
break; break;
case MSPCodes.MSP_RC: case MSPCodes.MSP_RC:
RC.active_channels = dataHandler.message_length_expected / 2; RC.active_channels = dataHandler.message_length_expected / 2;
@ -1299,8 +1298,12 @@ var mspHelper = (function (gui) {
MIXER_CONFIG.yawMotorDirection = data.getInt8(0); MIXER_CONFIG.yawMotorDirection = data.getInt8(0);
MIXER_CONFIG.yawJumpPreventionLimit = data.getUint16(1, true); MIXER_CONFIG.yawJumpPreventionLimit = data.getUint16(1, true);
MIXER_CONFIG.platformType = data.getInt8(3); 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.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; break;
case MSPCodes.MSP2_INAV_SET_MIXER: case MSPCodes.MSP2_INAV_SET_MIXER:

View file

@ -3,8 +3,21 @@
var ServoMixerRuleCollection = function () { var ServoMixerRuleCollection = function () {
var self = {}; let self = {},
var data = []; 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) { self.put = function (element) {
data.push(element); data.push(element);
@ -42,7 +55,7 @@ var ServoMixerRuleCollection = function () {
}; };
self.hasFreeSlots = function () { self.hasFreeSlots = function () {
return data.length < 16; return data.length < self.getServoRulesCount();
}; };
return self; return self;