]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/atc610x.cxx
ignore resets for now because every z/Z key press would trigger a call to NOAA. We...
[flightgear.git] / src / Network / atc610x.cxx
index 986065fd388fe2a64ef8660497c865847cb05c90..1b901592f5e24ca1c28736fc2ec89e8a03a1b681 100644 (file)
@@ -43,8 +43,8 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/io/iochannel.hxx>
 #include <simgear/math/sg_types.hxx>
-#include <simgear/misc/props.hxx>
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/props/props.hxx>
 
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
@@ -396,9 +396,11 @@ bool FGATC610x::open() {
 
     mag_compass = fgGetNode( "/instrumentation/magnetic-compass/indicated-heading-deg", true );
 
-    dme_min = fgGetNode( "/radios/dme/ete-min", true );
-    dme_kt = fgGetNode( "/radios/dme/speed-kt", true );
-    dme_nm = fgGetNode( "/radios/dme/distance-nm", true );
+    dme_min = fgGetNode( "/instrumentation/dme/indicated-time-min", true );
+    dme_kt = fgGetNode( "/instrumentation/dme/indicated-ground-speed-kt",
+                        true );
+    dme_nm = fgGetNode( "/instrumentation/dme/indicated-distance-nm", true );
+    dme_in_range = fgGetNode( "/instrumentation/dme/in-range", true );
 
     adf_bus_power = fgGetNode( "/systems/electrical/outputs/adf", true );
     dme_bus_power = fgGetNode( "/systems/electrical/outputs/dme", true );
@@ -473,6 +475,7 @@ bool FGATC610x::open() {
                   true );
     alt_press = fgGetNode( "/instrumentation/altimeter/setting-inhg", true );
     adf_hdg = fgGetNode( "/radios/kr-87/inputs/rotation-deg", true );
+    hdg_bug = fgGetNode( "/autopilot/settings/heading-bug-deg", true );
 
     elevator_center = fgGetNode( "/input/atc610x/elevator/center", true );
     elevator_min = fgGetNode( "/input/atc610x/elevator/min", true );
@@ -508,23 +511,26 @@ bool FGATC610x::open() {
     nav2vol_min = fgGetNode( "/input/atc610x/nav2vol/min", true );
     nav2vol_max = fgGetNode( "/input/atc610x/nav2vol/max", true );
 
-    comm1_servicable = fgGetNode( "/instrumentation/comm[0]/servicable", true );
-    comm2_servicable = fgGetNode( "/instrumentation/comm[1]/servicable", true );
-    nav1_servicable = fgGetNode( "/instrumentation/nav[0]/servicable", true );
-    nav2_servicable = fgGetNode( "/instrumentation/nav[1]/servicable", true );
-    adf_servicable = fgGetNode( "/instrumentation/adf/servicable", true );
-    xpdr_servicable = fgGetNode( "/instrumentation/transponder/servicable",
+    ignore_flight_controls
+        = fgGetNode( "/input/atc610x/ignore-flight-controls", true );
+
+    comm1_serviceable = fgGetNode( "/instrumentation/comm[0]/serviceable", true );
+    comm2_serviceable = fgGetNode( "/instrumentation/comm[1]/serviceable", true );
+    nav1_serviceable = fgGetNode( "/instrumentation/nav[0]/serviceable", true );
+    nav2_serviceable = fgGetNode( "/instrumentation/nav[1]/serviceable", true );
+    adf_serviceable = fgGetNode( "/instrumentation/adf/serviceable", true );
+    xpdr_serviceable = fgGetNode( "/radios/kt-70/inputs/serviceable",
                                  true );
-    dme_servicable = fgGetNode( "/instrumentation/dme/servicable", true );
+    dme_serviceable = fgGetNode( "/instrumentation/dme/serviceable", true );
 
-    // default to having everything servicable
-    comm1_servicable->setBoolValue( true );
-    comm2_servicable->setBoolValue( true );
-    nav1_servicable->setBoolValue( true );
-    nav2_servicable->setBoolValue( true );
-    adf_servicable->setBoolValue( true );
-    xpdr_servicable->setBoolValue( true );
-    dme_servicable->setBoolValue( true );
+    // default to having everything serviceable
+    comm1_serviceable->setBoolValue( true );
+    comm2_serviceable->setBoolValue( true );
+    nav1_serviceable->setBoolValue( true );
+    nav2_serviceable->setBoolValue( true );
+    adf_serviceable->setBoolValue( true );
+    xpdr_serviceable->setBoolValue( true );
+    dme_serviceable->setBoolValue( true );
 
     return true;
 }
@@ -660,7 +666,7 @@ static int tony_magic( int raw, int obs[3] ) {
            }
        }
         result = obs[1] - obs[2];
-        if ( abs(result) > 200 ) {
+        if ( abs(result) > 400 ) {
             // ignore
             result = 0;
         }
@@ -677,8 +683,8 @@ static int tony_magic( int raw, int obs[3] ) {
 
 
 static double instr_pot_filter( double ave, double val ) {
-    if ( fabs(ave - val) < 200 || fabs(val) < fabs(ave) ) {
-        return 0.66 * ave + 0.34 * val;
+    if ( fabs(ave - val) < 400 || fabs(val) < fabs(ave) ) {
+        return 0.5 * ave + 0.5 * val;
     } else {
         return ave;
     }
@@ -701,48 +707,58 @@ bool FGATC610x::do_analog_in() {
 
     float tmp;
 
-    // aileron
-    tmp = scale( ailerons_center->getIntValue(), ailerons_min->getIntValue(),
-                 ailerons_max->getIntValue(), analog_in_data[0] );
-    fgSetFloat( "/controls/aileron", tmp );
-    // cout << "aileron = " << analog_in_data[0] << " = " << tmp;
-    // elevator
-    tmp = -scale( elevator_center->getIntValue(), elevator_min->getIntValue(),
-                  elevator_max->getIntValue(), analog_in_data[5] );
-    fgSetFloat( "/controls/elevator", tmp );
-    // cout << "trim = " << analog_in_data[4] << " = " << tmp;
-
-    // elevator trim
-    tmp = scale( trim_center->getIntValue(), trim_min->getIntValue(),
-                 trim_max->getIntValue(), analog_in_data[4] );
-    fgSetFloat( "/controls/elevator-trim", tmp );
-    // cout << " elev = " << analog_in_data[5] << " = " << tmp << endl;
-
-    // mixture
-    tmp = scale( mixture_min->getIntValue(), mixture_max->getIntValue(),
-                 analog_in_data[6] );
-    fgSetFloat( "/controls/mixture[0]", tmp );
-    fgSetFloat( "/controls/mixture[1]", tmp );
-
-    // throttle
-    tmp = scale( throttle_min->getIntValue(), throttle_max->getIntValue(),
-                 analog_in_data[8] );
-    fgSetFloat( "/controls/throttle[0]", tmp );
-    fgSetFloat( "/controls/throttle[1]", tmp );
-    // cout << "throttle = " << tmp << endl;
-
-    // rudder
-    tmp = scale( rudder_center->getIntValue(), rudder_min->getIntValue(),
-                 rudder_max->getIntValue(), analog_in_data[10] );
-    fgSetFloat( "/controls/rudder", -tmp );
-
-    // toe brakes
-    tmp = scale( brake_left_min->getIntValue(), brake_left_max->getIntValue(),
-                 analog_in_data[20] );
-    fgSetFloat( "/controls/brakes[0]", tmp );
-    tmp = scale( brake_right_min->getIntValue(), brake_right_max->getIntValue(),
-                 analog_in_data[21] );
-    fgSetFloat( "/controls/brakes[1]", tmp );
+    if ( !ignore_flight_controls->getBoolValue() ) {
+        // aileron
+        tmp = scale( ailerons_center->getIntValue(),
+                     ailerons_min->getIntValue(),
+                     ailerons_max->getIntValue(), analog_in_data[0] );
+        fgSetFloat( "/controls/flight/aileron", tmp );
+        // cout << "aileron = " << analog_in_data[0] << " = " << tmp;
+
+        // elevator
+        tmp = -scale( elevator_center->getIntValue(),
+                      elevator_min->getIntValue(),
+                      elevator_max->getIntValue(), analog_in_data[5] );
+        fgSetFloat( "/controls/flight/elevator", tmp );
+        // cout << "trim = " << analog_in_data[4] << " = " << tmp;
+
+        // elevator trim
+        tmp = scale( trim_center->getIntValue(), trim_min->getIntValue(),
+                     trim_max->getIntValue(), analog_in_data[4] );
+        fgSetFloat( "/controls/flight/elevator-trim", tmp );
+        // cout << " elev = " << analog_in_data[5] << " = " << tmp << endl;
+
+        // mixture
+        tmp = scale( mixture_min->getIntValue(), mixture_max->getIntValue(),
+                     analog_in_data[6] );
+        fgSetFloat( "/controls/engines/engine[0]/mixture", tmp );
+        fgSetFloat( "/controls/engines/engine[1]/mixture", tmp );
+
+        // throttle
+        tmp = scale( throttle_min->getIntValue(), throttle_max->getIntValue(),
+                     analog_in_data[8] );
+        fgSetFloat( "/controls/engines/engine[0]/throttle", tmp );
+        fgSetFloat( "/controls/engines/engine[1]/throttle", tmp );
+        // cout << "throttle = " << tmp << endl;
+
+        if ( use_rudder ) {
+            // rudder
+            tmp = scale( rudder_center->getIntValue(),
+                         rudder_min->getIntValue(),
+                         rudder_max->getIntValue(), analog_in_data[10] );
+            fgSetFloat( "/controls/flight/rudder", -tmp );
+
+            // toe brakes
+            tmp = scale( brake_left_min->getIntValue(),
+                         brake_left_max->getIntValue(),
+                         analog_in_data[20] );
+            fgSetFloat( "/controls/gear/brake-left", tmp );
+            tmp = scale( brake_right_min->getIntValue(),
+                         brake_right_max->getIntValue(),
+                         analog_in_data[21] );
+            fgSetFloat( "/controls/gear/brake-right", tmp );
+        }
+    }
 
     // nav1 volume
     tmp = (float)analog_in_data[25] / 1024.0f;
@@ -758,12 +774,13 @@ bool FGATC610x::do_analog_in() {
 
     // instrument panel pots
     static bool first = true;
-    static int obs1[3], obs2[3], obs3[3], obs4[3], obs5[3];
+    static int obs1[3], obs2[3], obs3[3], obs4[3], obs5[3], obs6[3];
     static double diff1_ave = 0.0;
     static double diff2_ave = 0.0;
     static double diff3_ave = 0.0;
     static double diff4_ave = 0.0;
     static double diff5_ave = 0.0;
+    static double diff6_ave = 0.0;
 
     if ( first ) {
         first = false;
@@ -772,48 +789,57 @@ bool FGATC610x::do_analog_in() {
         obs3[0] = obs3[1] = obs3[2] = analog_in_data[29];
         obs4[0] = obs4[1] = obs4[2] = analog_in_data[30];
         obs5[0] = obs5[1] = obs5[2] = analog_in_data[31];
+        obs6[0] = obs6[1] = obs6[2] = analog_in_data[14];
     }
 
     int diff1 = tony_magic( analog_in_data[11], obs1 );
     int diff2 = tony_magic( analog_in_data[28], obs2 );
-    int diff3 = tony_magic( analog_in_data[39], obs3 );
+    int diff3 = tony_magic( analog_in_data[29], obs3 );
     int diff4 = tony_magic( analog_in_data[30], obs4 );
     int diff5 = tony_magic( analog_in_data[31], obs5 );
+    int diff6 = tony_magic( analog_in_data[14], obs6 );
 
     diff1_ave = instr_pot_filter( diff1_ave, diff1 );
     diff2_ave = instr_pot_filter( diff2_ave, diff2 );
     diff3_ave = instr_pot_filter( diff3_ave, diff3 );
     diff4_ave = instr_pot_filter( diff4_ave, diff4 );
     diff5_ave = instr_pot_filter( diff5_ave, diff5 );
+    diff6_ave = instr_pot_filter( diff6_ave, diff6 );
 
-    tmp = ati_bird->getDoubleValue() + (diff1_ave * (20.0/880.0) );
-    if ( tmp < -10.0 ) { tmp = -10.0; }
-    if ( tmp > 10.0 ) { tmp = 10.0; }
-    fgSetFloat( "/instrumentation/attitude-indicator/horizon-offset-deg", tmp );
-
-    tmp = alt_press->getDoubleValue() + (diff2_ave * (1.125/880.0) );
+    tmp = alt_press->getDoubleValue() + (diff1_ave * (0.25/888.0) );
     if ( tmp < 27.9 ) { tmp = 27.9; }
     if ( tmp > 31.4 ) { tmp = 31.4; }
     fgSetFloat( "/instrumentation/altimeter/setting-inhg", tmp );
 
-    tmp = nav1_obs->getDoubleValue() + (diff3_ave * (72.0/880.0) );
+    tmp = ati_bird->getDoubleValue() + (diff2_ave * (20.0/888.0) );
+    if ( tmp < -10.0 ) { tmp = -10.0; }
+    if ( tmp > 10.0 ) { tmp = 10.0; }
+    fgSetFloat( "/instrumentation/attitude-indicator/horizon-offset-deg", tmp );
+
+    tmp = nav1_obs->getDoubleValue() + (diff3_ave * (72.0/888.0) );
     while ( tmp >= 360.0 ) { tmp -= 360.0; }
     while ( tmp < 0.0 ) { tmp += 360.0; }
     // cout << " obs = " << tmp << endl;
     fgSetFloat( "/radios/nav[0]/radials/selected-deg", tmp );
 
-    tmp = nav2_obs->getDoubleValue() + (diff4_ave * (72.0/880.0) );
+    tmp = nav2_obs->getDoubleValue() + (diff4_ave * (72.0/888.0) );
     while ( tmp >= 360.0 ) { tmp -= 360.0; }
     while ( tmp < 0.0 ) { tmp += 360.0; }
     // cout << " obs = " << tmp << endl;
     fgSetFloat( "/radios/nav[1]/radials/selected-deg", tmp );
 
-    tmp = adf_hdg->getDoubleValue() + (diff5_ave * (72.0/880.0) );
+    tmp = adf_hdg->getDoubleValue() + (diff5_ave * (72.0/888.0) );
     while ( tmp >= 360.0 ) { tmp -= 360.0; }
     while ( tmp < 0.0 ) { tmp += 360.0; }
     // cout << " obs = " << tmp << endl;
     fgSetFloat( "/radios/kr-87/inputs/rotation-deg", tmp );
 
+    tmp = hdg_bug->getDoubleValue() + (diff6_ave * (72.0/888.0) );
+    while ( tmp >= 360.0 ) { tmp -= 360.0; }
+    while ( tmp < 0.0 ) { tmp += 360.0; }
+    // cout << " obs = " << tmp << endl;
+    fgSetFloat( "/autopilot/settings/heading-bug-deg", tmp );
+
     return true;
 }
 
@@ -863,20 +889,28 @@ bool FGATC610x::do_radio_switches() {
     dme_switch = (radio_switch_data[7] >> 4) & 0x03;
     if ( dme_switch == 0 ) {
        // off
-       fgSetInt( "/radios/dme/switch-position", 0 );
+       fgSetInt( "/instrumentation/dme/switch-position", 0 );
     } else if ( dme_switch == 2 ) {
        // nav1
-       fgSetInt( "/radios/dme/switch-position", 1 );
+       fgSetInt( "/instrumentation/dme/switch-position", 1 );
+        fgSetString( "/instrumentation/dme/frequencies/source",
+                     "/radios/nav[0]/frequencies/selected-mhz" );
+       freq = fgGetFloat( "/radios/nav[0]/frequencies/selected-mhz", true );
+        fgSetFloat( "/instrumentation/dme/frequencies/selected-mhz", freq );
     } else if ( dme_switch == 1 ) {
        // nav2
-       fgSetInt( "/radios/dme/switch-position", 3 );
+       fgSetInt( "/instrumentation/dme/switch-position", 3 );
+        fgSetString( "/instrumentation/dme/frequencies/source",
+                     "/radios/nav[1]/frequencies/selected-mhz" );
+       freq = fgGetFloat( "/radios/nav[1]/frequencies/selected-mhz", true );
+        fgSetFloat( "/instrumentation/dme/frequencies/selected-mhz", freq );
     }
 
     // NavCom1 Power
     fgSetBool( "/radios/comm[0]/inputs/power-btn",
                radio_switch_data[7] & 0x01 );
 
-    if ( navcom1_has_power() && comm1_servicable->getBoolValue() ) {
+    if ( navcom1_has_power() && comm1_serviceable->getBoolValue() ) {
         // Com1 Swap
         int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
         static int last_com1_swap;
@@ -893,7 +927,7 @@ bool FGATC610x::do_radio_switches() {
     fgSetBool( "/radios/comm[1]/inputs/power-btn",
                radio_switch_data[15] & 0x01 );
 
-    if ( navcom2_has_power() && comm2_servicable->getBoolValue() ) {
+    if ( navcom2_has_power() && comm2_serviceable->getBoolValue() ) {
         // Com2 Swap
         int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
         static int last_com2_swap;
@@ -906,7 +940,7 @@ bool FGATC610x::do_radio_switches() {
         last_com2_swap = com2_swap;
     }
 
-    if ( navcom1_has_power() && nav1_servicable->getBoolValue() ) {
+    if ( navcom1_has_power() && nav1_serviceable->getBoolValue() ) {
         // Nav1 Swap
         int nav1_swap = radio_switch_data[11] & 0x01;
         static int last_nav1_swap;
@@ -919,7 +953,7 @@ bool FGATC610x::do_radio_switches() {
         last_nav1_swap = nav1_swap;
     }
 
-    if ( navcom2_has_power() && nav2_servicable->getBoolValue() ) {
+    if ( navcom2_has_power() && nav2_serviceable->getBoolValue() ) {
         // Nav2 Swap
         int nav2_swap = !(radio_switch_data[19] & 0x01);
         static int last_nav2_swap;
@@ -932,7 +966,7 @@ bool FGATC610x::do_radio_switches() {
         last_nav2_swap = nav2_swap;
     }
 
-    if ( navcom1_has_power() && comm1_servicable->getBoolValue() ) {
+    if ( navcom1_has_power() && comm1_serviceable->getBoolValue() ) {
         // Com1 Tuner
         int com1_tuner_fine = ((radio_switch_data[5] >> 4) & 0x0f) - 1;
         int com1_tuner_coarse = (radio_switch_data[5] & 0x0f) - 1;
@@ -984,7 +1018,7 @@ bool FGATC610x::do_radio_switches() {
                     coarse_freq + fine_freq / 40.0 );
     }
 
-    if ( navcom2_has_power() && comm2_servicable->getBoolValue() ) {
+    if ( navcom2_has_power() && comm2_serviceable->getBoolValue() ) {
         // Com2 Tuner
         int com2_tuner_fine = ((radio_switch_data[13] >> 4) & 0x0f) - 1;
         int com2_tuner_coarse = (radio_switch_data[13] & 0x0f) - 1;
@@ -1036,7 +1070,7 @@ bool FGATC610x::do_radio_switches() {
                     coarse_freq + fine_freq / 40.0 );
     }
 
-    if ( navcom1_has_power() && nav1_servicable->getBoolValue() ) {
+    if ( navcom1_has_power() && nav1_serviceable->getBoolValue() ) {
         // Nav1 Tuner
         int nav1_tuner_fine = ((radio_switch_data[9] >> 4) & 0x0f) - 1;
         int nav1_tuner_coarse = (radio_switch_data[9] & 0x0f) - 1;
@@ -1088,7 +1122,7 @@ bool FGATC610x::do_radio_switches() {
                     coarse_freq + fine_freq / 20.0 );
     }
 
-    if ( navcom2_has_power() && nav2_servicable->getBoolValue() ) {
+    if ( navcom2_has_power() && nav2_serviceable->getBoolValue() ) {
         // Nav2 Tuner
         int nav2_tuner_fine = ((radio_switch_data[17] >> 4) & 0x0f) - 1;
         int nav2_tuner_coarse = (radio_switch_data[17] & 0x0f) - 1;
@@ -1147,7 +1181,7 @@ bool FGATC610x::do_radio_switches() {
     static int last_adf_tuner_fine = adf_tuner_fine;
     static int last_adf_tuner_coarse = adf_tuner_coarse;
 
-    if ( adf_has_power() && adf_servicable->getBoolValue() ) {
+    if ( adf_has_power() && adf_serviceable->getBoolValue() ) {
         // cout << "adf_stby_mode = " << adf_stby_mode->getIntValue() << endl;
         if ( adf_count_mode->getIntValue() == 2 ) {
             // tune count down timer
@@ -1221,8 +1255,13 @@ bool FGATC610x::do_radio_switches() {
               !(radio_switch_data[23] & 0x01) );
     fgSetInt( "/radios/kr-87/inputs/bfo-btn",
               !(radio_switch_data[23] >> 1 & 0x01) );
+#ifdef CURT_HARDWARE
     fgSetInt( "/radios/kr-87/inputs/frq-btn",
               !(radio_switch_data[23] >> 2 & 0x01) );
+#else
+    fgSetInt( "/radios/kr-87/inputs/frq-btn",
+              (radio_switch_data[23] >> 2 & 0x01) );
+#endif
     fgSetInt( "/radios/kr-87/inputs/flt-et-btn",
               !(radio_switch_data[23] >> 3 & 0x01) );
     fgSetInt( "/radios/kr-87/inputs/set-rst-btn",
@@ -1253,7 +1292,7 @@ bool FGATC610x::do_radio_switches() {
         }
     }
 
-    if ( xpdr_has_power() && xpdr_servicable->getBoolValue() ) {
+    if ( xpdr_has_power() && xpdr_serviceable->getBoolValue() ) {
         int id_code = xpdr_id_code->getIntValue();
         int digit[4];
         int place = 1000;
@@ -1324,44 +1363,54 @@ bool FGATC610x::do_radio_display() {
     char digits[10];
     int i;
 
-    if ( dme_has_power() && dme_servicable->getBoolValue() ) {
-       // DME minutes
-       float minutes = dme_min->getFloatValue();
-       if ( minutes > 999 ) {
-           minutes = 999.0;
-       }
-       snprintf(digits, 7, "%03.0f", minutes);
-       for ( i = 0; i < 6; ++i ) {
-           digits[i] -= '0';
-       }
-       radio_display_data[0] = digits[1] << 4 | digits[2];
-       radio_display_data[1] = 0xf0 | digits[0];
+    if ( dme_has_power() && dme_serviceable->getBoolValue() ) {
+        if ( dme_in_range->getBoolValue() ) {
+            // DME minutes
+            float minutes = dme_min->getFloatValue();
+            if ( minutes > 999 ) {
+                minutes = 999.0;
+            }
+            snprintf(digits, 7, "%03.0f", minutes);
+            for ( i = 0; i < 6; ++i ) {
+                digits[i] -= '0';
+            }
+            radio_display_data[0] = digits[1] << 4 | digits[2];
+            radio_display_data[1] = 0xf0 | digits[0];
        
-       // DME knots
-       float knots = dme_kt->getFloatValue();
-       if ( knots > 999 ) {
-           knots = 999.0;
-       }
-       snprintf(digits, 7, "%03.0f", knots);
-       for ( i = 0; i < 6; ++i ) {
-           digits[i] -= '0';
-       }
-       radio_display_data[2] = digits[1] << 4 | digits[2];
-       radio_display_data[3] = 0xf0 | digits[0];
+            // DME knots
+            float knots = dme_kt->getFloatValue();
+            if ( knots > 999 ) {
+                knots = 999.0;
+            }
+            snprintf(digits, 7, "%03.0f", knots);
+            for ( i = 0; i < 6; ++i ) {
+                digits[i] -= '0';
+            }
+            radio_display_data[2] = digits[1] << 4 | digits[2];
+            radio_display_data[3] = 0xf0 | digits[0];
 
-       // DME distance (nm)
-       float nm = dme_nm->getFloatValue();
-       if ( nm > 99 ) {
-           nm = 99.0;
-       }
-       snprintf(digits, 7, "%04.1f", nm);
-       for ( i = 0; i < 6; ++i ) {
-           digits[i] -= '0';
-       }
-       radio_display_data[4] = digits[1] << 4 | digits[3];
-       radio_display_data[5] = 0x00 | digits[0];
-       // the 0x00 in the upper nibble of the 6th byte of each
-       // display turns on the decimal point
+            // DME distance (nm)
+            float nm = dme_nm->getFloatValue();
+            if ( nm > 99 ) {
+                nm = 99.0;
+            }
+            snprintf(digits, 7, "%04.1f", nm);
+            for ( i = 0; i < 6; ++i ) {
+                digits[i] -= '0';
+            }
+            radio_display_data[4] = digits[1] << 4 | digits[3];
+            radio_display_data[5] = 0x00 | digits[0];
+            // the 0x00 in the upper nibble of the 6th byte of each
+            // display turns on the decimal point
+        } else {
+            // out of range
+            radio_display_data[0] = 0xbb;
+            radio_display_data[1] = 0xfb;
+            radio_display_data[2] = 0xbb;
+            radio_display_data[3] = 0xfb;
+            radio_display_data[4] = 0xbb;
+            radio_display_data[5] = 0x0b;
+        }
     } else {
        // blank dem display
        for ( i = 0; i < 6; ++i ) {
@@ -1369,7 +1418,7 @@ bool FGATC610x::do_radio_display() {
        }
     }
 
-    if ( navcom1_has_power() && comm1_servicable->getBoolValue() ) {
+    if ( navcom1_has_power() && comm1_serviceable->getBoolValue() ) {
         // Com1 standby frequency
         float com1_stby = com1_stby_freq->getFloatValue();
         if ( fabs(com1_stby) > 999.99 ) {
@@ -1406,7 +1455,7 @@ bool FGATC610x::do_radio_display() {
         radio_display_data[11] = 0xff;
     }
 
-    if ( navcom2_has_power() && comm2_servicable->getBoolValue() ) {
+    if ( navcom2_has_power() && comm2_serviceable->getBoolValue() ) {
         // Com2 standby frequency
         float com2_stby = com2_stby_freq->getFloatValue();
         if ( fabs(com2_stby) > 999.99 ) {
@@ -1443,7 +1492,7 @@ bool FGATC610x::do_radio_display() {
         radio_display_data[23] = 0xff;
     }
 
-    if ( navcom1_has_power() && nav1_servicable->getBoolValue() ) {
+    if ( navcom1_has_power() && nav1_serviceable->getBoolValue() ) {
         // Nav1 standby frequency
         float nav1_stby = nav1_stby_freq->getFloatValue();
         if ( fabs(nav1_stby) > 999.99 ) {
@@ -1480,7 +1529,7 @@ bool FGATC610x::do_radio_display() {
         radio_display_data[17] = 0xff;
     }
 
-    if ( navcom2_has_power() && nav2_servicable->getBoolValue() ) {
+    if ( navcom2_has_power() && nav2_serviceable->getBoolValue() ) {
         // Nav2 standby frequency
         float nav2_stby = nav2_stby_freq->getFloatValue();
         if ( fabs(nav2_stby) > 999.99 ) {
@@ -1518,7 +1567,7 @@ bool FGATC610x::do_radio_display() {
     }
 
     // ADF standby frequency / timer
-    if ( adf_has_power() && adf_servicable->getBoolValue() ) {
+    if ( adf_has_power() && adf_serviceable->getBoolValue() ) {
         if ( adf_stby_mode->getIntValue() == 0 ) {
             // frequency
             float adf_stby = adf_stby_freq->getFloatValue();
@@ -1605,7 +1654,7 @@ bool FGATC610x::do_radio_display() {
     }
     
     // Transponder code and flight level
-    if ( xpdr_has_power() && xpdr_servicable->getBoolValue() ) {
+    if ( xpdr_has_power() && xpdr_serviceable->getBoolValue() ) {
         if ( xpdr_func_knob->getIntValue() == 2 ) {
             // test mode
             radio_display_data[36] = 8 << 4 | 8;
@@ -1718,50 +1767,53 @@ bool FGATC610x::do_switches() {
     update_switch_matrix( board, switch_data, switch_matrix );
 
     // master switches
-    fgSetBool( "/controls/switches/master-bat", switch_matrix[board][4][1] );
-    fgSetBool( "/controls/switches/master-alt", switch_matrix[board][5][1] );
+    fgSetBool( "/controls/switches/master-bat", switch_matrix[board][5][1] );
+    fgSetBool( "/controls/switches/master-alt", switch_matrix[board][4][1] );
     fgSetBool( "/controls/switches/master-avionics",
                switch_matrix[board][0][3] );
 
-    // magnetos and starter switch
-    int magnetos = 0;
-    bool starter = false;
-    if ( switch_matrix[board][3][1] == 1 ) {
-       magnetos = 3;
-       starter = true;
-    } else if ( switch_matrix[board][2][1] == 1 ) {
-       magnetos = 3;
-       starter = false;
-    } else if ( switch_matrix[board][1][1] == 1 ) {
-       magnetos = 2;
-       starter = false;
-    } else if ( switch_matrix[board][0][1] == 1 ) {
-       magnetos = 1;
-       starter = false;
-    } else {
-       magnetos = 0;
-       starter = false;
-    }
+    if ( !ignore_flight_controls->getBoolValue() ) {
+        // magnetos and starter switch
+        int magnetos = 0;
+        bool starter = false;
+        if ( switch_matrix[board][3][1] == 1 ) {
+            magnetos = 3;
+            starter = true;
+        } else if ( switch_matrix[board][2][1] == 1 ) {
+            magnetos = 3;
+            starter = false;
+        } else if ( switch_matrix[board][1][1] == 1 ) {
+            magnetos = 2;
+            starter = false;
+        } else if ( switch_matrix[board][0][1] == 1 ) {
+            magnetos = 1;
+            starter = false;
+        } else {
+            magnetos = 0;
+            starter = false;
+        }
 
-    // do a bit of filtering on the magneto/starter switch and the
-    // flap lever because these are not well debounced in hardware
-    static int mag1, mag2, mag3;
-    mag3 = mag2;
-    mag2 = mag1;
-    mag1 = magnetos;
-    if ( mag1 == mag2 && mag2 == mag3 ) {
-        fgSetInt( "/controls/magnetos[0]", magnetos );
-    }
-    static bool start1, start2, start3;
-    start3 = start2;
-    start2 = start1;
-    start1 = starter;
-    if ( start1 == start2 && start2 == start3 ) {
-        fgSetBool( "/controls/starter[0]", starter );
+        // do a bit of filtering on the magneto/starter switch and the
+        // flap lever because these are not well debounced in hardware
+        static int mag1, mag2, mag3;
+        mag3 = mag2;
+        mag2 = mag1;
+        mag1 = magnetos;
+        if ( mag1 == mag2 && mag2 == mag3 ) {
+            fgSetInt( "/controls/engines/engine[0]/magnetos", magnetos );
+        }
+        static bool start1, start2, start3;
+        start3 = start2;
+        start2 = start1;
+        start1 = starter;
+        if ( start1 == start2 && start2 == start3 ) {
+            fgSetBool( "/controls/engines/engine[0]/starter", starter );
+        }
     }
 
     // other toggle switches
-    fgSetBool( "/controls/fuel-pump[0]", switch_matrix[board][0][2] );
+    fgSetBool( "/controls/engines/engine[0]/fuel-pump",
+               switch_matrix[board][0][2] );
     fgSetBool( "/controls/switches/flashing-beacon",
                switch_matrix[board][1][2] );
     fgSetBool( "/controls/switches/landing-light", switch_matrix[board][2][2] );
@@ -1772,25 +1824,27 @@ bool FGATC610x::do_switches() {
     fgSetBool( "/controls/switches/pitot-heat", switch_matrix[board][6][2] );
 
     // flaps
-    float flaps = 0.0;
-    if ( switch_matrix[board][6][3] ) {
-       flaps = 1.0;
-    } else if ( switch_matrix[board][5][3] ) {
-       flaps = 2.0 / 3.0;
-    } else if ( switch_matrix[board][4][3] ) {
-       flaps = 1.0 / 3.0;
-    } else if ( !switch_matrix[board][4][3] ) {
-       flaps = 0.0;
-    }
+    if ( !ignore_flight_controls->getBoolValue() ) {
+        float flaps = 0.0;
+        if ( switch_matrix[board][6][3] ) {
+            flaps = 1.0;
+        } else if ( switch_matrix[board][5][3] ) {
+            flaps = 2.0 / 3.0;
+        } else if ( switch_matrix[board][4][3] ) {
+            flaps = 1.0 / 3.0;
+        } else if ( !switch_matrix[board][4][3] ) {
+            flaps = 0.0;
+        }
 
-    // do a bit of filtering on the magneto/starter switch and the
-    // flap lever because these are not well debounced in hardware
-    static float flap1, flap2, flap3;
-    flap3 = flap2;
-    flap2 = flap1;
-    flap1 = flaps;
-    if ( flap1 == flap2 && flap2 == flap3 ) {
-        fgSetFloat( "/controls/flaps", flaps );
+        // do a bit of filtering on the magneto/starter switch and the
+        // flap lever because these are not well debounced in hardware
+        static float flap1, flap2, flap3;
+        flap3 = flap2;
+        flap2 = flap1;
+        flap1 = flaps;
+        if ( flap1 == flap2 && flap2 == flap3 ) {
+            fgSetFloat( "/controls/flight/flaps", flaps );
+        }
     }
 
     // fuel selector (also filtered)
@@ -1814,8 +1868,8 @@ bool FGATC610x::do_switches() {
     fuel2 = fuel1;
     fuel1 = fuel;
     if ( fuel1 == fuel2 && fuel2 == fuel3 ) {
-        fgSetBool( "/controls/fuel-selector[0]", (fuel & 0x01) > 0 );
-        fgSetBool( "/controls/fuel-selector[1]", (fuel & 0x02) > 0 );
+        fgSetBool( "/controls/fuel/tank[0]/fuel_selector", (fuel & 0x01) > 0 );
+        fgSetBool( "/controls/fuel/tank[1]/fuel_selector", (fuel & 0x02) > 0 );
     }
 
     // circuit breakers
@@ -1847,8 +1901,11 @@ bool FGATC610x::do_switches() {
     fgSetBool( "/controls/circuit-breakers/annunciators", true );
 #endif
 
-    fgSetDouble( "/controls/parking-brake",
-                 switch_matrix[board][7][3] );
+    if ( !ignore_flight_controls->getBoolValue() ) {
+        fgSetDouble( "/controls/gear/brake-parking",
+                     switch_matrix[board][7][3] );
+    }
+
     fgSetDouble( "/radios/marker-beacon/power-btn",
                  switch_matrix[board][6][1] );