Skip to content

Commit

Permalink
fix(lights): Landing Light movement now only possible with power + po…
Browse files Browse the repository at this point in the history
…sition LVAR (flybywiresim#8553)

Landing Light movement now only possible with power and position is output into LVAR
  • Loading branch information
Maximilian-Reuter authored Mar 5, 2024
1 parent 23f5b33 commit a1d7acb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
1. [FUEL] Lowered starting fuel on C/D spawn, will only load last saved fuel on C/D spawn, center tank refuel now happens simultaneous with wing refuel - @Maximilian-Reuter
1. [EFB/SIMBRIEF] Option to import SimBrief Fuel & Payload when SimBrief Data is imported - @Fragtality (Fragtality) + @Maximilian-Reuter
1. [FLIGHTMODEL] Fixes some crosswind issues - @donstim (donbikes)
1. [LIGHTS] Movement of landing lights now requires power and position is output into LVAR - @Maximilian-Reuter

## 0.11.0

Expand Down
7 changes: 7 additions & 0 deletions fbw-a32nx/docs/a320-simvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,13 @@
| 13 | Ten |
| 14 | Five |

- A32NX_LANDING_{ID}_POSITION
- Percent
- Current position of the landing light animation
- {ID}
- 2 | LEFT
- 3 | RIGHT

## Model/XML Interface

These variables are the interface between the 3D model and the systems/code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,24 @@
<Include ModelBehaviorFile="Asobo\Generic\FX.xml"/>
<Include Path="A32NX\generated\A32NX_Exterior.xml"/>
<Component ID="LIGHTING">
<UseTemplate Name="ASOBO_LIGHTING_Exterior_Retractable_Light_Template">
<LIGHT_TYPE>LANDING</LIGHT_TYPE>
<ID>2</ID>
<ANIM_NAME>l_opening_landing_light</ANIM_NAME>
<ANIM_LAG>12</ANIM_LAG>
</UseTemplate>
<UseTemplate Name="ASOBO_LIGHTING_Exterior_Retractable_Light_Template">
<LIGHT_TYPE>LANDING</LIGHT_TYPE>
<ID>3</ID>
<ANIM_NAME>r_opening_landing_light</ANIM_NAME>
<ANIM_LAG>12</ANIM_LAG>
</UseTemplate>
<Component ID="LANDING_LIGHT_LEFT">
<UseTemplate Name="FBW_LIGHTING_Exterior_Retractable_Light_Template">
<LIGHT_TYPE>LANDING</LIGHT_TYPE>
<ID>2</ID>
<ANIM_NAME>l_opening_landing_light</ANIM_NAME>
<ANIM_LAG>12</ANIM_LAG>
<FAILURE>(L:A32NX_ELEC_AC_1_BUS_IS_POWERED)</FAILURE>
</UseTemplate>
</Component>
<Component ID="LANDING_LIGHT_RIGHT">
<UseTemplate Name="FBW_LIGHTING_Exterior_Retractable_Light_Template">
<LIGHT_TYPE>LANDING</LIGHT_TYPE>
<ID>3</ID>
<ANIM_NAME>r_opening_landing_light</ANIM_NAME>
<ANIM_LAG>12</ANIM_LAG>
<FAILURE>(L:A32NX_ELEC_AC_2_BUS_IS_POWERED)</FAILURE>
</UseTemplate>
</Component>
</Component>
<Component ID="HANDLING">
<UseTemplate Name="FBW_HANDLING_Elevator_Template">
Expand Down
29 changes: 29 additions & 0 deletions fbw-a32nx/src/behavior/src/A32NX_Exterior.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@
<!-- SPDX-License-Identifier: GPL-3.0 -->

<ModelBehaviors>
<Template Name="FBW_LIGHTING_Exterior_Retractable_Light_Template">
<DefaultTemplateParameters>
<ANIM_NAME>LIGHTING_Retractable_#LIGHT_TYPE#_Light_#ID#</ANIM_NAME>
<ANIM_LAG>100</ANIM_LAG>
<ANIM_FRAMES>100</ANIM_FRAMES>
</DefaultTemplateParameters>
<UseTemplate Name="ASOBO_GT_Anim_Code">
<ANIM_CODE type="rnp" return="number" >
alias currentPosition = (O:AnimCode, number);
alias publishedPosition = (L:A32NX_#LIGHT_TYPE#_#ID#_POSITION, number);
let animSpeed = #ANIM_FRAMES, number# / #ANIM_LAG, number#;
let animProgress = animSpeed * (A:ANIMATION DELTA TIME, seconds);
let requestedPosition = if (L:#LIGHT_TYPE#_#ID#_Retracted, boolean) {0} else {100};

if currentPosition != requestedPosition {
let newPosition = 0;
if requestedPosition > 0 {
newPosition = (currentPosition + animProgress).min(requestedPosition);
} else {
newPosition = (currentPosition - animProgress).max(requestedPosition);
}
publishedPosition = newPosition;
} else {
publishedPosition = currentPosition;
}
publishedPosition
</ANIM_CODE>
</UseTemplate>
</Template>
<Template Name="A32NX_ENGINE_Turbine_Template">
<DefaultTemplateParameters>
<ID>1</ID>
Expand Down

0 comments on commit a1d7acb

Please sign in to comment.