Skip to content

Commit

Permalink
fix(ecam): fix ALL button behavior being inconsitent + cycling throug…
Browse files Browse the repository at this point in the history
…h STS page (flybywiresim#8916)

* Fixes ALL button behavior being inconsitent + cycling through STS page

* added changelog

* dont cycle through cruise page

* Apply information from new references

* Added a small delay to the LED on the ecam button lighting up when switching with the ALL button based on references
  • Loading branch information
Maximilian-Reuter authored Sep 21, 2024
1 parent 3afe455 commit 497d0a8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
1. [MODEL] Replaced overhead decals - @Repsol2k
1. [MODEL] General improvements to 3d model and textures - @MoreRightRudder, @Repsol2k, @tracernz
1. [MODEL] Folding armrests - @Repsol2k
1. [LIGHTING] Fixed Automatic Lighting on Spawn depending on outside lightcondition - @Maximilian-Reuter (\_Chaoz_)
1. [LIGHTING] Fixed Automatic Lighting on Spawn depending on outside lightcondition - @Maximilian-Reuter (\_chaoz_)
1. [EFCS] Implement calculated yaw damper gain - @lukecologne (luke)
1. [EFCS] Decrease yaw damper at low speeds on ground, down to 0 below 40kts - @lukecologne (luke)
1. [FLIGHTMODEL] Fix pitch trim on approach - @donstim (donbikes)
Expand Down Expand Up @@ -119,6 +119,7 @@
1. [FADEC] Added quick start for engines and APU - @frankkopp (Frank Kopp) - @Gurgel100 (Pascal)
1. [EFB] Added expedited presets - @frankkopp (Frank Kopp)
1. [FMS] Show runway ident on lateral/vertical revision page of the missed approach point - @BlueberryKing (BlueberryKing)
1. [ECAM] Fixed ALL ECAM Button cycling through STS page and being inconsisten on press - @Maximilian-Reuter (\_chaoz_)

## 0.11.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@
<ANIM_TEMPLATE>FBW_ECAM_PAGE_BUTTON_Template</ANIM_TEMPLATE>
<BASE_NAME>STS</BASE_NAME>
<Part_ID>STS</Part_ID>
<GROUP_INDEX>11</GROUP_INDEX> <!--Change to positive to activate-->
<GROUP_INDEX>12</GROUP_INDEX> <!--Change to positive to activate-->
<TOOLTIPID>Display STS informations on ECAM</TOOLTIPID>
</UseTemplate>

Expand Down
50 changes: 31 additions & 19 deletions fbw-a32nx/src/systems/instruments/src/SD/PagesContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,29 @@ enum SdPages {
Door = 8,
Wheel = 9,
Fctl = 10,
Status = 11,
Crz = 12,
Crz = 11,
Status = 12,
}

const CRZ_CONDITION_TIMER_DURATION = 60;
const ENG_CONDITION_TIMER_DURATION = 10;
const APU_CONDITION_TIMER_DURATION = 15;
const FCTL_CONDITION_TIMER_DURATION = 20;
const STS_DISPLAY_TIMER_DURATION = 3;
const ECAM_LIGHT_DELAY_ALL = 200;

export const PagesContainer = () => {
const [currentPage, setCurrentPage] = useState(SdPages.Door);
const [prevFailPage, setPrevFailPage] = useState(SdPages.Eng);
const [ecamCycleInterval, setEcamCycleInterval] = useState(-1);
const [ecamButtonLightDelayTimer, setEcamButtonLightDelayTimer] = useState(Number.MIN_SAFE_INTEGER);
const [failPage] = useSimVar('L:A32NX_ECAM_SFAIL', 'Enum', 300);

const [prevEcamAllButtonState, setPrevEcamAllButtonState] = useState(false);

const [pageWhenUnselected, setPageWhenUnselected] = useState(SdPages.Door);

const [ecamAllButtonPushed] = useSimVar('L:A32NX_ECAM_ALL_Push_IsDown', 'Bool', 100);
const [ecamAllButtonPushed] = useSimVar('L:A32NX_ECAM_ALL_Push_IsDown', 'Bool', 20);
const [fwcFlightPhase] = useSimVar('L:A32NX_FWC_FLIGHT_PHASE', 'Enum', 500);
const [crzCondTimer, setCrzCondTimer] = useState(CRZ_CONDITION_TIMER_DURATION);
const [ecamFCTLTimer, setEcamFCTLTimer] = useState(FCTL_CONDITION_TIMER_DURATION);
Expand Down Expand Up @@ -118,17 +120,28 @@ export const PagesContainer = () => {
};

const updateCallback = (deltaTime) => {
if (ecamButtonLightDelayTimer != Number.MIN_SAFE_INTEGER) {
setEcamButtonLightDelayTimer((t) => t - deltaTime);
if (ecamButtonLightDelayTimer <= 0) {
setPage(currentPage);
setEcamButtonLightDelayTimer(Number.MIN_SAFE_INTEGER);
}
}
if (ecamAllButtonPushed && !prevEcamAllButtonState) {
// button press
setPage((prev) => (prev + 1) % 12);
setCurrentPage((prev) => (prev + 1) % 12);
setCurrentPage((prev) => {
prev = page === SdPages.None ? SdPages.Eng : prev + 1;
setEcamButtonLightDelayTimer(ECAM_LIGHT_DELAY_ALL);
return prev % 11;
});
setEcamCycleInterval(
setInterval(() => {
setCurrentPage((prev) => {
setPage((prev + 1) % 12);
return (prev + 1) % 12;
prev = Math.min(prev + 1, SdPages.Fctl);
setEcamButtonLightDelayTimer(ECAM_LIGHT_DELAY_ALL);
return prev;
});
}, 1000) as unknown as number,
}, 3000) as unknown as number,
);
} else if (!ecamAllButtonPushed && prevEcamAllButtonState) {
// button release
Expand All @@ -138,12 +151,13 @@ export const PagesContainer = () => {
setStsPrevPage(currentPage);
}
const newPage = page;
if (newPage !== -1) {
setCurrentPage(newPage);
} else {
setCurrentPage(pageWhenUnselected);
if (ecamButtonLightDelayTimer === Number.MIN_SAFE_INTEGER) {
if (newPage !== -1) {
setCurrentPage(newPage);
} else {
setCurrentPage(pageWhenUnselected);
}
}

switch (fwcFlightPhase) {
case 10:
case 1:
Expand Down Expand Up @@ -234,19 +248,17 @@ export const PagesContainer = () => {

// Disable user selected page when new failure detected
if (prevFailPage !== failPage) {
setCurrentPage(SdPages.None);
setPage(SdPages.None);
}
}

// switch page when desired page was changed, or new Failure detected
if ((pageWhenUnselected !== newPage && page === SdPages.None) || prevFailPage !== failPage) {
// switch page when new Failure detected
if (prevFailPage !== failPage) {
setCurrentPage(pageWhenUnselected);
}

setPrevFailPage(failPage);
}

setPrevEcamAllButtonState(ecamAllButtonPushed);
};

Expand All @@ -264,8 +276,8 @@ export const PagesContainer = () => {
8: <DoorPage />,
9: <WheelPage />,
10: <FctlPage />,
11: <StatusPage />,
12: <CrzPage />,
11: <CrzPage />,
12: <StatusPage />,
};

return (
Expand Down

0 comments on commit 497d0a8

Please sign in to comment.