Integrates existing soaring instruments with the soaring sdk
All reviewed aircraft now support total energy compensated variometers and reuse a common implementation. The following issues have been addressed, either explicitly or as a benefit from the integration: + Fixed incorrect variometer readouts at sim/speed-up values != 1 + Fixed erratic instrument behavior after pause and reinit + Reworked all vario needle animations to be smoother. + Fixed ASK13 yaw string. Now it deflects to the correct side. + Added temperature and (fake) battery readings to ILEC SC7 digital variometer. + Fixed ILEC SC7 sign readout (didn't show the minus sign). Note: The ASK21 models have not been integrated, as they will need a more profound cockpit overhaul.
This commit is contained in:
parent
db995cc8ee
commit
ff071bd858
2 changed files with 238 additions and 267 deletions
|
@ -1,102 +1,73 @@
|
|||
io.include("Aircraft/Generic/soaring-instrumentation-sdk.nas");
|
||||
|
||||
var debug_enabled = 0;
|
||||
|
||||
## helpers
|
||||
#
|
||||
var FT2M=0.30480;
|
||||
var KT2MPS=1852/3600;
|
||||
var square=func(x) return x*x;
|
||||
var get_delta=func (current,previous) {return (current-previous);}
|
||||
var state = {new:func {return{parents:[state]};},altitude_m:0,airspeed_mps:0,timestamp:0,te_read:0};
|
||||
var samples = []; setsize(samples, 30);
|
||||
var te_needle =0;
|
||||
# Initialize exported properties
|
||||
setprop("/instrumentation/ilec-sc7/volume", 0.8);
|
||||
setprop("/instrumentation/ilec-sc7/audio", 2);
|
||||
setprop("/instrumentation/ilec-sc7/mode", 1);
|
||||
setprop("/instrumentation/ilec-sc7/sensitivity", 3);
|
||||
setprop("/instrumentation/ilec-sc7/lcd-digits-abs", 0);
|
||||
setprop("/instrumentation/ilec-sc7/lcd-digits-sgn", 0);
|
||||
setprop("/instrumentation/ilec-sc7/te-reading-mps", 0);
|
||||
setprop("/instrumentation/variometer/te-reading-mps", 0);
|
||||
|
||||
setprop("/instrumentation/ilec-sc7/te-reading-mps",0);
|
||||
setprop("/instrumentation/ilec-sc7/volume",0.8);
|
||||
setprop("/instrumentation/ilec-sc7/audio",2);
|
||||
setprop("/instrumentation/ilec-sc7/mode",1);
|
||||
setprop("/instrumentation/ilec-sc7/sensitivity",1);
|
||||
setprop("/instrumentation/ilec-sc7/filter",0.05);
|
||||
# Helper function for updating lcd display
|
||||
var update_lcd_props = func(value) {
|
||||
setprop("/instrumentation/ilec-sc7/lcd-digits-abs", math.abs(value));
|
||||
setprop("/instrumentation/ilec-sc7/lcd-digits-sgn", (value < 0) ? 0 : 1);
|
||||
};
|
||||
|
||||
var update_state = func {
|
||||
var s = state.new();
|
||||
s.altitude_m=getprop("/position/altitude-ft")*FT2M;
|
||||
s.airspeed_mps=getprop("/velocities/airspeed-kt")*KT2MPS;
|
||||
s.timestamp=systime();
|
||||
return s;
|
||||
}
|
||||
# Instrument setup:
|
||||
|
||||
var push30 = func {
|
||||
var i = 0;
|
||||
while ( i < 30 ) {
|
||||
samples[i]=0;
|
||||
i += 1;
|
||||
};
|
||||
}
|
||||
# One TE probe feeds two vario needles and a 25s averager.
|
||||
# LCD digits are controlled by the.. um.. lcd_controller
|
||||
# that switches between battery level, temperature and averager
|
||||
# depending on mode switch posiion.
|
||||
|
||||
##
|
||||
# debug info
|
||||
var s_dump = func(s) {
|
||||
print(s.timestamp," ", s.altitude_m, " ", s.airspeed_mps);
|
||||
}
|
||||
# Why a second needle? A digital vario is usually installed together
|
||||
# with a mechanical one, so now we are at it, why not provide a bonus
|
||||
# TE reading for it and avoid loading an extra script?
|
||||
|
||||
var averager = func {
|
||||
var sum = 0 ;
|
||||
var i = 0;
|
||||
while ( i < 29 ) {
|
||||
samples[i] = samples[i+1]; # shift everything to the "left"
|
||||
i += 1;
|
||||
};
|
||||
samples[29] = te_needle; # and set last sample to current
|
||||
i = 0;
|
||||
while ( i < 30 ) {
|
||||
sum = sum + samples[i];
|
||||
i += 1;
|
||||
};
|
||||
var average30 = sum / 30;
|
||||
setprop("/instrumentation/ilec-sc7/average",math.abs(average30));
|
||||
setprop("/instrumentation/ilec-sc7/average-sign",math.sgn(average30));
|
||||
if (debug_enabled) print (" average ",average30);
|
||||
settimer(averager, 1); # update rate
|
||||
}
|
||||
|
||||
var probe = TotalEnergyProbe.new();
|
||||
|
||||
var tvario = {
|
||||
new: func {return {parents:[tvario]};},
|
||||
state:{previous:,current:},
|
||||
init: func {state.previous=state.new(); state.current=state.new();},
|
||||
update:func {
|
||||
if (debug_enabled) print("\nUpdating TEV:");
|
||||
state.current = update_state();
|
||||
if (debug_enabled) {
|
||||
s_dump(state.current);
|
||||
s_dump(state.previous);
|
||||
}
|
||||
var delta_t = get_delta(state.current.timestamp, state.previous.timestamp);
|
||||
# TE reading = (h2-h1)/t + (v2^2 - v1^2) / 19.62*t
|
||||
if (debug_enabled) print("delta_t:",delta_t);
|
||||
var uncompensated = get_delta(state.current.altitude_m,state.previous.altitude_m) / delta_t;
|
||||
if (debug_enabled) print(" uncompensated:",uncompensated);
|
||||
var adjustment = get_delta(square(state.current.airspeed_mps),square(state.previous.airspeed_mps)) / (19.62 * delta_t);
|
||||
if (debug_enabled) print(" adjustment:",adjustment,"\n");
|
||||
var te_reading = uncompensated + adjustment;
|
||||
if (debug_enabled) print (" te_reading:",te_reading);
|
||||
|
||||
te_needle = getprop("/instrumentation/ilec-sc7/te-reading-mps");
|
||||
var filter = 0.01 + 0.02 * getprop("/instrumentation/ilec-sc7/sensitivity");
|
||||
setprop("/instrumentation/ilec-sc7/filter",filter);
|
||||
var sc7_needle = Dampener.new(
|
||||
input: probe,
|
||||
dampening: 3,
|
||||
on_update: update_prop("/instrumentation/ilec-sc7/te-reading-mps"));
|
||||
|
||||
te_needle = te_needle * (1-filter) + filter * te_reading;
|
||||
setprop("/instrumentation/ilec-sc7/te-reading-mps",te_needle);
|
||||
setprop("/instrumentation/ilec-sc7/te-reading-neg",-te_needle);
|
||||
state.previous = state.current; # save current state for next call
|
||||
settimer(func me.update(), 1/20); # update rate
|
||||
}
|
||||
};
|
||||
var extra_needle = Dampener.new(
|
||||
input: probe,
|
||||
dampening: 2.7,
|
||||
on_update: update_prop("/instrumentation/variometer/te-reading-mps"));
|
||||
|
||||
var tv = tvario.new();
|
||||
tv.init();
|
||||
tv.update();
|
||||
push30();
|
||||
averager();
|
||||
|
||||
var averager = Averager.new(
|
||||
input: probe,
|
||||
buffer_size: 25);
|
||||
|
||||
var battery_level = { output: 9.9 };
|
||||
|
||||
var temperature = PropertyReader.new(
|
||||
property: "environment/temperature-degc",
|
||||
scale: 0.1);
|
||||
|
||||
var lcd_controller = InputSwitcher.new(
|
||||
inputs: [battery_level, averager, temperature],
|
||||
active_input: 1,
|
||||
on_update: update_lcd_props);
|
||||
|
||||
# Subscribe property listeners for instrument switches
|
||||
setlistener("instrumentation/ilec-sc7/mode",
|
||||
func(n) { lcd_controller.select_input(n.getValue()) }, 0, 0);
|
||||
|
||||
setlistener("instrumentation/ilec-sc7/sensitivity",
|
||||
func(n) { sc7_needle.dampening = n.getValue() }, 0, 0);
|
||||
|
||||
# Wrap everything together into an instrument
|
||||
var fast_instruments = Instrument.new(
|
||||
update_period: 0,
|
||||
components: [probe, sc7_needle, extra_needle],
|
||||
enable: 1);
|
||||
|
||||
var slow_instruments = Instrument.new(
|
||||
update_period: 1,
|
||||
components: [averager, temperature, lcd_controller],
|
||||
enable: 1);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<object-name>decimals-digit</object-name>
|
||||
<object-name>units-digit</object-name>
|
||||
<object-name>sign-digit</object-name>
|
||||
<object-name>dot-digit</object-name>
|
||||
<object-name>dot-digit</object-name>
|
||||
<emission>
|
||||
<red>0.028</red>
|
||||
<green>0.014</green>
|
||||
|
@ -19,14 +19,14 @@
|
|||
<factor-prop>systems/electrical/outputs/instrument-lights</factor-prop>
|
||||
</emission>
|
||||
</animation>
|
||||
|
||||
|
||||
<!--needle-->
|
||||
|
||||
<animation>
|
||||
<type>rotate</type>
|
||||
<object-name>Needle</object-name>
|
||||
<property>/instrumentation/ilec-sc7/te-reading-mps</property>
|
||||
<interpolation>
|
||||
<interpolation>
|
||||
<entry><ind> -5</ind><dep>-119.713</dep></entry>
|
||||
<entry><ind> 0.0</ind><dep> 0.0</dep></entry>
|
||||
<entry><ind> 5</ind><dep>119.7135</dep></entry>
|
||||
|
@ -42,9 +42,9 @@
|
|||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
|
||||
<!-- mc cready -->
|
||||
|
||||
|
||||
<animation>
|
||||
<type>rotate</type>
|
||||
<object-name>mc-cready</object-name>
|
||||
|
@ -61,7 +61,7 @@
|
|||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>mc-cready</object-name>
|
||||
|
@ -80,7 +80,7 @@
|
|||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>mc-cready</object-name>
|
||||
|
@ -99,9 +99,9 @@
|
|||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
|
||||
<!-- volume -->
|
||||
|
||||
|
||||
<animation>
|
||||
<type>rotate</type>
|
||||
<object-name>vol-knob</object-name>
|
||||
|
@ -118,7 +118,7 @@
|
|||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>vol-knob</object-name>
|
||||
|
@ -137,7 +137,7 @@
|
|||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>vol-knob</object-name>
|
||||
|
@ -156,9 +156,9 @@
|
|||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
|
||||
<!-- audio switch -->
|
||||
|
||||
|
||||
<animation>
|
||||
<type>rotate</type>
|
||||
<object-name>audio-switch</object-name>
|
||||
|
@ -179,191 +179,191 @@
|
|||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>incr-audio</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/audio</property>
|
||||
<step>1</step>
|
||||
<min>0</min>
|
||||
<max>2</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>decr-audio</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/audio</property>
|
||||
<step>-1</step>
|
||||
<min>0</min>
|
||||
<max>2</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
<!-- mode switch -->
|
||||
|
||||
<animation>
|
||||
<type>rotate</type>
|
||||
<object-name>mode-switch</object-name>
|
||||
<property>instrumentation/ilec-sc7/mode</property>
|
||||
<interpolation>
|
||||
<entry><ind>0</ind><dep>-30</dep></entry>
|
||||
<entry><ind>1.0</ind><dep>0</dep></entry>
|
||||
<entry><ind>2.0</ind><dep>30</dep></entry>
|
||||
</interpolation>
|
||||
<center>
|
||||
<x-m>0.001</x-m>
|
||||
<y-m>0.025</y-m>
|
||||
<z-m>-0.013</z-m>
|
||||
</center>
|
||||
<axis>
|
||||
<x>0</x>
|
||||
<y>-1</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>incr-mode</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/mode</property>
|
||||
<step>1</step>
|
||||
<min>0</min>
|
||||
<max>2</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>decr-mode</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/mode</property>
|
||||
<step>-1</step>
|
||||
<min>0</min>
|
||||
<max>2</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
<!-- sensitivity switch -->
|
||||
|
||||
<animation>
|
||||
<type>rotate</type>
|
||||
<object-name>sens-switch</object-name>
|
||||
<property>instrumentation/ilec-sc7/sensitivity</property>
|
||||
<interpolation>
|
||||
<entry><ind>0</ind><dep>-30</dep></entry>
|
||||
<entry><ind>1.0</ind><dep>30</dep></entry>
|
||||
</interpolation>
|
||||
<center>
|
||||
<x-m>0.001</x-m>
|
||||
<y-m>0.003</y-m>
|
||||
<z-m>-0.031</z-m>
|
||||
</center>
|
||||
<axis>
|
||||
<x>0</x>
|
||||
<y>-1</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>incr-sens</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/sensitivity</property>
|
||||
<step>1</step>
|
||||
<min>0</min>
|
||||
<max>1</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>decr-sens</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/sensitivity</property>
|
||||
<step>-1</step>
|
||||
<min>0</min>
|
||||
<max>1</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
<!-- digits -->
|
||||
|
||||
<animation>
|
||||
<type>textranslate</type>
|
||||
<object-name>decimals-digit</object-name>
|
||||
<property>instrumentation/ilec-sc7/average</property>
|
||||
<factor>1</factor>
|
||||
<step>0.1</step>
|
||||
<bias>0.005</bias>
|
||||
<axis>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>textranslate</type>
|
||||
<object-name>units-digit</object-name>
|
||||
<property>instrumentation/ilec-sc7/average</property>
|
||||
<factor>0.1</factor>
|
||||
<step>1</step>
|
||||
<bias>0.005</bias>
|
||||
<axis>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>textranslate</type>
|
||||
<object-name>sign-digit</object-name>
|
||||
<property>instrumentation/ilec-sc7/average-sign</property>
|
||||
<factor>0.1</factor>
|
||||
<step>1</step>
|
||||
<bias>0.005</bias>
|
||||
<axis>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
<!-- mode switch -->
|
||||
|
||||
<animation>
|
||||
<type>rotate</type>
|
||||
<object-name>mode-switch</object-name>
|
||||
<property>instrumentation/ilec-sc7/mode</property>
|
||||
<interpolation>
|
||||
<entry><ind>0</ind><dep>-30</dep></entry>
|
||||
<entry><ind>1.0</ind><dep>0</dep></entry>
|
||||
<entry><ind>2.0</ind><dep>30</dep></entry>
|
||||
</interpolation>
|
||||
<center>
|
||||
<x-m>0.001</x-m>
|
||||
<y-m>0.025</y-m>
|
||||
<z-m>-0.013</z-m>
|
||||
</center>
|
||||
<axis>
|
||||
<x>0</x>
|
||||
<y>-1</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>incr-mode</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/mode</property>
|
||||
<step>1</step>
|
||||
<min>0</min>
|
||||
<max>2</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>decr-mode</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/mode</property>
|
||||
<step>-1</step>
|
||||
<min>0</min>
|
||||
<max>2</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
<!-- sensitivity switch -->
|
||||
|
||||
<animation>
|
||||
<type>rotate</type>
|
||||
<object-name>sens-switch</object-name>
|
||||
<property>instrumentation/ilec-sc7/sensitivity</property>
|
||||
<interpolation>
|
||||
<entry><ind>1</ind><dep>30</dep></entry>
|
||||
<entry><ind>3</ind><dep>-30</dep></entry>
|
||||
</interpolation>
|
||||
<center>
|
||||
<x-m>0.001</x-m>
|
||||
<y-m>0.003</y-m>
|
||||
<z-m>-0.031</z-m>
|
||||
</center>
|
||||
<axis>
|
||||
<x>0</x>
|
||||
<y>-1</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>decr-sens</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/sensitivity</property>
|
||||
<step>3</step>
|
||||
<min>1</min>
|
||||
<max>3</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>pick</type>
|
||||
<object-name>incr-sens</object-name>
|
||||
<action>
|
||||
<button>0</button>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>instrumentation/ilec-sc7/sensitivity</property>
|
||||
<step>-3</step>
|
||||
<min>1</min>
|
||||
<max>3</max>
|
||||
<wrap>false</wrap>
|
||||
</binding>
|
||||
</action>
|
||||
</animation>
|
||||
|
||||
<!-- digits -->
|
||||
|
||||
<animation>
|
||||
<type>textranslate</type>
|
||||
<object-name>decimals-digit</object-name>
|
||||
<property>instrumentation/ilec-sc7/lcd-digits-abs</property>
|
||||
<factor>1</factor>
|
||||
<step>0.1</step>
|
||||
<bias>0.005</bias>
|
||||
<axis>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>textranslate</type>
|
||||
<object-name>units-digit</object-name>
|
||||
<property>instrumentation/ilec-sc7/lcd-digits-abs</property>
|
||||
<factor>0.1</factor>
|
||||
<step>1</step>
|
||||
<bias>0.005</bias>
|
||||
<axis>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>textranslate</type>
|
||||
<object-name>sign-digit</object-name>
|
||||
<property>instrumentation/ilec-sc7/lcd-digits-sgn</property>
|
||||
<factor>0.1</factor>
|
||||
<step>1</step>
|
||||
<bias>0.005</bias>
|
||||
<axis>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</axis>
|
||||
</animation>
|
||||
|
||||
</PropertyList>
|
||||
|
||||
|
|
Loading…
Reference in a new issue