Skip to content

Commit

Permalink
fix(a32nx/fws): Fix AP disconnection via 3D model inst. disc. push bu…
Browse files Browse the repository at this point in the history
…tton
  • Loading branch information
flogross89 committed Dec 31, 2024
1 parent 125a86d commit 6bf113d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
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#)
</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

0 comments on commit 6bf113d

Please sign in to comment.