From 515984801ca944dea850cd5b0f55c1541f619dac Mon Sep 17 00:00:00 2001 From: elliot747 Date: Sun, 19 Jan 2025 00:10:09 +0000 Subject: [PATCH 1/2] fix(a32nx/fcu) Fixed fcu alt rounding immediatly on interval set to 1000s --- .../wasm/fbw_a320/src/model/FcuComputer.cpp | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/fbw-a32nx/src/wasm/fbw_a320/src/model/FcuComputer.cpp b/fbw-a32nx/src/wasm/fbw_a320/src/model/FcuComputer.cpp index 0b0e0c29f97..3530116f5b6 100644 --- a/fbw-a32nx/src/wasm/fbw_a320/src/model/FcuComputer.cpp +++ b/fbw-a32nx/src/wasm/fbw_a320/src/model/FcuComputer.cpp @@ -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 - (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 - (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(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(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); From df14b2fc98f7251aa3f81f9f72f2b6fc086e5910 Mon Sep 17 00:00:00 2001 From: elliot747 Date: Sun, 19 Jan 2025 00:23:21 +0000 Subject: [PATCH 2/2] Commiting change log entry with info on change made --- .github/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index a92b729492d..dd1647ddad8 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -1562,3 +1562,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)