Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(a32nx/fws): Fix AP disconnection via 3D model inst. disc. push button #9695

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
1. [A380X/ENGINES] Adjust climb thrust to be more accurate - @BlueberryKing (BlueberryKing)
1. [A380X/EWD] Show THR limit in EWD instead of N1 - @flogross89 (floridude)
1. [A380X/FLIGHT MODEL] Fix pitchup and unrecoverable stall - - @donstim (donbikes#4084)
1. [A32NX/FWS] Fix autopilot instinctive disconnect button logic for 3D model - @flogross89 (floridude)

## 0.12.0

Expand Down
14 changes: 13 additions & 1 deletion fbw-a32nx/src/systems/systems-host/systems/FWC/PseudoFWC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class PseudoFWC {
public readonly recallButtonInputBuffer = new NXLogicMemoryNode(false);
public readonly aThrDiscInputBuffer = new NXLogicMemoryNode(false);
public readonly apDiscInputBuffer = new NXLogicMemoryNode(false);
public readonly takeoverPbInputBuffer = new NXLogicMemoryNode(false);

/* PSEUDO FWC VARIABLES */
private readonly startupTimer = new DebounceTimer();
Expand Down Expand Up @@ -1263,6 +1264,13 @@ export class PseudoFWC {
this.recallButtonInputBuffer.write(true, false);
}

if (
SimVar.GetSimVarValue('L:A32NX_PRIORITY_TAKEOVER:1', SimVarValueType.Bool) ||
SimVar.GetSimVarValue('L:A32NX_PRIORITY_TAKEOVER:2', SimVarValueType.Bool)
) {
this.takeoverPbInputBuffer.write(true, false);
}

// Enforce cycle time for the logic computation (otherwise pulse nodes would be broken)
if (deltaTime === -1 || _deltaTime === 0) {
return;
Expand All @@ -1277,7 +1285,10 @@ export class PseudoFWC {
this.clr2PulseNode.write(this.clearButtonInputBuffer.read(), deltaTime);
this.rclUpPulseNode.write(this.recallButtonInputBuffer.read(), deltaTime);
this.autoThrustInstinctiveDiscPressed.write(this.aThrDiscInputBuffer.read(), deltaTime);
this.autoPilotInstinctiveDiscPressedPulse.write(this.apDiscInputBuffer.read(), deltaTime);
this.autoPilotInstinctiveDiscPressedPulse.write(
this.apDiscInputBuffer.read() || this.takeoverPbInputBuffer.read(),
deltaTime,
);

// Inputs update
this.flightPhaseEndedPulseNode.write(false, deltaTime);
Expand Down Expand Up @@ -2904,6 +2915,7 @@ export class PseudoFWC {
this.recallButtonInputBuffer.write(false, true);
this.aThrDiscInputBuffer.write(false, true);
this.apDiscInputBuffer.write(false, true);
this.takeoverPbInputBuffer.write(false, true);
this.autoPilotInstinctiveDiscCountSinceLastFwsCycle = 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,7 @@
<UseTemplate Name="ASOBO_GT_Push_Button_Held">
<TOOLTIPID>%((L:A32NX_AUTOPILOT_ACTIVE, Bool))%{if}Disc. Autopilot%{else}Take priority%{end}</TOOLTIPID>
<LEFT_SINGLE_CODE>
(L:A32NX_AUTOPILOT_ACTIVE, Bool) if{
(&gt;K:AUTOPILOT_OFF)
} els{
1 (&gt;L:A32NX_PRIORITY_TAKEOVER:#ID#)
}
1 (&gt;L:A32NX_PRIORITY_TAKEOVER:#ID#)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually had a discussion about this on Discord recently and the conclusion was that we should use events instead, as short clicks often do not register this way.
Suggest doing both, and reverting the AP change.

Suggested change
1 (&gt;L:A32NX_PRIORITY_TAKEOVER:#ID#)
(&gt;K:AUTOPILOT_OFF)
1 (&gt;L:A32NX_PRIORITY_TAKEOVER:#ID#)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept both the event and Lvar now, but FMGC/AP doesn't react to the PRIORITY_TAKEOVER Lvar anymore (only to the known AP OFF K events)

</LEFT_SINGLE_CODE>
<LEFT_LEAVE_CODE>
0 (&gt;L:A32NX_PRIORITY_TAKEOVER:#ID#)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export class FwsCore {
public readonly clDownInputBuffer = new NXLogicMemoryNode(false);
public readonly aThrDiscInputBuffer = new NXLogicMemoryNode(false);
public readonly apDiscInputBuffer = new NXLogicMemoryNode(false);
public readonly takeoverPbInputBuffer = new NXLogicMemoryNode(false);

/* PSEUDO FWC VARIABLES */

Expand Down Expand Up @@ -1816,6 +1817,13 @@ export class FwsCore {
this.clDownInputBuffer.write(true, false);
}

if (
SimVar.GetSimVarValue('L:A32NX_PRIORITY_TAKEOVER:1', SimVarValueType.Bool) ||
SimVar.GetSimVarValue('L:A32NX_PRIORITY_TAKEOVER:2', SimVarValueType.Bool)
) {
this.takeoverPbInputBuffer.write(true, false);
}

// Enforce cycle time for the logic computation (otherwise pulse nodes would be broken)
if (deltaTime === -1 || _deltaTime === 0) {
return;
Expand All @@ -1839,7 +1847,10 @@ export class FwsCore {
this.clUpPulseNode.write(this.clUpInputBuffer.read(), deltaTime);
this.clDownPulseNode.write(this.clDownInputBuffer.read(), deltaTime);
this.autoThrustInstinctiveDiscPressed.write(this.aThrDiscInputBuffer.read(), deltaTime);
this.autoPilotInstinctiveDiscPressedPulse.write(this.apDiscInputBuffer.read(), deltaTime);
this.autoPilotInstinctiveDiscPressedPulse.write(
this.apDiscInputBuffer.read() || this.takeoverPbInputBuffer.read(),
deltaTime,
);

// Inputs update
this.flightPhaseEndedPulseNode.write(false, deltaTime);
Expand Down Expand Up @@ -4143,6 +4154,7 @@ export class FwsCore {
this.clDownInputBuffer.write(false, true);
this.aThrDiscInputBuffer.write(false, true);
this.apDiscInputBuffer.write(false, true);
this.takeoverPbInputBuffer.write(false, true);
this.autoPilotInstinctiveDiscCountSinceLastFwsCycle = 0;
}

Expand Down
3 changes: 2 additions & 1 deletion fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2141,7 +2141,8 @@ bool FlyByWireInterface::updateAutopilotStateMachine(double sampleTime) {
autopilotStateMachineInput.in.input.AP_ENGAGE_push = simInputAutopilot.AP_engage;
autopilotStateMachineInput.in.input.AP_1_push = simInputAutopilot.AP_1_push;
autopilotStateMachineInput.in.input.AP_2_push = simInputAutopilot.AP_2_push;
autopilotStateMachineInput.in.input.AP_DISCONNECT_push = simInputAutopilot.AP_disconnect || wasInSlew || doDisconnect;
autopilotStateMachineInput.in.input.AP_DISCONNECT_push = simInputAutopilot.AP_disconnect || idCaptPriorityButtonPressed->get() ||
idFoPriorityButtonPressed->get() || wasInSlew || doDisconnect;
autopilotStateMachineInput.in.input.HDG_push = simInputAutopilot.HDG_push;
autopilotStateMachineInput.in.input.HDG_pull = simInputAutopilot.HDG_pull;
autopilotStateMachineInput.in.input.ALT_push = simInputAutopilot.ALT_push;
Expand Down
Loading