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/fcu): Fixed FCU ALT selector immediately switching to 1000s when interval selected #9784

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1566,3 +1566,4 @@
Discord)
1. [EFB] Restructured APIs and made Navigraph Auth a reusable component - @MicahBCode (Mischa Binder)
1. [ECAM] Added F units to CRZ and COND pages for Cabin temps. Currently tied to kg/lbs option in EFB -Patrick Macken (@PatM on Discord)
1. [A32NX/FCU] Fixed bug where the FCU selected altitude would immediately switch to 1000s on selecting the 1000ft inteval knob - @elliot747 (Elliot)
36 changes: 28 additions & 8 deletions fbw-a32nx/src/wasm/fbw_a320/src/model/FcuComputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,14 +942,34 @@ void FcuComputer::step()
FcuComputer_DWork.pValue_h = FcuComputer_U.in.sim_input.alt;
}

if (FcuComputer_U.in.discrete_inputs.afs_inputs.alt_increment_1000) {
FcuComputer_DWork.pValue_h = std::round((static_cast<real32_T>
(FcuComputer_U.in.discrete_inputs.afs_inputs.alt_knob.turns) * 1000.0F + FcuComputer_DWork.pValue_h) / 1000.0F) *
1000.0F;
} else {
FcuComputer_DWork.pValue_h = std::round((static_cast<real32_T>
(FcuComputer_U.in.discrete_inputs.afs_inputs.alt_knob.turns) * 100.0F + FcuComputer_DWork.pValue_h) / 100.0F) *
100.0F;
if (FcuComputer_U.in.discrete_inputs.afs_inputs.alt_knob.turns != FcuComputer_P.CompareToConstant_const) {
if (FcuComputer_U.in.discrete_inputs.afs_inputs.alt_increment_1000) {
// In the case altitude is still in 100s, ensure a turn doesn't count for more than 1000ft (e.g. 6300ft turn -1 should be 6000ft,
// not 5000ft)
real32_T orig_value = FcuComputer_DWork.pValue_h;
real32_T new_value = std::round((static_cast<real32_T>(FcuComputer_U.in.discrete_inputs.afs_inputs.alt_knob.turns) * 1000.0F +
FcuComputer_DWork.pValue_h) /
1000.0F) *
1000.0F;

real32_T max_delta = std::abs(FcuComputer_U.in.discrete_inputs.afs_inputs.alt_knob.turns * 1000.0F);
real32_T delta = std::abs(new_value - orig_value);
if (delta > max_delta) {
if (FcuComputer_U.in.discrete_inputs.afs_inputs.alt_knob.turns > 0)
new_value -= 1000.0F;
else
new_value += 1000.0F;
}

FcuComputer_DWork.pValue_h = new_value;

} else {
FcuComputer_DWork.pValue_h =
std::round(
(static_cast<real32_T>(FcuComputer_U.in.discrete_inputs.afs_inputs.alt_knob.turns) * 100.0F + FcuComputer_DWork.pValue_h) /
100.0F) *
100.0F;
}
}

FcuComputer_DWork.pValue_h = std::fmax(std::fmin(FcuComputer_DWork.pValue_h, 49000.0F), 100.0F);
Expand Down
Loading