Skip to content

Commit

Permalink
fix(rmp): RMP behaviour and lights #7105 (@08f7009)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueberryKing authored and 2hwk committed Aug 9, 2022
1 parent 2e0244f commit 63f21ab
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
1. [FLIGHTMODEL] Improve flight handling characteristics, ground effect, and landing gear simulation - @donstim (donbikes#4084)
1. [MODEL] Remove blue highlights in lock mode - @tracernz (Mike)
1. [EFB] Added Payload Loading to EFB - @2hwk (2Cas#1022)
1. [RMP] Fixed the behavior of the RMPs and ACPs (VHFs only) - Julian Sebline (Julian Sebline#8476 on Discord)

## 0.8.0

Expand Down Expand Up @@ -1098,5 +1099,4 @@
1. [MISC] Standby Instrument stays ON if emergency power should be available, bug fixes - @2hwk (2Cas#1022 on discord)
1. [CDU] Full +/- button functionality - @lhoenig (Lukas Hoenig)
1. [DCDU] Fixed MSG- and MSG+ button labels - @tyler58546 (tyler58546)
1. [OVHD] Fixed fire push button not being able to be stowed - Julian Sebline (Julian Sebline#8476 on Discord)
1. [ISIS] Fixed issue where ISIS was allowing a bug to be set while in the OFF state - Patrick Macken (@Pat M on Discord)
241 changes: 132 additions & 109 deletions flybywire-aircraft-a320-neo/ModelBehaviorDefs/A32NX/AirlinerCommon.xml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

43 changes: 39 additions & 4 deletions src/behavior/src/A32NX_Interior_RMP.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@
</Component>

<!-- Panel transfer button -->
<!-- Force COM3_RADIO_SET_HZ to 0 to show "DATA" at startup -->
<Component ID="RMP_TRANSFER_BUTTON_#SIDE#" Node="PUSH_RADIO#SIDE#_ARROWS">
<Update Once="True">
0 (&gt;K:COM3_RADIO_SET_HZ)
</Update>
<UseTemplate Name="FBW_Anim_Interactions">
<ANIM_TYPE>BUTTON</ANIM_TYPE>
<ANIM_TEMPLATE>ASOBO_GT_Push_Button</ANIM_TEMPLATE>
Expand Down Expand Up @@ -132,20 +136,50 @@
<BASE_NAME>AM</BASE_NAME>
</UseTemplate>

<!-- SEL word indicator light -->
<Component ID="PUSH_RADIO#SIDE#_SEL_SEQ1" Node="PUSH_RADIO#SIDE#_SEL_SEQ1">
<UseTemplate Name="ASOBO_GT_Emissive_Gauge">
<POTENTIOMETER>7</POTENTIOMETER>
<EMISSIVE_CODE type="rnp" return="number">
let indicatorsPowered = #INDICATORS_POWERED, bool#;
let id = #ID, number#;
alias toggleSwitch = (L:A32NX_RMP_#SIDE#_TOGGLE_SWITCH, bool);
alias selectedModeLeft = (L:A32NX_RMP_L_SELECTED_MODE, number);
alias selectedModeRight = (L:A32NX_RMP_R_SELECTED_MODE, number);
alias annunciatorLight = (L:A32NX_OVHD_INTLT_ANN, number);
let emissiveDim = if annunciatorLight == 2 { 0.05 } else { 1 };
// @todo abnormal defined differently with NAV modes available.
let rmpLeftAbnormal = selectedModeLeft != 1 or selectedModeRight == 1;
let rmpRightAbnormal = selectedModeRight != 2 or selectedModeLeft == 2;
let sideLeftCheck = id == 1;
let sideRightCheck = id == 2;
(if (toggleSwitch and ((rmpLeftAbnormal and sideLeftCheck) or (rmpRightAbnormal and sideRightCheck)) or (annunciatorLight == 0)) and indicatorsPowered {
1 * emissiveDim
} else {
0
})
</EMISSIVE_CODE>
</UseTemplate>
</Component>

<!-- SEL indicator led light -->
<Component ID="PUSH_RADIO#SIDE#_SEL_SEQ2" Node="PUSH_RADIO#SIDE#_SEL_SEQ2">
<UseTemplate Name="ASOBO_GT_Emissive_Gauge">
<POTENTIOMETER>7</POTENTIOMETER>
<EMISSIVE_CODE type="rnp" return="number">
let indicatorsPowered = #INDICATORS_POWERED, bool#;
let id = #ID, number#;
alias toggleSwitch = (L:A32NX_RMP_#SIDE#_TOGGLE_SWITCH, bool);
alias selectedModeLeft = (L:A32NX_RMP_L_SELECTED_MODE, number);
alias selectedModeRight = (L:A32NX_RMP_R_SELECTED_MODE, number);
alias annunciatorLight = (L:A32NX_OVHD_INTLT_ANN, number);
let emissiveDim = if annunciatorLight == 2 { 0.05 } else { 1 };
// @todo abnormal defined differently with NAV modes available.
let rmpLeftAbnormal = selectedModeLeft != 1;
let rmpRightAbnormal = selectedModeRight != 2;
(if (toggleSwitch and (rmpLeftAbnormal or rmpRightAbnormal) or (annunciatorLight == 0)) and indicatorsPowered {
let rmpLeftAbnormal = selectedModeLeft != 1 or selectedModeRight == 1;
let rmpRightAbnormal = selectedModeRight != 2 or selectedModeLeft == 2;
let sideLeftCheck = id == 1;
let sideRightCheck = id == 2;
(if (toggleSwitch and ((rmpLeftAbnormal and sideLeftCheck) or (rmpRightAbnormal and sideRightCheck)) or (annunciatorLight == 0)) and indicatorsPowered {
1 * emissiveDim
} else {
0
Expand All @@ -156,6 +190,7 @@

<!-- SEL indicator backlighting -->
<UseTemplate Name="FBW_RMP_BACKLIGHT_Template">
<POTENTIOMETER>7</POTENTIOMETER>
<BASE_NAME>SEL</BASE_NAME>
</UseTemplate>
</Template>
Expand Down Expand Up @@ -288,7 +323,7 @@
<Component ID="#BACKLIGHT_NAME#" Node="#BACKLIGHT_NAME#">
<UseTemplate Name="ASOBO_GT_Emissive_Gauge">
<EMISSIVE_CODE>
(A:LIGHT POTENTIOMETER:#POTENTIOMETER#, Percent over 100) #BACKLIGHTS_POWERED# *
(A:LIGHT POTENTIOMETER:#POTENTIOMETER#, Percent over 100) #BACKLIGHTS_POWERED# (L:A32NX_RMP_#SIDE#_TOGGLE_SWITCH) * *
</EMISSIVE_CODE>
</UseTemplate>
</Component>
Expand Down
1 change: 1 addition & 0 deletions src/instruments/src/Common/EWDMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const EWDMessages = {
'000055201': '\x1b<3mCOMPANY MSG',
'000056001': '\x1b<3mHI ALT SET',
'000068001': '\x1b<3mADIRS SWTG',
'000056701': '\x1b<3mVHF3 VOICE',
'213122101': '\x1b<2m\x1b4mCAB PR\x1bm EXCESS CAB ALT',
'213122102': '\x1b<5m -CREW OXY MASKS.....USE',
'213122103': '\x1b<5m -SIGNS...............ON',
Expand Down
14 changes: 14 additions & 0 deletions src/instruments/src/EWD/elements/PseudoFWC.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ const PseudoFWC: React.FC = () => {
const [pack2On] = useSimVar('L:A32NX_OVHD_COND_PACK_2_PB_IS_ON', 'bool');
const [excessPressure] = useSimVar('L:A32NX_PRESS_EXCESS_CAB_ALT', 'bool', 500);

const [voiceVHF3] = useSimVar('A:COM ACTIVE FREQUENCY:3', 'number', 500);

/* WARNINGS AND FAILURES */
const landASAPRed: boolean = !!(!aircraftOnGround
&& (
Expand Down Expand Up @@ -1670,6 +1672,17 @@ const PseudoFWC: React.FC = () => {
sysPage: -1,
side: 'RIGHT',
},
'0000567': // VHF3 VOICE
{
flightPhaseInhib: [],
simVarIsActive: voiceVHF3 !== 0 && [1, 2, 6, 9, 10].includes(flightPhase),
whichCodeToReturn: [0],
codesToReturn: ['000056701'],
memoInhibit: false,
failure: 0,
sysPage: -1,
side: 'RIGHT',
},
};

/* TO CONFIG */
Expand Down Expand Up @@ -1994,6 +2007,7 @@ const PseudoFWC: React.FC = () => {
unit,
usrStartRefueling,
wingAntiIce,
voiceVHF3,
]);

useEffect(() => {
Expand Down
37 changes: 32 additions & 5 deletions src/instruments/src/RMP/Components/RadioPanelDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface Props {
value: number | string,
}

const TEXT_DATA_MODE_VHF3 = 'DATA';

/**
* Format the given frequency to be displayed.
* @param frequency The given frequency number in Hz.
Expand All @@ -23,14 +25,39 @@ const formatFrequency = (frequency: number): string => (frequency / 1000000).toF
export function RadioPanelDisplay(props: Props) {
const [lightsTest] = useSimVar('L:A32NX_OVHD_INTLT_ANN', 'Boolean', 1000);

// If the passed value prop is a number, we'll use formatFrequency to get string format.
const value = typeof props.value === 'number' ? formatFrequency(props.value) : props.value;
let content: JSX.Element;

return (
<svg className="rmp-svg">
if (lightsTest === 0) {
content = (
<text x="100%" y="52%">
8.8.8.8.8.8
</text>
);
} else if (props.value > 0) {
let value = '';
// If the passed value prop is a number, we'll use formatFrequency to get string format.
if (typeof props.value === 'number') {
value = formatFrequency(props.value);
} else {
value = props.value;
}

content = (
<text x="100%" y="52%">
{lightsTest === 0 ? '8.8.8.8.8.8' : value}
{value}
</text>
);
} else {
content = (
<text x="85%" y="52%">
{TEXT_DATA_MODE_VHF3}
</text>
);
}

return (
<svg className="rmp-svg">
{content}
</svg>
);
}
41 changes: 24 additions & 17 deletions src/instruments/src/RMP/Components/StandbyFrequency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,29 +103,36 @@ export const StandbyFrequency = (props: Props) => {
const spacing = usePersistentProperty('RMP_VHF_SPACING_25KHZ', '0')[0] === '0' ? 8.33 : 25;
// Handle outer knob turned.
const outerKnobUpdateCallback: UpdateValueCallback = useCallback((offset) => {
const frequency = Math.round(props.value / 1000);
const integer = Math.floor(frequency / 1000);
const decimal = frequency % 1000;
// @todo determine min/max depending on mode.
const maxInteger = decimal > 975 ? 135 : 136;
const newInteger = Utils.Clamp(integer + offset, 118, maxInteger);
props.setValue((newInteger * 1000 + decimal) * 1000);
if (props.value !== 0) {
const frequency = Math.round(props.value / 1000);
const integer = Math.floor(frequency / 1000);
const decimal = frequency % 1000;
// @todo determine min/max depending on mode.
const maxInteger = decimal > 975 ? 135 : 136;
const newInteger = Utils.Clamp(integer + offset, 118, maxInteger);
props.setValue((newInteger * 1000 + decimal) * 1000);
} else {
props.setValue(0);
}
}, [props.value]);

// Handle inner knob turned.
const innerKnobUpdateCallback: UpdateValueCallback = useCallback((offset) => {
const frequency = Math.round(props.value / 1000);
if (Math.sign(offset) === 1 && frequency === 136975) {
return;
if (props.value !== 0) {
const integer = Math.floor(frequency / 1000);
// @todo determine correct frequency spacing depending on mode.
const decimal = offsetFrequencyChannel(spacing, frequency % 1000, offset);
// @todo determine min/max depending on mode.
// Tested in real life:
// Integer cannot return to 118 from 136 to the right
// Decimal can return to 0 from 975 to the right
// const maxDecimal = integer === 136 ? 975 : 1000;
const newDecimal = Utils.Clamp(decimal, 0, 1000);
props.setValue((integer * 1000 + newDecimal) * 1000);
} else {
props.setValue(0);
}

const integer = Math.floor(frequency / 1000);
// @todo determine correct frequency spacing depending on mode.
const decimal = offsetFrequencyChannel(spacing, frequency % 1000, offset);
// @todo determine min/max depending on mode.
const maxDecimal = integer === 136 ? 975 : 1000;
const newDecimal = Utils.Clamp(decimal, 0, maxDecimal);
props.setValue((integer * 1000 + newDecimal) * 1000);
}, [props.value]);

// Used to change integer value of freq.
Expand Down
6 changes: 6 additions & 0 deletions src/instruments/src/RMP/Components/VhfRadioPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ const useStandbyVhfFrequency = (side: string, transceiver: number) => {
export const VhfRadioPanel = (props: Props) => {
const [active, setActive] = useActiveVhfFrequency(props.transceiver);
const [standby, setStandby] = useStandbyVhfFrequency(props.side, props.transceiver);
const [, setValueOppositePanelStandby] = props.side === 'L' ? useStandbyVhfFrequency('R', 3) : useStandbyVhfFrequency('L', 3);

// Handle Transfer Button Pressed.
useInteractionEvent(`A32NX_RMP_${props.side}_TRANSFER_BUTTON_PRESSED`, () => {
// Force the standby opposite side otherwise we would lose the frequency/data format
// Otherwise it would become frequency/frequency
if (props.transceiver === 3) {
setValueOppositePanelStandby(active);
}
setActive(standby);
setStandby(active);
});
Expand Down

0 comments on commit 63f21ab

Please sign in to comment.