GoFlight MCP and EFIS input configs
This commit is contained in:
parent
4d402914b1
commit
363dc4cea5
3 changed files with 792 additions and 460 deletions
|
@ -1,23 +1,70 @@
|
|||
<PropertyList>
|
||||
|
||||
<name>GoFlight GF EFIS</name>
|
||||
<debug-events type="bool">true</debug-events>
|
||||
<debug-events type="bool">false</debug-events>
|
||||
|
||||
<nasal>
|
||||
<open>
|
||||
<![CDATA[
|
||||
|
||||
var basePath = "/instrumentation/efis[0]/";
|
||||
|
||||
# value is 0..8 for the konb on 738, GF only goes to 10
|
||||
var efisRangeKnobNode = props.globals.getNode(basePath ~ "inputs/range-knob");
|
||||
efisRangeKnobNode.setIntValue(0);
|
||||
|
||||
# value is absolute integer for each click, hmmmm
|
||||
var efisBaroKnobNode = props.globals.getNode(basePath ~ "inputs/baro-knob");
|
||||
|
||||
var setRangeBit = func(bit) {
|
||||
var b = efisRangeKnobNode.getValue() - 1;
|
||||
efisRangeKnobNode.setIntValue(bits.set(b, bit) + 1);
|
||||
}
|
||||
|
||||
var clearRangeBit = func(bit) {
|
||||
var b = efisRangeKnobNode.getValue() - 1;
|
||||
efisRangeKnobNode.setIntValue(bits.clear(b, bit) + 1);
|
||||
}
|
||||
|
||||
var efisNDModeNode = props.globals.getNode(basePath ~ "mfd/mode-num");
|
||||
var setModeBit = func(bit) {
|
||||
var mode = efisNDModeNode.getValue();
|
||||
efisNDModeNode.setIntValue(bits.set(mode, bit));
|
||||
}
|
||||
|
||||
var clearModeBit = func(bit) {
|
||||
var mode = efisNDModeNode.getValue();
|
||||
efisNDModeNode.setIntValue(bits.clear(mode, bit));
|
||||
}
|
||||
]]>
|
||||
</open>
|
||||
</nasal>
|
||||
|
||||
<hid-descriptor>
|
||||
<report>
|
||||
<type>input</type>
|
||||
<id>1</id>
|
||||
<unused-bits><size type="int">16</size></unused-bits>
|
||||
<rel-dial-0>
|
||||
<size type="int">8</size>
|
||||
<count type="int">2</count>
|
||||
<is-signed type="bool">true</is-signed>
|
||||
</rel-dial-0>
|
||||
<button-0>
|
||||
<count type="int">24</count>
|
||||
</button-0>
|
||||
</report>
|
||||
</hid-descriptor>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-4</name>
|
||||
<name>rel-dial-0</name>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>/input/goflight/efis/height</property>
|
||||
<min type="double">0.0</min>
|
||||
</binding>
|
||||
<interpolater>
|
||||
<mirrored type="bool">true</mirrored>
|
||||
<entry><ind>0</ind><dep>0</dep></entry>
|
||||
<entry><ind>1</ind><dep>1</dep></entry>
|
||||
<entry><ind>2</ind><dep>2</dep></entry>
|
||||
|
@ -26,146 +73,17 @@
|
|||
</interpolater>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-5</name>
|
||||
<event>
|
||||
<name>rel-dial-1</name>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>/input/goflight/efis/baro</property>
|
||||
<min type="double">108.0</min>
|
||||
<max type="double">117.95</max>
|
||||
<wrap type="bool">true</wrap>
|
||||
</binding>
|
||||
<interpolater>
|
||||
<entry><ind>0</ind><dep>0</dep></entry>
|
||||
<entry><ind>1</ind><dep>1</dep></entry>
|
||||
<entry><ind>2</ind><dep>2</dep></entry>
|
||||
<entry><ind>3</ind><dep>4</dep></entry>
|
||||
<entry><ind>4</ind><dep>8</dep></entry>
|
||||
</interpolater>
|
||||
</event>
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<event>
|
||||
<name>led-misc</name>
|
||||
<setting>
|
||||
<value>4</value>
|
||||
<condition>
|
||||
<equals>
|
||||
<property>/input/goflight/mfr/active</property>
|
||||
<value>0</value>
|
||||
</equals>
|
||||
</condition>
|
||||
</setting>
|
||||
<setting>
|
||||
<value>7</value>
|
||||
<condition>
|
||||
<not-equals>
|
||||
<property>/input/goflight/mfr/active</property>
|
||||
<value>0</value>
|
||||
</not-equals>
|
||||
</condition>
|
||||
</setting>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>led-misc-1</name>
|
||||
<setting>
|
||||
<value>7</value>
|
||||
<condition>
|
||||
<equals>
|
||||
<property>/input/goflight/mfr/active</property>
|
||||
<value>1</value>
|
||||
</equals>
|
||||
</condition>
|
||||
</setting>
|
||||
<setting>
|
||||
<value>0</value>
|
||||
<condition>
|
||||
<not-equals>
|
||||
<property>/input/goflight/mfr/active</property>
|
||||
<value>1</value>
|
||||
</not-equals>
|
||||
</condition>
|
||||
</setting>
|
||||
</event>
|
||||
-->
|
||||
<event>
|
||||
<desc>STA Button</desc>
|
||||
<name>button-1</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/sta</property>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>WXR Button</desc>
|
||||
<name>button-2</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/wxr</property>
|
||||
<property>/instrumentation/efis[0]/inputs/baro-knob</property>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>TERR Button</desc>
|
||||
<name>button-3</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 3");</script>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-4</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/arpt</property>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-5</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 5");</script>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-6</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 6");</script>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-7</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 7");</script>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-8</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 8");</script>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>TERR Button</desc>
|
||||
<name>button-9</name>
|
||||
<name>button-0</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/terr</property>
|
||||
|
@ -174,7 +92,7 @@
|
|||
|
||||
<event>
|
||||
<desc>POS Button</desc>
|
||||
<name>button-10</name>
|
||||
<name>button-1</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/pos</property>
|
||||
|
@ -183,7 +101,7 @@
|
|||
|
||||
<event>
|
||||
<desc>DATA Button</desc>
|
||||
<name>button-11</name>
|
||||
<name>button-2</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/data</property>
|
||||
|
@ -192,7 +110,7 @@
|
|||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-12</name>
|
||||
<name>button-3</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/arpt</property>
|
||||
|
@ -201,7 +119,7 @@
|
|||
|
||||
<event>
|
||||
<desc>WPT Button</desc>
|
||||
<name>button-13</name>
|
||||
<name>button-4</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/wpt</property>
|
||||
|
@ -210,7 +128,7 @@
|
|||
|
||||
<event>
|
||||
<desc>STA Button</desc>
|
||||
<name>button-14</name>
|
||||
<name>button-5</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/sta</property>
|
||||
|
@ -219,7 +137,7 @@
|
|||
|
||||
<event>
|
||||
<desc>WXR Button</desc>
|
||||
<name>button-15</name>
|
||||
<name>button-6</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/wxr</property>
|
||||
|
@ -227,44 +145,56 @@
|
|||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-16</name>
|
||||
<desc></desc>
|
||||
<name>button-7</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 16");</script>
|
||||
<script>debug.dump("Button 7");</script>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-17</name>
|
||||
<desc></desc>
|
||||
<name>button-8</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 17");</script>
|
||||
<script>setModeBit(0)</script>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>clearModeBit(0)</script>
|
||||
</binding>
|
||||
</mod-up>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-18</name>
|
||||
<desc></desc>
|
||||
<name>button-9</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 18");</script>
|
||||
<script>setModeBit(1)</script>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>clearModeBit(1)</script>
|
||||
</binding>
|
||||
</mod-up>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-19</name>
|
||||
<desc></desc>
|
||||
<name>button-10</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 19");</script>
|
||||
<script>debug.dump("Button 10");</script>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>in/HPA toggle</desc>
|
||||
<name>button-20</name>
|
||||
<name>button-11</name>
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/kpa-mode</property>
|
||||
|
@ -272,48 +202,71 @@
|
|||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-21</name>
|
||||
<desc>DH/MCA knob push</desc>
|
||||
<name>button-12</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 21");</script>
|
||||
<script>debug.dump("DH/MCA toggle");</script>
|
||||
</binding>
|
||||
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/minimums-mode</property>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-22</name>
|
||||
<desc></desc>
|
||||
<name>button-13</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 22");</script>
|
||||
<script>setRangeBit(0)</script>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>clearRangeBit(0)</script>
|
||||
</binding>
|
||||
</mod-up>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-23</name>
|
||||
<desc></desc>
|
||||
<name>button-14</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 23");</script>
|
||||
<script>setRangeBit(1)</script>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>clearRangeBit(1)</script>
|
||||
</binding>
|
||||
</mod-up>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ARPT Button</desc>
|
||||
<name>button-24</name>
|
||||
<desc></desc>
|
||||
<name>button-15</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button 24");</script>
|
||||
<script>setRangeBit(2)</script>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>clearRangeBit(2)</script>
|
||||
</binding>
|
||||
</mod-up>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>ADF-L switch</desc>
|
||||
<name>button-25</name>
|
||||
<name>button-16</name>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/instrumentation/efis/inputs/lh-vor-adf</property>
|
||||
<value>2</value>
|
||||
<value>-1</value>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
|
@ -327,7 +280,7 @@
|
|||
|
||||
<event>
|
||||
<desc>VOR-L switch</desc>
|
||||
<name>button-26</name>
|
||||
<name>button-17</name>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/instrumentation/efis/inputs/lh-vor-adf</property>
|
||||
|
@ -344,11 +297,11 @@
|
|||
|
||||
<event>
|
||||
<desc>ADF-R switch</desc>
|
||||
<name>button-27</name>
|
||||
<name>button-18</name>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/instrumentation/efis/inputs/rh-vor-adf</property>
|
||||
<value>2</value>
|
||||
<value>-1</value>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
|
@ -361,7 +314,7 @@
|
|||
|
||||
<event>
|
||||
<desc>VOR-R switch</desc>
|
||||
<name>button-28</name>
|
||||
<name>button-19</name>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/instrumentation/efis/inputs/rh-vor-adf</property>
|
||||
|
@ -378,7 +331,7 @@
|
|||
|
||||
<event>
|
||||
<desc>MTRS Button</desc>
|
||||
<name>button-29</name>
|
||||
<name>button-20</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button MTRS");</script>
|
||||
|
@ -391,8 +344,8 @@
|
|||
</event>
|
||||
|
||||
<event>
|
||||
<desc>MTRS Button</desc>
|
||||
<name>button-30</name>
|
||||
<desc>FPV Button</desc>
|
||||
<name>button-21</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("Button FPV");</script>
|
||||
|
@ -404,17 +357,4 @@
|
|||
</binding>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<desc>DH/MCA knob push</desc>
|
||||
<name>button-21</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>debug.dump("DH/MCA toggle");</script>
|
||||
</binding>
|
||||
|
||||
<binding>
|
||||
<command>property-toggle</command>
|
||||
<property>/instrumentation/efis/inputs/minimums-mode</property>
|
||||
</binding>
|
||||
</event>
|
||||
</PropertyList>
|
||||
|
|
|
@ -1,103 +1,34 @@
|
|||
<PropertyList>
|
||||
|
||||
<name>GoFlight MCP Pro</name>
|
||||
<debug-events type="bool">true</debug-events>
|
||||
<name>MCP Pro</name>
|
||||
<debug-events type="bool">false</debug-events>
|
||||
|
||||
<nasal>
|
||||
<open>
|
||||
<![CDATA[
|
||||
# map decimal digits 0..9 to standard 7-segment LCD pattern
|
||||
# 2 should be 5b
|
||||
# 3 should be 4f
|
||||
var translateDigitToSevenSegment = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67];
|
||||
|
||||
var encodeString = func(s, fieldWidth, padChar = nil)
|
||||
{
|
||||
var padCount = fieldWidth - size(s);
|
||||
var r = "";
|
||||
if (padChar == nil) padChar = chr(0);
|
||||
var altitudeAlphanumeric = func() { return goflight.mcp.altitudeData(); }
|
||||
var headingAlphanumeric = func() { return goflight.mcp.headingData(); }
|
||||
var courseAlphanumeric = func() { return goflight.mcp.course1Data(); }
|
||||
var course2Alphanumeric = func() { return goflight.mcp.course2Data(); }
|
||||
var speedAlphanumeric = func() { return goflight.mcp.speedData(); }
|
||||
var vspeedAlphanumeric = func() { return goflight.mcp.vsData(); }
|
||||
|
||||
while (padCount > 0) {
|
||||
r ~= padChar;
|
||||
padCount -=1;
|
||||
}
|
||||
|
||||
for (var i=0; i < size(s); i += 1) {
|
||||
if (s[i] == `.`) {
|
||||
# set the high bit to correspond to the decimal
|
||||
var lastIndex = size(r) - 1;
|
||||
r[lastIndex] = r[lastIndex] + 0x80;
|
||||
} elsif (s[i] == `-`) {
|
||||
r ~= chr(0x40);
|
||||
} else {
|
||||
var digitCode = s[i] - `0`;
|
||||
r ~= chr(translateDigitToSevenSegment[digitCode]);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
var altitudeAlphanumeric = func() {
|
||||
var alt = getprop("/autopilot/settings/target-altitude-ft");
|
||||
var altStr = sprintf("%d", alt);
|
||||
return encodeString(altStr, 5);
|
||||
}
|
||||
|
||||
var headingAlphanumeric = func() {
|
||||
var hdg = getprop("/autopilot/settings/heading-bug-deg");
|
||||
return encodeString(sprintf("%d", hdg), 3);
|
||||
}
|
||||
|
||||
var courseAlphanumeric = func() {
|
||||
var crs = getprop("/instrumentation/nav[0]/radials/selected-deg");
|
||||
return encodeString(sprintf("%d", crs), 3);
|
||||
}
|
||||
|
||||
var course2Alphanumeric = func() {
|
||||
var crs = getprop("/instrumentation/nav[1]/radials/selected-deg");
|
||||
return encodeString(sprintf("%d", crs), 3);
|
||||
}
|
||||
|
||||
var speedAlphanumeric = func() {
|
||||
var spd = getprop("/autopilot/settings/target-speed-kt");
|
||||
return encodeString(sprintf("%d", spd), 5);
|
||||
}
|
||||
|
||||
var vspeedAlphanumeric = func() {
|
||||
var vs = getprop("/autopilot/settings/vertical-speed-fpm");
|
||||
return encodeString(sprintf("%d", vs), 5);
|
||||
}
|
||||
|
||||
var ledState = func()
|
||||
{
|
||||
if (activeChannel == 1) return chr(0x04);
|
||||
return chr(0x2);
|
||||
}
|
||||
]]>
|
||||
</open>
|
||||
</nasal>
|
||||
|
||||
<event>
|
||||
<name>rel-dial</name>
|
||||
<interpolater>
|
||||
<mirrored type="bool">true</mirrored>
|
||||
<entry><ind>0</ind><dep>0</dep></entry>
|
||||
<entry><ind>1</ind><dep>1</dep></entry>
|
||||
<entry><ind>2</ind><dep>5</dep></entry>
|
||||
<entry><ind>3</ind><dep>10</dep></entry>
|
||||
<entry><ind>4</ind><dep>20</dep></entry>
|
||||
</interpolater>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>/autopilot/settings/target-altitude-ft</property>
|
||||
<factor type="double">100</factor>
|
||||
<min>0</min>
|
||||
</binding>
|
||||
<name>display-brightness</name>
|
||||
<setting>
|
||||
<property>/input/goflight/mcp/brightness</property>
|
||||
</setting>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-1</name>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-0</name>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>/autopilot/settings/heading-bug-deg</property>
|
||||
|
@ -107,16 +38,31 @@
|
|||
</binding>
|
||||
<interpolater>
|
||||
<mirrored type="bool">true</mirrored>
|
||||
<entry><ind>0</ind><dep>0</dep></entry>
|
||||
<entry><ind>1</ind><dep>1</dep></entry>
|
||||
<entry><ind>2</ind><dep>5</dep></entry>
|
||||
<entry><ind>3</ind><dep>10</dep></entry>
|
||||
<entry><ind>4</ind><dep>20</dep></entry>
|
||||
<entry>
|
||||
<ind>0</ind>
|
||||
<dep>0</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>1</ind>
|
||||
<dep>1</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>2</ind>
|
||||
<dep>5</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>3</ind>
|
||||
<dep>10</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>4</ind>
|
||||
<dep>30</dep>
|
||||
</entry>
|
||||
</interpolater>
|
||||
</event>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-2</name>
|
||||
<event>
|
||||
<name>rel-dial-1</name>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>/instrumentation/nav[0]/radials/selected-deg</property>
|
||||
|
@ -126,49 +72,99 @@
|
|||
</binding>
|
||||
<interpolater>
|
||||
<mirrored type="bool">true</mirrored>
|
||||
<entry><ind>0</ind><dep>0</dep></entry>
|
||||
<entry><ind>1</ind><dep>1</dep></entry>
|
||||
<entry><ind>2</ind><dep>5</dep></entry>
|
||||
<entry><ind>3</ind><dep>10</dep></entry>
|
||||
<entry><ind>4</ind><dep>20</dep></entry>
|
||||
<entry>
|
||||
<ind>0</ind>
|
||||
<dep>0</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>1</ind>
|
||||
<dep>1</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>2</ind>
|
||||
<dep>5</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>3</ind>
|
||||
<dep>10</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>4</ind>
|
||||
<dep>30</dep>
|
||||
</entry>
|
||||
</interpolater>
|
||||
</event>
|
||||
<event>
|
||||
<name>rel-dial-3</name>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-2</name>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>/autopilot/settings/vertical-speed-fpm</property>
|
||||
<factor type="double">10</factor>
|
||||
<factor type="double">-50</factor>
|
||||
<min>-8000</min>
|
||||
<max>12000</max>
|
||||
</binding>
|
||||
<interpolater>
|
||||
<mirrored type="bool">true</mirrored>
|
||||
<entry><ind>0</ind><dep>0</dep></entry>
|
||||
<entry><ind>1</ind><dep>1</dep></entry>
|
||||
<entry><ind>2</ind><dep>5</dep></entry>
|
||||
<entry><ind>3</ind><dep>10</dep></entry>
|
||||
<entry><ind>4</ind><dep>20</dep></entry>
|
||||
</interpolater>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-4</name>
|
||||
<entry>
|
||||
<ind>0</ind>
|
||||
<dep>0</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>1</ind>
|
||||
<dep>1</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>2</ind>
|
||||
<dep>2</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>3</ind>
|
||||
<dep>4</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>4</ind>
|
||||
<dep>10</dep>
|
||||
</entry>
|
||||
</interpolater>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-3</name>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>/autopilot/settings/target-speed-kt</property>
|
||||
<min>0</min>
|
||||
<command>nasal</command>
|
||||
<script>goflight.mcp.adjustSpeed(cmdarg().getNode("offset").getValue())</script>
|
||||
</binding>
|
||||
<interpolater>
|
||||
<mirrored type="bool">true</mirrored>
|
||||
<entry><ind>0</ind><dep>0</dep></entry>
|
||||
<entry><ind>1</ind><dep>1</dep></entry>
|
||||
<entry><ind>2</ind><dep>5</dep></entry>
|
||||
<entry><ind>3</ind><dep>10</dep></entry>
|
||||
<entry><ind>4</ind><dep>20</dep></entry>
|
||||
</interpolater>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-5</name>
|
||||
<entry>
|
||||
<ind>0</ind>
|
||||
<dep>0</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>1</ind>
|
||||
<dep>1</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>2</ind>
|
||||
<dep>5</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>3</ind>
|
||||
<dep>10</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>4</ind>
|
||||
<dep>20</dep>
|
||||
</entry>
|
||||
</interpolater>
|
||||
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>rel-dial-4</name>
|
||||
<binding>
|
||||
<command>property-adjust</command>
|
||||
<property>/instrumentation/nav[1]/radials/selected-deg</property>
|
||||
|
@ -178,80 +174,130 @@
|
|||
</binding>
|
||||
<interpolater>
|
||||
<mirrored type="bool">true</mirrored>
|
||||
<entry><ind>0</ind><dep>0</dep></entry>
|
||||
<entry><ind>1</ind><dep>1</dep></entry>
|
||||
<entry><ind>2</ind><dep>5</dep></entry>
|
||||
<entry><ind>3</ind><dep>10</dep></entry>
|
||||
<entry><ind>4</ind><dep>20</dep></entry>
|
||||
|
||||
<entry>
|
||||
<ind>0</ind>
|
||||
<dep>0</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>1</ind>
|
||||
<dep>1</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>2</ind>
|
||||
<dep>5</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>3</ind>
|
||||
<dep>10</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>4</ind>
|
||||
<dep>30</dep>
|
||||
</entry>
|
||||
</interpolater>
|
||||
</event>
|
||||
</event>
|
||||
|
||||
|
||||
<report>
|
||||
<report-id type="int">9</report-id>
|
||||
<watch>/autopilot/settings/target-altitude-ft</watch>
|
||||
<nasal-function>altitudeAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">7</report-id>
|
||||
<watch>/autopilot/settings/heading-bug-deg</watch>
|
||||
<nasal-function>headingAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">3</report-id>
|
||||
<watch>/instrumentation/nav[0]/radials/selected-deg</watch>
|
||||
<nasal-function>courseAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">11</report-id>
|
||||
<watch>/autopilot/settings/vertical-speed-fpm</watch>
|
||||
<nasal-function>vspeedAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">5</report-id>
|
||||
<watch>/autopilot/settings/target-speed-kt</watch>
|
||||
<nasal-function>speedAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">13</report-id>
|
||||
<watch>/instrumentation/nav[1]/radials/selected-deg</watch>
|
||||
<nasal-function>course2Alphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<!-- set LED from nose gear indicator -->
|
||||
<event>
|
||||
<name>led-misc</name>
|
||||
<name>rel-dial-5</name>
|
||||
<interpolater>
|
||||
<mirrored type="bool">true</mirrored>
|
||||
|
||||
<entry>
|
||||
<ind>0</ind>
|
||||
<dep>0</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>1</ind>
|
||||
<dep>1</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>2</ind>
|
||||
<dep>10</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>3</ind>
|
||||
<dep>50</dep>
|
||||
</entry>
|
||||
<entry>
|
||||
<ind>4</ind>
|
||||
<dep>100</dep>
|
||||
</entry>
|
||||
</interpolater>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
var x = cmdarg().getNode("offset").getValue();
|
||||
goflight.mcp.adjustAltitude(x * 50);
|
||||
</script>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
<report>
|
||||
<report-id type="int">9</report-id>
|
||||
<watch>/input/goflight/mcp/refresh</watch>
|
||||
<nasal-function>altitudeAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">7</report-id>
|
||||
<watch>/input/goflight/mcp/refresh-headings</watch>
|
||||
<nasal-function>headingAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">3</report-id>
|
||||
<watch>/input/goflight/mcp/refresh-headings</watch>
|
||||
<nasal-function>courseAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">11</report-id>
|
||||
<watch>/input/goflight/mcp/refresh</watch>
|
||||
<nasal-function>vspeedAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">5</report-id>
|
||||
<watch>/input/goflight/mcp/refresh</watch>
|
||||
<nasal-function>speedAlphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<report>
|
||||
<report-id type="int">13</report-id>
|
||||
<watch>/input/goflight/mcp/refresh-headings</watch>
|
||||
<nasal-function>course2Alphanumeric</nasal-function>
|
||||
</report>
|
||||
|
||||
<!-- LED driver properties - these are generated from individual
|
||||
bool properties by the LEDWatcher helper class above -->
|
||||
<event>
|
||||
<name>led-misc-0</name>
|
||||
<setting>
|
||||
<value>1</value>
|
||||
<condition>
|
||||
<property>/gear/gear[0]/indicator-servicable</property>
|
||||
<greater-than>
|
||||
<property>/gear/gear[0]/position-norm</property>
|
||||
<value>0.9</value>
|
||||
</greater-than>
|
||||
</condition>
|
||||
</setting>
|
||||
<setting>
|
||||
<value>0</value>
|
||||
<condition>
|
||||
<not>
|
||||
<and>
|
||||
<property>/gear/gear[0]/indicator-servicable</property>
|
||||
<greater-than>
|
||||
<property>/gear/gear[0]/position-norm</property>
|
||||
<value>0.9</value>
|
||||
</greater-than>
|
||||
</and>
|
||||
</not>
|
||||
</condition>
|
||||
<property>/input/goflight/mcp/led[0]</property>
|
||||
</setting>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>led-misc-1</name>
|
||||
<setting>
|
||||
<property>/input/goflight/mcp/led[1]</property>
|
||||
</setting>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>led-misc-2</name>
|
||||
<setting>
|
||||
<property>/input/goflight/mcp/led[2]</property>
|
||||
</setting>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>led-misc-3</name>
|
||||
<setting>
|
||||
<property>/input/goflight/mcp/led[3]</property>
|
||||
</setting>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>button-1</name>
|
||||
|
@ -266,7 +312,7 @@
|
|||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("Button 2")</script>
|
||||
</binding>
|
||||
</binding>enable
|
||||
</event>
|
||||
|
||||
<event>
|
||||
|
@ -321,8 +367,8 @@
|
|||
<desc>Speed</desc>
|
||||
<name>button-9</name>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("SPD")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>speed</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -330,8 +376,8 @@
|
|||
<name>button-10</name>
|
||||
<desc>Level Change</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("LVL CHG")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>level-change</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -339,8 +385,8 @@
|
|||
<name>button-11</name>
|
||||
<desc>Heading</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("HDG")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>heading</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -348,8 +394,8 @@
|
|||
<name>button-12</name>
|
||||
<desc>Approach</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("APP")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>approach</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -357,8 +403,8 @@
|
|||
<name>button-13</name>
|
||||
<desc>Altitude</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("ALT")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>altitude-hold</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -366,8 +412,8 @@
|
|||
<name>button-14</name>
|
||||
<desc>Vertical Speed</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("VS")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>vs</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -375,9 +421,17 @@
|
|||
<name>button-15</name>
|
||||
<desc>Disengage Bar</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("Disengage")</script>
|
||||
<command>property-assign</command>
|
||||
<property>/input/goflight/mcp/ap-disengage</property>
|
||||
<value>1</value>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/input/goflight/mcp/ap-disengage</property>
|
||||
<value>0</value>
|
||||
</binding>
|
||||
</mod-up>
|
||||
</event>
|
||||
|
||||
|
||||
|
@ -385,17 +439,25 @@
|
|||
<name>button-16</name>
|
||||
<desc>F/O FD Enable</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("F/O FD")</script>
|
||||
<command>property-assign</command>
|
||||
<property>/input/goflight/mcp/fo-fd-enabled</property>
|
||||
<value>1</value>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/input/goflight/mcp/fo-fd-enabled</property>
|
||||
<value>0</value>
|
||||
</binding>
|
||||
</mod-up>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>button-17</name>
|
||||
<desc>Altitude Intervention</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("ALT INTV")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>altitude-intervention</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -403,8 +465,8 @@
|
|||
<name>button-18</name>
|
||||
<desc>CWS-A</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("CWS-A")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>cws-a</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -412,8 +474,8 @@
|
|||
<name>button-19</name>
|
||||
<desc>CWS-B</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("CWS-B")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>cws-b</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -421,8 +483,8 @@
|
|||
<name>button-20</name>
|
||||
<desc>IAS knob push</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("IAS push")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>speed-push</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -430,8 +492,8 @@
|
|||
<name>button-21</name>
|
||||
<desc>HDG knob push</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("HDG push")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>heading-push</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -439,8 +501,8 @@
|
|||
<name>button-22</name>
|
||||
<desc>Altitude Knob Push</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("ALT SEL")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>altitude-select</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -448,17 +510,25 @@
|
|||
<name>button-23</name>
|
||||
<desc>Captain's FD Enable</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("CAP FD")</script>
|
||||
<command>property-assign</command>
|
||||
<property>/input/goflight/mcp/captain-fd-enabled</property>
|
||||
<value>1</value>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/input/goflight/mcp/captain-fd-enabled</property>
|
||||
<value>0</value>
|
||||
</binding>
|
||||
</mod-up>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>button-24</name>
|
||||
<desc>N1 select</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("N1")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>n1</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -466,8 +536,8 @@
|
|||
<name>button-25</name>
|
||||
<desc>VNAV</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("VNAV")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>vnav</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -475,8 +545,8 @@
|
|||
<name>button-26</name>
|
||||
<desc>LNAV</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("LNAV")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>lnav</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -484,8 +554,8 @@
|
|||
<name>button-27</name>
|
||||
<desc>CMD A</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("CMD A")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>command-a</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -493,8 +563,8 @@
|
|||
<name>button-28</name>
|
||||
<desc>CMD B</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("CMD B")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>command-b</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -502,17 +572,25 @@
|
|||
<name>button-29</name>
|
||||
<desc>AT arm</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("A/T ARM")</script>
|
||||
<command>property-assign</command>
|
||||
<property>/input/goflight/mcp/autothrottle-armed</property>
|
||||
<value>1</value>
|
||||
</binding>
|
||||
<mod-up>
|
||||
<binding>
|
||||
<command>property-assign</command>
|
||||
<property>/input/goflight/mcp/autothrottle-armed</property>
|
||||
<value>0</value>
|
||||
</binding>
|
||||
</mod-up>
|
||||
</event>
|
||||
|
||||
<event>
|
||||
<name>button-30</name>
|
||||
<desc>Soeed crossover</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("SPD C/O")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>speed-crossover</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -520,8 +598,8 @@
|
|||
<name>button-31</name>
|
||||
<desc>Speed intervention</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("SPD INTV")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>speed-intervention</button>
|
||||
</binding>
|
||||
</event>
|
||||
|
||||
|
@ -529,8 +607,8 @@
|
|||
<name>button-32</name>
|
||||
<desc>VOR / Localizer</desc>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>print("VOR/LOC")</script>
|
||||
<command>goflight-mcp-button</command>
|
||||
<button>vor</button>
|
||||
</binding>
|
||||
</event>
|
||||
</PropertyList>
|
||||
|
|
314
Nasal/goflight.nas
Normal file
314
Nasal/goflight.nas
Normal file
|
@ -0,0 +1,314 @@
|
|||
# helpers for working with GoFlight input devices
|
||||
|
||||
# map decimal digits 0..9 to standard 7-segment LCD pattern
|
||||
var translateDigitToSevenSegment = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67];
|
||||
|
||||
var formatFrequencyMHz = func(freqMhz, fieldWidth)
|
||||
{
|
||||
return bytesForString(sprintf("%.3f", freqMhz), fieldWidth);
|
||||
}
|
||||
|
||||
var formatFrequencyKHz = func(freqKhz, fieldWidth)
|
||||
{
|
||||
return bytesForString(sprintf("%6.2f", freqKhz), fieldWidth);
|
||||
}
|
||||
|
||||
var bytesForString = func(s, fieldWidth)
|
||||
{
|
||||
var padCount = fieldWidth - size(s);
|
||||
var r = "";
|
||||
|
||||
while (padCount > 0) {
|
||||
r ~= chr(0);
|
||||
padCount -=1;
|
||||
}
|
||||
|
||||
for (var i=0; i < size(s); i += 1) {
|
||||
if (s[i] == `.`) {
|
||||
# set the high bit to correspond to the decimal
|
||||
var lastIndex = size(r) - 1;
|
||||
r[lastIndex] = r[lastIndex] + 0x80;
|
||||
} else if (s[i] == ` `) { # spaces
|
||||
r ~= chr(0);
|
||||
} else if (s[i] == `-`) { # negative
|
||||
r ~= chr(0x40);
|
||||
} else {
|
||||
var digitCode = s[i] - `0`;
|
||||
r ~= chr(translateDigitToSevenSegment[digitCode]);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
# TEST
|
||||
# STBY
|
||||
# OFF
|
||||
# XPDR
|
||||
# TA
|
||||
# TA/RA
|
||||
|
||||
|
||||
var translateTo14Segment = {
|
||||
32: [0x0, 0x0], # space
|
||||
65: [0x22, 0x37], # A
|
||||
66: [0x0A, 0x8f],
|
||||
67: [0x00, 0x39],
|
||||
68: [0x08, 0x8f], # uppercase D
|
||||
69: [0x22, 0x39],
|
||||
70: [0x20, 0x31], # F
|
||||
77: [0x00, 0x00], # upper M
|
||||
78: [0x00, 0x00], # upper N
|
||||
79: [0x00, 0x3f], # upper O
|
||||
80: [0x22, 0x33], # upper P
|
||||
82: [0x26, 0x33], # upper R
|
||||
83: [0x22, 0x2d], # upper S
|
||||
84: [0x08, 0x81], # T
|
||||
88: [0x15, 0x40], # X
|
||||
89: [0x09, 0x40] # Y
|
||||
};
|
||||
|
||||
var formatFourteenSegment = func(s, fieldWidth)
|
||||
{
|
||||
var r = [];
|
||||
for (var i=0; i < size(s); i += 1) {
|
||||
var ch = s[i];
|
||||
if (!contains(translateTo14Segment, ch)) {
|
||||
debug.dump('No 14 segment mapping for:', ch);
|
||||
} else {
|
||||
var t = translateTo14Segment[s[i]];
|
||||
append(r, t[0]);
|
||||
append(r, t[1]);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
var reverseBytes = func(bytes)
|
||||
{
|
||||
var r=[];
|
||||
for (var i = size(bytes) - 1; i >=0; i -=1) {
|
||||
append(r, bytes[i]);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
var MFRController = {
|
||||
|
||||
new: func(prefix)
|
||||
{
|
||||
var m = {
|
||||
parents: [MFRController]
|
||||
};
|
||||
|
||||
# m._hideTimer = maketimer(m.DELAY, m, Tooltip._hideTimeout);
|
||||
# m._hideTimer.singleShot = 1;
|
||||
|
||||
return m;
|
||||
}
|
||||
};
|
||||
|
||||
var mcp = {
|
||||
init: func()
|
||||
{
|
||||
me._speedKnotsProp = props.globals.getNode("/autopilot/settings/target-speed-kt", 1);
|
||||
me._speedMachProp = props.globals.getNode("/autopilot/settings/target-speed-mach", 1);
|
||||
me._altitudeFtProp = props.globals.getNode("/autopilot/settings/target-altitude-ft", 1);
|
||||
me._vsFPMProp = props.globals.getNode("/autopilot/settings/vertical-speed-fpm", 1);
|
||||
me._headingProp = props.globals.getNode("/autopilot/settings/heading-bug-deg", 1);
|
||||
me._course1Prop = props.globals.getNode("/instrumentation/nav[0]/radials/selected-deg", 1);
|
||||
me._course2Prop = props.globals.getNode("/instrumentation/nav[1]/radials/selected-deg", 1);
|
||||
|
||||
me._useMach = 0;
|
||||
me._refreshProp = props.globals.getNode("/input/goflight/mcp/refresh", 1);
|
||||
me._refreshHeadingProp = props.globals.getNode("/input/goflight/mcp/refresh-headings", 1);
|
||||
|
||||
me._blankVSWindow = props.globals.getNode("/input/goflight/mcp/blank-vs-window", 1);
|
||||
|
||||
me._ledProps = [];
|
||||
for (var l=0; l<4; l+=1) {
|
||||
var node = props.globals.getNode("/input/goflight/mcp/led[" ~ l ~ "]", 1);
|
||||
node.setIntValue(0);
|
||||
append(me._ledProps, node);
|
||||
}
|
||||
|
||||
setlistener(me._speedKnotsProp, func { me.doRefresh(); } );
|
||||
setlistener(me._speedMachProp, func { me.doRefresh(); });
|
||||
setlistener(me._altitudeFtProp, func { me.doRefresh(); });
|
||||
setlistener(me._vsFPMProp, func { me.doRefresh(); });
|
||||
setlistener(me._blankVSWindow, func { me.doRefresh(); });
|
||||
|
||||
setlistener(me._headingProp, func { me.doRefreshHeading(); });
|
||||
setlistener(me._course1Prop, func { me.doRefreshHeading(); });
|
||||
setlistener(me._course2Prop, func { me.doRefreshHeading(); });
|
||||
|
||||
me.doRefresh();
|
||||
me.doRefreshHeading();
|
||||
|
||||
print("GoFlight MCP init done");
|
||||
},
|
||||
|
||||
setAltitudeFtProp: func(path)
|
||||
{
|
||||
me._altitudeFtProp = props.globals.getNode(path, 1);
|
||||
setlistener(me._altitudeFtProp, func { me.doRefresh(); });
|
||||
me.doRefresh();
|
||||
},
|
||||
|
||||
doRefresh: func()
|
||||
{
|
||||
me._refreshProp.setIntValue(0);
|
||||
},
|
||||
|
||||
doRefreshHeading: func()
|
||||
{
|
||||
me._refreshHeadingProp.setIntValue(0);
|
||||
},
|
||||
|
||||
setMachMode: func(useMach)
|
||||
{
|
||||
me._useMach = useMach;
|
||||
me.doRefresh();
|
||||
},
|
||||
|
||||
altitudeData: func()
|
||||
{
|
||||
# if window is blanked, return empty data
|
||||
var alt = me._altitudeFtProp.getValue();
|
||||
return bytesForString(sprintf("%d", alt), 5);
|
||||
},
|
||||
|
||||
vsData: func()
|
||||
{
|
||||
# if window is blanked, return empty data
|
||||
if (me._blankVSWindow.getValue()) {
|
||||
return bytesForString(" ", 5);
|
||||
}
|
||||
|
||||
var vs = me._vsFPMProp.getValue();
|
||||
return bytesForString(sprintf("%d", vs), 5);
|
||||
},
|
||||
|
||||
speedData: func()
|
||||
{
|
||||
if (me._useMach) {
|
||||
var mach = me._speedMachProp.getValue();
|
||||
return bytesForString(sprintf("%0.3f ", mach), 5);
|
||||
}
|
||||
|
||||
var spd = me._speedKnotsProp.getValue();
|
||||
return bytesForString(sprintf("%d", spd), 5);
|
||||
},
|
||||
|
||||
adjustSpeed: func(val)
|
||||
{
|
||||
if (me._useMach) {
|
||||
var mach = me._speedMachProp.getValue();
|
||||
me._speedMachProp.setDoubleValue(mach + (val * 0.01));
|
||||
return;
|
||||
}
|
||||
|
||||
var spd = me._speedKnotsProp.getValue();
|
||||
me._speedKnotsProp.setIntValue(spd + val);
|
||||
},
|
||||
|
||||
adjustAltitude: func(val)
|
||||
{
|
||||
var alt = me._altitudeFtProp.getValue();
|
||||
me._altitudeFtProp.setIntValue(alt + val);
|
||||
},
|
||||
|
||||
headingData: func()
|
||||
{
|
||||
var h = me._headingProp.getValue();
|
||||
return bytesForString(sprintf("%0d", h), 3);
|
||||
},
|
||||
|
||||
course1Data: func()
|
||||
{
|
||||
var h = me._course1Prop.getValue();
|
||||
return bytesForString(sprintf("%0d", h), 3);
|
||||
},
|
||||
|
||||
course2Data: func()
|
||||
{
|
||||
var h = me._course2Prop.getValue();
|
||||
return bytesForString(sprintf("%0d", h), 3);
|
||||
},
|
||||
|
||||
_ledNames: {
|
||||
'SPEED': [1, 0],
|
||||
'LVL-CHG': [1, 1],
|
||||
'HDG-SEL': [1, 2],
|
||||
'APP': [1,3],
|
||||
'ALT-HLD': [1,4],
|
||||
'V/S': [1,5],
|
||||
'F/O F/D': [1,7],
|
||||
# bank 2
|
||||
'CWS A': [2,1],
|
||||
'CWS B': [2,2],
|
||||
'CAP F/D': [2,6],
|
||||
'N1': [2, 7],
|
||||
# bank 3
|
||||
'VNAV': [3,0],
|
||||
'LNAV': [3,1],
|
||||
'CMD A': [3,2],
|
||||
'CMD B': [3,3],
|
||||
'A/T ARM': [3,4],
|
||||
'VOR-LOC': [3,7],
|
||||
},
|
||||
|
||||
watchPropertyForLED: func(prop, ledName)
|
||||
{
|
||||
if (!contains(me._ledNames, ledName)) {
|
||||
printlog('warn', 'Unknown GoFlight MCP LED:' ~ ledName);
|
||||
return;
|
||||
}
|
||||
|
||||
var ledData = me._ledNames[ledName];
|
||||
setlistener(prop, func(n) { me.setLED(ledData, n.getValue()); });
|
||||
},
|
||||
|
||||
setLED: func(data, b)
|
||||
{
|
||||
# data is a pair of ints; the LED node and the bit within
|
||||
var node = me._ledProps[data[0]];
|
||||
var ledBits = node.getValue();
|
||||
node.setIntValue(bits.switch(ledBits, data[1], b));
|
||||
}
|
||||
};
|
||||
|
||||
var flapPositions = [];
|
||||
var flapsNode = nil;
|
||||
|
||||
_setlistener("/sim/signals/nasal-dir-initialized", func {
|
||||
mcp.init();
|
||||
|
||||
# build flap axis quantisation data
|
||||
flapsNode = props.globals.getNode("/controls/flight/flaps");
|
||||
|
||||
foreach (var c; props.globals.getNode("/sim/flaps").getChildren("setting")) {
|
||||
var step = c.getValue();
|
||||
append(flapPositions, step);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var flapsAxisQuantized = func(val)
|
||||
{
|
||||
var normVal = (val + 1) * 0.5;
|
||||
var numSteps = size(flapPositions);
|
||||
for (var i=1; i<numSteps; i+=1) {
|
||||
var midPoint = (flapPositions[i-1] + flapPositions[i]) * 0.5;
|
||||
if (normVal < midPoint) {
|
||||
#print('flap Q:' ~ normVal ~ " to " ~ flapPositions[i-1]);
|
||||
flapsNode.setDoubleValue(flapPositions[i-1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#print('flap Q:' ~ normVal ~ " to " ~ flapPositions[numSteps-1]);
|
||||
# if we fall off the end, we're at the final value
|
||||
flapsNode.setDoubleValue(flapPositions[numSteps-1]);
|
||||
}
|
||||
|
||||
print("GoFlight Nasal module load done");
|
Loading…
Reference in a new issue