| 1 |
<PropertyList> |
| 2 |
|
| 3 |
<name>GoFlight MFR</name> |
| 4 |
<debug-events type="bool">false</debug-events> |
| 5 |
|
| 6 |
<nasal> |
| 7 |
<open> |
| 8 |
<![CDATA[ |
| 9 |
var activeChannel = 0; |
| 10 |
var activeNode = props.globals.getNode("/input/goflight/mfr/active", 1); |
| 11 |
var standbyNode = props.globals.getNode("/input/goflight/mfr/standby-mhz", 1); |
| 12 |
var selectedNode = props.globals.getNode("/input/goflight/mfr/selected-mhz", 1); |
| 13 |
var brightnessNode = props.globals.getNode("/input/goflight/mfr/brightness", 8); |
| 14 |
|
| 15 |
var updateActive = func(newActive) |
| 16 |
{ |
| 17 |
activeChannel = newActive; |
| 18 |
activeNode.setValue(activeChannel); |
| 19 |
|
| 20 |
printlog("info", "GoFlight MFR: Active channel is now:" ~ activeChannel); |
| 21 |
var prefix = "/instrumentation/nav[" ~ activeChannel ~ "]/frequencies/"; |
| 22 |
|
| 23 |
standbyNode.unalias(); |
| 24 |
standbyNode.alias(props.globals.getNode(prefix ~ "standby-mhz")); |
| 25 |
|
| 26 |
selectedNode.unalias(); |
| 27 |
selectedNode.alias(props.globals.getNode(prefix ~ "selected-mhz")); |
| 28 |
} |
| 29 |
|
| 30 |
var cycleActive = func() { |
| 31 |
activeChannel = activeChannel + 1; |
| 32 |
if (activeChannel >= 2) activeChannel = 0; |
| 33 |
updateActive(); |
| 34 |
} |
| 35 |
|
| 36 |
# map decimal digits 0..9 to standard 7-segment LCD pattern |
| 37 |
var translateDigitToSevenSegment = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f]; |
| 38 |
|
| 39 |
var formatFrequency = func(freqMhz) |
| 40 |
{ |
| 41 |
var s = sprintf("%.3f", freqMhz); |
| 42 |
var padCount = 6 - size(s); |
| 43 |
var r = ""; |
| 44 |
|
| 45 |
while (padCount > 0) { |
| 46 |
r ~= chr(0); |
| 47 |
padCount -=1; |
| 48 |
} |
| 49 |
|
| 50 |
for (var i=0; i < size(s); i += 1) { |
| 51 |
if (s[i] == `.`) { |
| 52 |
# set the high bit to correspond to the decimal |
| 53 |
var lastIndex = size(r) - 1; |
| 54 |
r[lastIndex] = r[lastIndex] + 0x80; |
| 55 |
} else { |
| 56 |
var digitCode = s[i] - `0`; |
| 57 |
r ~= chr(translateDigitToSevenSegment[digitCode]); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
return r; |
| 62 |
} |
| 63 |
|
| 64 |
var standbyAlphanumeric = func() { |
| 65 |
return formatFrequency(standbyNode.getValue()); |
| 66 |
} |
| 67 |
|
| 68 |
var selectedAlphanumeric = func() { |
| 69 |
return formatFrequency(selectedNode.getValue()); |
| 70 |
} |
| 71 |
|
| 72 |
updateActive(0); |
| 73 |
]]> |
| 74 |
</open> |
| 75 |
</nasal> |
| 76 |
|
| 77 |
<event> |
| 78 |
<name>rel-dial-0</name> |
| 79 |
<binding> |
| 80 |
<command>property-adjust</command> |
| 81 |
<property>/input/goflight/mfr/standby-mhz</property> |
| 82 |
<min type="double">108.0</min> |
| 83 |
<max type="double">117.95</max> |
| 84 |
<wrap type="bool">true</wrap> |
| 85 |
</binding> |
| 86 |
<interpolater> |
| 87 |
<entry><ind>0</ind><dep>0</dep></entry> |
| 88 |
<entry><ind>1</ind><dep>1</dep></entry> |
| 89 |
<entry><ind>2</ind><dep>2</dep></entry> |
| 90 |
<entry><ind>3</ind><dep>4</dep></entry> |
| 91 |
<entry><ind>4</ind><dep>8</dep></entry> |
| 92 |
</interpolater> |
| 93 |
</event> |
| 94 |
|
| 95 |
<event> |
| 96 |
<name>rel-dial-1</name> |
| 97 |
<binding> |
| 98 |
<command>property-adjust</command> |
| 99 |
<property>/input/goflight/mfr/standby-mhz</property> |
| 100 |
<factor type="double">0.025</factor> |
| 101 |
<min type="double">108.0</min> |
| 102 |
<max type="double">117.95</max> |
| 103 |
<wrap type="bool">true</wrap> |
| 104 |
</binding> |
| 105 |
<interpolater> |
| 106 |
<entry><ind>0</ind><dep>0</dep></entry> |
| 107 |
<entry><ind>1</ind><dep>1</dep></entry> |
| 108 |
<entry><ind>2</ind><dep>2</dep></entry> |
| 109 |
<entry><ind>3</ind><dep>4</dep></entry> |
| 110 |
<entry><ind>4</ind><dep>8</dep></entry> |
| 111 |
</interpolater> |
| 112 |
</event> |
| 113 |
|
| 114 |
<report> |
| 115 |
<report-id type="int">3</report-id> |
| 116 |
<watch>/input/goflight/mfr/active</watch> |
| 117 |
|
| 118 |
|
| 119 |
<watch>/instrumentation/nav[0]/frequencies/selected-mhz</watch> |
| 120 |
<watch>/instrumentation/nav[1]/frequencies/selected-mhz</watch> |
| 121 |
<nasal-function>selectedAlphanumeric</nasal-function> |
| 122 |
</report> |
| 123 |
|
| 124 |
<report> |
| 125 |
<report-id type="int">5</report-id> |
| 126 |
<watch>/input/goflight/mfr/active</watch> |
| 127 |
|
| 128 |
|
| 129 |
<watch>/instrumentation/nav[0]/frequencies/standby-mhz</watch> |
| 130 |
<watch>/instrumentation/nav[1]/frequencies/standby-mhz</watch> |
| 131 |
<nasal-function>standbyAlphanumeric</nasal-function> |
| 132 |
</report> |
| 133 |
|
| 134 |
<event> |
| 135 |
<name>led-misc-1</name> |
| 136 |
<setting> |
| 137 |
<value>1</value> |
| 138 |
<condition> |
| 139 |
<equals> |
| 140 |
<property>/input/goflight/mfr/active</property> |
| 141 |
<value>0</value> |
| 142 |
</equals> |
| 143 |
</condition> |
| 144 |
</setting> |
| 145 |
<setting> |
| 146 |
<value>0</value> |
| 147 |
<condition> |
| 148 |
<not-equals> |
| 149 |
<property>/input/goflight/mfr/active</property> |
| 150 |
<value>0</value> |
| 151 |
</not-equals> |
| 152 |
</condition> |
| 153 |
</setting> |
| 154 |
</event> |
| 155 |
|
| 156 |
<event> |
| 157 |
<name>led-misc-2</name> |
| 158 |
<setting> |
| 159 |
<value>1</value> |
| 160 |
<condition> |
| 161 |
<equals> |
| 162 |
<property>/input/goflight/mfr/active</property> |
| 163 |
<value>1</value> |
| 164 |
</equals> |
| 165 |
</condition> |
| 166 |
</setting> |
| 167 |
<setting> |
| 168 |
<value>0</value> |
| 169 |
<condition> |
| 170 |
<not-equals> |
| 171 |
<property>/input/goflight/mfr/active</property> |
| 172 |
<value>1</value> |
| 173 |
</not-equals> |
| 174 |
</condition> |
| 175 |
</setting> |
| 176 |
</event> |
| 177 |
|
| 178 |
<event> |
| 179 |
<name>display-brightness</name> |
| 180 |
<setting> |
| 181 |
<property>/input/goflight/mfr/brightness</property> |
| 182 |
</setting> |
| 183 |
</event> |
| 184 |
|
| 185 |
<event> |
| 186 |
<desc>Transfer Button</desc> |
| 187 |
<name>button-1</name> |
| 188 |
<binding> |
| 189 |
<command>property-swap</command> |
| 190 |
<property>/input/goflight/mfr/standby-mhz</property> |
| 191 |
<property>/input/goflight/mfr/selected-mhz</property> |
| 192 |
</binding> |
| 193 |
</event> |
| 194 |
|
| 195 |
<event> |
| 196 |
<desc>Nav 1 Button</desc> |
| 197 |
<name>button-2</name> |
| 198 |
<binding> |
| 199 |
<command>nasal</command> |
| 200 |
<script>updateActive(0)</script> |
| 201 |
</binding> |
| 202 |
</event> |
| 203 |
|
| 204 |
<event> |
| 205 |
<desc>Nav 2 Button</desc> |
| 206 |
<name>button-3</name> |
| 207 |
<binding> |
| 208 |
<command>nasal</command> |
| 209 |
<script>updateActive(1)</script> |
| 210 |
</binding> |
| 211 |
</event> |
| 212 |
|
| 213 |
</PropertyList> |