1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-14 20:10:11 +03:00

RXFAIL send method that allows more future RX channels

- Fixed the bug found by Nighthawk32
- Correction for camelCase
- Some bugfixes
This commit is contained in:
ProDrone 2015-12-16 00:39:58 +01:00
parent 31fa4bfaa2
commit 1a0c6735a9
3 changed files with 68 additions and 32 deletions

View file

@ -800,12 +800,14 @@ var MSP = {
offset++;
FAILSAFE_CONFIG.failsafe_throttle = data.getUint16(offset, 1);
offset += 2;
FAILSAFE_CONFIG.failsafe_kill_switch = data.getUint8(offset, 1);
offset++;
FAILSAFE_CONFIG.failsafe_throttle_low_delay = data.getUint16(offset, 1);
offset += 2;
FAILSAFE_CONFIG.failsafe_procedure = data.getUint8(offset, 1);
offset++;
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
FAILSAFE_CONFIG.failsafe_kill_switch = data.getUint8(offset, 1);
offset++;
FAILSAFE_CONFIG.failsafe_throttle_low_delay = data.getUint16(offset, 1);
offset += 2;
FAILSAFE_CONFIG.failsafe_procedure = data.getUint8(offset, 1);
offset++;
}
break;
case MSP_codes.MSP_RXFAIL_CONFIG:
@ -1178,17 +1180,11 @@ MSP.crunch = function (code) {
buffer.push(FAILSAFE_CONFIG.failsafe_off_delay);
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_throttle));
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle));
buffer.push(FAILSAFE_CONFIG.failsafe_kill_switch);
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay));
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay));
buffer.push(FAILSAFE_CONFIG.failsafe_procedure);
break;
case MSP_codes.MSP_SET_RXFAIL_CONFIG:
for (var i = 0; i < RXFAIL_CONFIG.length; i++) {
buffer.push(RXFAIL_CONFIG[i].mode);
buffer.push(lowByte(RXFAIL_CONFIG[i].value));
buffer.push(highByte(RXFAIL_CONFIG[i].value));
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
buffer.push(FAILSAFE_CONFIG.failsafe_kill_switch);
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay));
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay));
buffer.push(FAILSAFE_CONFIG.failsafe_procedure);
}
break;
@ -1312,10 +1308,10 @@ MSP.sendServoConfigurations = function(onCompleteCallback) {
if (SERVO_CONFIG.length == 0) {
onCompleteCallback();
} else {
nextFunction();
}
nextFunction();
function send_next_servo_configuration() {
var buffer = [];
@ -1402,11 +1398,10 @@ MSP.sendModeRanges = function(onCompleteCallback) {
if (MODE_RANGES.length == 0) {
onCompleteCallback();
} else {
send_next_mode_range();
}
send_next_mode_range();
function send_next_mode_range() {
var modeRange = MODE_RANGES[modeRangeIndex];
@ -1435,11 +1430,10 @@ MSP.sendAdjustmentRanges = function(onCompleteCallback) {
if (ADJUSTMENT_RANGES.length == 0) {
onCompleteCallback();
} else {
send_next_adjustment_range();
}
send_next_adjustment_range();
function send_next_adjustment_range() {
var adjustmentRange = ADJUSTMENT_RANGES[adjustmentRangeIndex];
@ -1471,9 +1465,9 @@ MSP.sendLedStripConfig = function(onCompleteCallback) {
if (LED_STRIP.length == 0) {
onCompleteCallback();
} else {
send_next_led_strip_config();
}
send_next_led_strip_config();
function send_next_led_strip_config() {
@ -1540,3 +1534,34 @@ MSP.serialPortFunctionsToMask = function(functions) {
}
return mask;
}
MSP.sendRxFailConfig = function(onCompleteCallback) {
var nextFunction = send_next_rxfail_config;
var rxFailIndex = 0;
if (RXFAIL_CONFIG.length == 0) {
onCompleteCallback();
} else {
send_next_rxfail_config();
}
function send_next_rxfail_config() {
var rxFail = RXFAIL_CONFIG[rxFailIndex];
var buffer = [];
buffer.push(rxFailIndex);
buffer.push(rxFail.mode);
buffer.push(lowByte(rxFail.value));
buffer.push(highByte(rxFail.value));
// prepare for next iteration
rxFailIndex++;
if (rxFailIndex == RXFAIL_CONFIG.length) {
nextFunction = onCompleteCallback;
}
MSP.send_message(MSP_codes.MSP_SET_RXFAIL_CONFIG, buffer, false, nextFunction);
}
};