mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
Backend for getting logic conditions from FC
This commit is contained in:
parent
3c7cf5fc47
commit
d6ded2404e
8 changed files with 166 additions and 5 deletions
|
@ -534,13 +534,33 @@ var mspHelper = (function (gui) {
|
|||
}
|
||||
}
|
||||
SERVO_RULES.cleanup();
|
||||
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP_SET_SERVO_MIX_RULE:
|
||||
console.log("Servo mix saved");
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_INAV_LOGIC_CONDITIONS:
|
||||
LOGIC_CONDITIONS.flush();
|
||||
if (data.byteLength % 13 === 0) {
|
||||
for (i = 0; i < data.byteLength; i += 13) {
|
||||
LOGIC_CONDITIONS.put(new LogicCondition(
|
||||
data.getInt8(i),
|
||||
data.getInt8(i + 1),
|
||||
data.getInt8(i + 2),
|
||||
data.getInt32(i + 3, true),
|
||||
data.getInt8(i + 7),
|
||||
data.getInt32(i + 8, true),
|
||||
data.getInt8(i + 12)
|
||||
));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_INAV_SET_LOGIC_CONDITIONS:
|
||||
console.log("Logic conditions saved");
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_COMMON_MOTOR_MIXER:
|
||||
MOTOR_RULES.flush();
|
||||
|
||||
|
@ -2330,6 +2350,54 @@ var mspHelper = (function (gui) {
|
|||
}
|
||||
};
|
||||
|
||||
self.loadLogicConditions = function (callback) {
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "2.2.0")) {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_LOGIC_CONDITIONS, false, false, callback);
|
||||
}
|
||||
}
|
||||
|
||||
self.sendLogicConditions = function (onCompleteCallback) {
|
||||
let nextFunction = sendCondition,
|
||||
conditionIndex = 0;
|
||||
|
||||
if (LOGIC_CONDITIONS.getCount() == 0 || semver.lt(CONFIG.flightControllerVersion, "2.2.0")) {
|
||||
onCompleteCallback();
|
||||
} else {
|
||||
nextFunction();
|
||||
}
|
||||
|
||||
function sendCondition() {
|
||||
|
||||
let buffer = [];
|
||||
|
||||
// send one at a time, with index
|
||||
|
||||
let condition = LOGIC_CONDITIONS.get()[conditionIndex];
|
||||
|
||||
buffer.push(conditionIndex);
|
||||
buffer.push(condition.getEnabled());
|
||||
buffer.push(condition.getOperation());
|
||||
buffer.push(condition.getOperandAType());
|
||||
buffer.push(specificByte(condition.getOperandAValue(), 0));
|
||||
buffer.push(specificByte(condition.getOperandAValue(), 1));
|
||||
buffer.push(specificByte(condition.getOperandAValue(), 2));
|
||||
buffer.push(specificByte(condition.getOperandAValue(), 3));
|
||||
buffer.push(condition.getOperandBType());
|
||||
buffer.push(specificByte(condition.getOperandAValue(), 0));
|
||||
buffer.push(specificByte(condition.getOperandAValue(), 1));
|
||||
buffer.push(specificByte(condition.getOperandAValue(), 2));
|
||||
buffer.push(specificByte(condition.getOperandAValue(), 3));
|
||||
buffer.push(condition.getFlags());
|
||||
|
||||
// prepare for next iteration
|
||||
conditionIndex++;
|
||||
if (conditionIndex == LOGIC_CONDITIONS.getCount()) { //This is the last rule. Not pretty, but we have to send all rules
|
||||
nextFunction = onCompleteCallback;
|
||||
}
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SET_LOGIC_CONDITIONS, buffer, false, nextFunction);
|
||||
}
|
||||
};
|
||||
|
||||
self.sendModeRanges = function (onCompleteCallback) {
|
||||
var nextFunction = send_next_mode_range;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue