1
0
Fork 0

S3 Vario: Fix bug where the needle became offsetted when the instruments was switched off while non-zero

This commit is contained in:
Delta Echo 2021-05-14 12:26:24 +02:00
parent c2e71eb3e9
commit 55b0cf802c
2 changed files with 16 additions and 18 deletions

View file

@ -42,6 +42,8 @@ var volt_prop = props.globals.initNode("/systems/electrical/outputs/S3", 0.0, "D
var mc = s3.initNode("mc", 1.5, "DOUBLE");
var needle = s3.initNode( "needle-deg", 0.0, "DOUBLE" );
var instrument_dir = "Aircraft/Instruments-3d/glider/vario/S3/";
var canvas_S3_base = {
@ -135,6 +137,18 @@ var canvas_S3_start = {
};
var s3_update = maketimer(0.2, func() { canvas_S3_base.update() } );
s3_update.simulatedTime = 1;
var vario_needle_ctrl = func {
if( start_prop.getDoubleValue() == 1.0 ){
needle.setDoubleValue( math.clamp( te_rdg.getDoubleValue() * 24, -132, 132 ) ); # max deflection: 132 deg at +- 5.5 m/s
} else {
needle.setDoubleValue( 0.0 );
}
}
var needle_update = maketimer( 0.0, vario_needle_ctrl );
needle_update.simulatedTime = 1;
var ls = setlistener("sim/signals/fdm-initialized", func {
S3_display = canvas.new({
@ -152,6 +166,7 @@ var ls = setlistener("sim/signals/fdm-initialized", func {
S3_start = canvas_S3_start.new(groupStart, instrument_dir~"S3_start.svg");
s3_update.start();
needle_update.start();
removelistener(ls);
});
@ -259,5 +274,4 @@ var slow_instruments = UpdateLoop.new(
update_period: 1,
components: [averager],
enable: 1);

View file

@ -117,17 +117,7 @@
<animation>
<type>rotate</type>
<object-name>vario.needle</object-name>
<property>instrumentation/s3/te-reading-mps</property>
<condition>
<equals>
<property>instrumentation/s3/start</property>
<value>1</value>
</equals>
</condition>
<interpolation>
<entry><ind> -5.5 </ind><dep> -132 </dep></entry>
<entry><ind> 5.5 </ind><dep> 132 </dep></entry>
</interpolation>
<property>instrumentation/s3/needle-deg</property>
<center>
<y-m>0.0</y-m>
<z-m>0.0</z-m>
@ -142,12 +132,6 @@
<type>rotate</type>
<object-name>vario.needle</object-name>
<property>instrumentation/s3/start</property>
<condition>
<not-equals>
<property>instrumentation/s3/start</property>
<value>1</value>
</not-equals>
</condition>
<interpolation>
<entry><ind> 0 </ind><dep> 0 </dep></entry>
<entry><ind> 0.1 </ind><dep> -12 </dep></entry>