Improve MSP handling of servo configuration. Fixes backup of CJMCU

boards.
10.3.x-maintenance
Dominic Clifton 2015-05-07 22:47:32 +01:00
parent 244685c9a6
commit 0f95f4ec4c
1 changed files with 12 additions and 10 deletions

View File

@ -434,15 +434,17 @@ var MSP = {
case MSP_codes.MSP_SERVO_CONF:
SERVO_CONFIG = []; // empty the array as new data is coming in
for (var i = 0; i < 56; i += 7) {
var arr = {
'min': data.getInt16(i, 1),
'max': data.getInt16(i + 2, 1),
'middle': data.getInt16(i + 4, 1),
'rate': data.getInt8(i + 6)
};
if (data.byteLength % 7 == 0) {
for (var i = 0; i < data.byteLength; i += 7) {
var arr = {
'min': data.getInt16(i, 1),
'max': data.getInt16(i + 2, 1),
'middle': data.getInt16(i + 4, 1),
'rate': data.getInt8(i + 6)
};
SERVO_CONFIG.push(arr);
SERVO_CONFIG.push(arr);
}
}
break;
case MSP_codes.MSP_SET_RAW_RC:
@ -688,7 +690,7 @@ var MSP = {
}
break;
case MSP_codes.MSP_CHANNEL_FORWARDING:
for (var i = 0; i < 8; i ++) {
for (var i = 0; i < data.byteLength && i < SERVO_CONFIG.length; i ++) {
var channelIndex = data.getUint8(i);
if (channelIndex < 255) {
SERVO_CONFIG[i].indexOfChannelToForward = channelIndex;