Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion tabs/outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function srxl2StatusArrived(resp) {
const outputsTab = {
allowTestMode: false,
srxl2Calibrating: false,
srxl2Starting: false, // Start sent, the status that confirms it not back yet
feature3DEnabled: false
};
outputsTab.initialize = function (callback) {
Expand Down Expand Up @@ -236,6 +237,7 @@ outputsTab.initialize = function (callback) {
function srxl2CalStop() {
interval.remove(SRXL2_POLL);
outputsTab.srxl2Calibrating = false;
outputsTab.srxl2Starting = false;
$('#srxl2-cal-abort').hide();
$('#srxl2-cal-start').show();
$('#srxl2-cal-ack').prop('checked', false);
Expand All @@ -248,6 +250,10 @@ outputsTab.initialize = function (callback) {

function srxl2CalPoll() {
MSP.send_message(MSPCodes.MSP2_INAV_ESC_SRXL2_STATUS, false, false, function (resp) {
/* A reply on its way when the sequence was called off must not bring its status back */
if (!outputsTab.srxl2Calibrating) {
return;
}
if (!srxl2StatusArrived(resp)) {
return; /* one lost poll; the next one in 500 ms decides */
}
Expand Down Expand Up @@ -325,6 +331,12 @@ outputsTab.initialize = function (callback) {
? i18n.getMessage('srxl2PortCountOpen', [ports, motors])
: i18n.getMessage('srxl2PortCountOpenNoMixer', [ports]));
} else {
/* Another protocol hides the Abort button with the box, and the
* firmware would go on holding full throttle: call the sequence off. */
if (outputsTab.srxl2Calibrating || outputsTab.srxl2Starting) {
MSP.send_message(MSPCodes.MSP2_INAV_ESC_SRXL2_CALIBRATE, [SRXL2_CAL_OFF], false);
srxl2CalShow('srxl2CalibrateAborted');
}
srxl2CalStop();
}
}
Expand Down Expand Up @@ -363,6 +375,7 @@ outputsTab.initialize = function (callback) {
return;
}
const data = [SRXL2_CAL_WAIT_BATTERY];
outputsTab.srxl2Starting = true;
MSP.send_message(MSPCodes.MSP2_INAV_ESC_SRXL2_CALIBRATE, data, false, function () {
/*
* The callback fires whether or not the firmware accepted: this is
Expand All @@ -372,6 +385,11 @@ outputsTab.initialize = function (callback) {
* a sequence that never started, then reports it finished.
*/
MSP.send_message(MSPCodes.MSP2_INAV_ESC_SRXL2_STATUS, false, false, function (resp) {
/* Called off on the way (protocol changed, tab left): the stop went out after the start */
if (!outputsTab.srxl2Starting) {
return;
}
outputsTab.srxl2Starting = false;
if (!srxl2StatusArrived(resp)) {
srxl2CalShow('srxl2CalibrateRefused');
$('#srxl2-cal-ack').prop('checked', false);
Expand Down Expand Up @@ -1047,8 +1065,9 @@ outputsTab.cleanup = function (callback) {
* throttle on the wire while it waits for the battery, and a control that
* has gone off screen is not a reason to leave it holding.
*/
if (outputsTab.srxl2Calibrating) {
if (outputsTab.srxl2Calibrating || outputsTab.srxl2Starting) {
outputsTab.srxl2Calibrating = false;
outputsTab.srxl2Starting = false;
MSP.send_message(MSPCodes.MSP2_INAV_ESC_SRXL2_CALIBRATE, [SRXL2_CAL_OFF], false, function () {
if (callback) callback();
});
Expand Down
Loading