]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/atc610x.cxx
Patches from Erik Hofman for SGI compatibility:
[flightgear.git] / src / Network / atc610x.cxx
index fd32059bd21a74279a18e6440a57251bf79ee88f..0711054a17fbd680c9454389c4be690780bc1fdc 100644 (file)
@@ -53,6 +53,7 @@
 
 SG_USING_STD(string);
 
+
 // Lock the ATC 610 hardware
 static int ATC610xLock( int fd ) {
     // rewind
@@ -323,6 +324,7 @@ bool FGATC610x::open() {
 
     bool home = false;
     int timeout = 900;          // about 30 seconds
+    timeout = 0;
     while ( ! home && timeout > 0 ) {
         if ( timeout % 150 == 0 ) {
             SG_LOG( SG_IO, SG_INFO, "waiting for compass = " << timeout );
@@ -421,10 +423,12 @@ bool FGATC610x::open() {
     nav1_freq = fgGetNode( "/radios/nav[0]/frequencies/selected-mhz", true );
     nav1_stby_freq
        = fgGetNode( "/radios/nav[0]/frequencies/standby-mhz", true );
+    nav1_obs = fgGetNode( "/radios/nav[0]/radials/selected-deg", true );
 
     nav2_freq = fgGetNode( "/radios/nav[1]/frequencies/selected-mhz", true );
     nav2_stby_freq
        = fgGetNode( "/radios/nav[1]/frequencies/standby-mhz", true );
+    nav2_obs = fgGetNode( "/radios/nav[1]/radials/selected-deg", true );
 
     adf_power_btn = fgGetNode( "/radios/kr-87/inputs/power-btn", true );
     adf_vol = fgGetNode( "/radios/kr-87/inputs/volume", true );
@@ -464,33 +468,51 @@ bool FGATC610x::open() {
     xpdr_sby_ann = fgGetNode( "/radios/kt-70/annunciators/sby", true );
     xpdr_reply_ann = fgGetNode( "/radios/kt-70/annunciators/reply", true );
 
-    elevator_center = fgGetNode( "/input/atc610x/elevator/center", 0 );
-    elevator_min = fgGetNode( "/input/atc610x/elevator/min", 0 );
-    elevator_max = fgGetNode( "/input/atc610x/elevator/max", 0 );
+    elevator_center = fgGetNode( "/input/atc610x/elevator/center", true );
+    elevator_min = fgGetNode( "/input/atc610x/elevator/min", true );
+    elevator_max = fgGetNode( "/input/atc610x/elevator/max", true );
+
+    ailerons_center = fgGetNode( "/input/atc610x/ailerons/center", true );
+    ailerons_min = fgGetNode( "/input/atc610x/ailerons/min", true );
+    ailerons_max = fgGetNode( "/input/atc610x/ailerons/max", true );
 
-    ailerons_center = fgGetNode( "/input/atc610x/ailerons/center", 0 );
-    ailerons_min = fgGetNode( "/input/atc610x/ailerons/min", 0 );
-    ailerons_max = fgGetNode( "/input/atc610x/ailerons/max", 0 );
+    rudder_center = fgGetNode( "/input/atc610x/rudder/center", true );
+    rudder_min = fgGetNode( "/input/atc610x/rudder/min", true );
+    rudder_max = fgGetNode( "/input/atc610x/rudder/max", true );
 
-    rudder_center = fgGetNode( "/input/atc610x/rudder/center", 0 );
-    rudder_min = fgGetNode( "/input/atc610x/rudder/min", 0 );
-    rudder_max = fgGetNode( "/input/atc610x/rudder/max", 0 );
+    throttle_min = fgGetNode( "/input/atc610x/throttle/min", true );
+    throttle_max = fgGetNode( "/input/atc610x/throttle/max", true );
 
-    throttle_min = fgGetNode( "/input/atc610x/throttle/min", 0 );
-    throttle_max = fgGetNode( "/input/atc610x/throttle/max", 0 );
+    mixture_min = fgGetNode( "/input/atc610x/mixture/min", true );
+    mixture_max = fgGetNode( "/input/atc610x/mixture/max", true );
 
-    mixture_min = fgGetNode( "/input/atc610x/mixture/min", 0 );
-    mixture_max = fgGetNode( "/input/atc610x/mixture/max", 0 );
+    trim_center = fgGetNode( "/input/atc610x/trim/center", true );
+    trim_min = fgGetNode( "/input/atc610x/trim/min", true );
+    trim_max = fgGetNode( "/input/atc610x/trim/max", true );
 
-    trim_center = fgGetNode( "/input/atc610x/trim/center", 0 );
-    trim_min = fgGetNode( "/input/atc610x/trim/min", 0 );
-    trim_max = fgGetNode( "/input/atc610x/trim/max", 0 );
+    nav1vol_min = fgGetNode( "/input/atc610x/nav1vol/min", true );
+    nav1vol_max = fgGetNode( "/input/atc610x/nav1vol/max", true );
 
-    nav1vol_min = fgGetNode( "/input/atc610x/nav1vol/min", 0 );
-    nav1vol_max = fgGetNode( "/input/atc610x/nav1vol/max", 0 );
+    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",
+                                 true );
+    dme_servicable = fgGetNode( "/instrumentation/dme/servicable", true );
 
-    nav2vol_min = fgGetNode( "/input/atc610x/nav2vol/min", 0 );
-    nav2vol_max = fgGetNode( "/input/atc610x/nav2vol/max", 0 );
+    // 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 );
 
     return true;
 }
@@ -500,11 +522,6 @@ bool FGATC610x::open() {
 // Read analog inputs
 /////////////////////////////////////////////////////////////////////
 
-#define ATC_AILERON_CENTER 535
-#define ATC_ELEVATOR_TRIM_CENTER 512
-#define ATC_ELEVATOR_CENTER 543
-#define ATC_RUDDER_CENTER 519
-
 // scale a number between min and max (with center defined) to a scale
 // from -1.0 to 1.0
 static double scale( int center, int min, int max, int value ) {
@@ -561,7 +578,7 @@ bool FGATC610x::do_analog_in() {
        // printf("%04d ", value );
     }
 
-    float tmp, tmp1, tmp2;
+    float tmp;
 
     // aileron
     tmp = scale( ailerons_center->getIntValue(), ailerons_min->getIntValue(),
@@ -583,22 +600,23 @@ bool FGATC610x::do_analog_in() {
 
     // mixture
     tmp = scale( mixture_min->getIntValue(), mixture_max->getIntValue(),
-                 analog_in_data[7] );
+                 analog_in_data[6] );
     fgSetFloat( "/controls/mixture[0]", tmp );
     fgSetFloat( "/controls/mixture[1]", tmp );
 
     // throttle
-    tmp = scale( mixture_min->getIntValue(), mixture_max->getIntValue(),
+    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;
 
-#if 0
     // rudder
+    /*
     tmp = scale( rudder_center->getIntValue(), rudder_min->getIntValue(),
                  rudder_max->getIntValue(), analog_in_data[10] );
-    fgSetFloat( "/controls/rudder", tmp );
-#endif
+    fgSetFloat( "/controls/rudder", -tmp );
+    */
 
     // nav1 volume
     tmp = (float)analog_in_data[25] / 1024.0f;
@@ -612,14 +630,173 @@ bool FGATC610x::do_analog_in() {
     tmp = (float)analog_in_data[26] / 1024.0f;
     fgSetFloat( "/radios/kr-87/inputs/volume", tmp );
 
-    // nav2 obs tuner
-    tmp = (float)analog_in_data[29] * 360.0f / 1024.0f;
-    fgSetFloat( "/radios/nav[1]/radials/selected-deg", tmp );
+#define FG_SECOND_TRY
 
     // nav1 obs tuner
-    tmp1 = (float)analog_in_data[30] * 360.0f / 1024.0f;
-    tmp2 = (float)analog_in_data[31] * 360.0f / 1024.0f;
-    fgSetFloat( "/radios/nav[0]/radials/selected-deg", tmp1 );
+    static int last_obs1 = analog_in_data[29];
+    static double diff1_ave = 0.0;
+    int diff1 = 0;
+
+#if defined( FG_FIRST_TRY )
+    if ( analog_in_data[29] < 150 || analog_in_data[29] > 990 ) {
+        if ( last_obs1 > 512 && last_obs1 <= 990 ) {
+            diff1 = 1;
+        } else if ( last_obs1 >= 150 && last_obs1 <= 990 ) {
+            diff1 = -1;
+        }
+    } else if ( last_obs1 < 150 || last_obs1 > 990 ) {
+        if ( analog_in_data[29] > 512 && analog_in_data[29] <= 990 ) {
+            diff1 = -1;
+        } else if ( analog_in_data[29] >= 150 && analog_in_data[29] <= 990 ) {
+            diff1 = 1;
+        }
+    } else {
+        diff1 = analog_in_data[29] - last_obs1;
+    }
+#elif defined( FG_SECOND_TRY )
+    if ( analog_in_data[29] < 20 ) {
+        if ( last_obs1 >= 110 && last_obs1 < 512 ) {
+            diff1 = -6;
+        } else if ( last_obs1 >= 512 ) {
+            diff1 = 6;
+        }
+        last_obs1 = analog_in_data[29];
+    } else if ( analog_in_data[29] < 110 ) {
+        // do nothing
+    } else if ( last_obs1 < 20 ) {
+        if ( analog_in_data[29] >= 110 && analog_in_data[29] < 512 ) {
+            diff1 = 6;
+        } else if ( analog_in_data[29] >= 512 ) {
+            diff1 = -6;
+        }
+        last_obs1 = analog_in_data[29];
+    } else {
+        diff1 = analog_in_data[29] - last_obs1;
+        if ( abs(diff1) > 200 ) {
+            // ignore
+            diff1 = 0;
+        }
+        last_obs1 = analog_in_data[29];
+    }
+#elif defined( FG_FOURTH_TRY )
+    static bool ignore_next = false;
+    diff1 = analog_in_data[29] - last_obs1;
+    if ( abs(diff1) > 200 ) {
+        // ignore
+        diff1 = 0;
+        ignore_next = true;
+    } else if ( ignore_next ) {
+        diff1 = 0;
+        ignore_next = false;
+    }
+    last_obs1 = analog_in_data[29];
+#endif
+
+    // cout << " diff1 = " << diff1 << endl;
+    if ( diff1 < -500 ) { diff1 += 1024; }
+    if ( diff1 > 500 ) { diff1 -= 1024; }
+
+    if ( fabs(diff1_ave - diff1) < 200 || fabs(diff1) < fabs(diff1_ave) ) {
+        diff1_ave = (2.0/3.0) * diff1_ave + (1.0/3.0) * diff1;
+    }
+
+    tmp = nav1_obs->getDoubleValue() + (diff1_ave * (72.0/914.0) );
+    while ( tmp >= 360.0 ) { tmp -= 360.0; }
+    while ( tmp < 0.0 ) { tmp += 360.0; }
+
+    fgSetFloat( "/radios/nav[0]/radials/selected-deg", tmp );
+
+    // nav2 obs tuner
+    static int last_obs2 = analog_in_data[30];
+    static double diff2_ave = 0.0;
+    int diff2 = 0;
+
+    // cout << "obs2 = " << analog_in_data[30] << " last obs2 = " << last_obs2;
+
+#if defined( FG_FIRST_TRY )
+    if ( analog_in_data[30] < 150 || analog_in_data[30] > 990 ) {
+        if ( last_obs2 > 512 && last_obs2 <= 990 ) {
+            diff2 = 1;
+        } else if ( last_obs2 >= 150 && last_obs2 <= 990 ) {
+            diff2 = -1;
+        }
+    } else if ( last_obs2 < 150 || last_obs2 > 990 ) {
+        if ( analog_in_data[30] > 512 && analog_in_data[30] <= 990 ) {
+            diff2 = -1;
+        } else if ( analog_in_data[30] >= 150 && analog_in_data[30] <= 990 ) {
+            diff2 = 1;
+        }
+    } else {
+        diff2 = analog_in_data[30] - last_obs2;
+    }
+#elif defined( FG_SECOND_TRY )
+    if ( analog_in_data[30] < 30 ) {
+        if ( last_obs2 >= 43 && last_obs2 < 480 ) {
+            diff2 = -6;
+        } else if ( last_obs2 >= 480 ) {
+            diff2 = 6;
+        }
+        last_obs2 = analog_in_data[30];
+    } else if ( analog_in_data[30] < 43 ) {
+        // do nothing
+    } else if ( last_obs2 < 30 ) {
+        if ( analog_in_data[30] >= 23 && analog_in_data[30] < 480 ) {
+            diff2 = 6;
+        } else if ( analog_in_data[30] >= 480 ) {
+            diff2 = -6;
+        }
+        last_obs2 = analog_in_data[30];
+    } else if ( analog_in_data[30] > 930 ) {
+        if ( last_obs2 <= 924 && last_obs2 > 480 ) {
+            diff2 = 6;
+        } else if ( last_obs2 <= 480 ) {
+            diff2 = -6;
+        }
+        last_obs2 = analog_in_data[30];
+    } else if ( analog_in_data[30] > 924 ) {
+        // do nothing
+    } else if ( last_obs2 > 930 ) {
+        if ( analog_in_data[30] <= 924 && analog_in_data[30] > 480 ) {
+            diff2 = -6;
+        } else if ( analog_in_data[30] <= 480 ) {
+            diff2 = 6;
+        }
+        last_obs2 = analog_in_data[30];
+    } else {
+        diff2 = analog_in_data[30] - last_obs2;
+        if ( abs(diff2) > 200 ) {
+            // ignore
+            diff2 = 0;
+        }
+        last_obs2 = analog_in_data[30];
+    }
+#elif defined( FG_FOURTH_TRY )
+    static bool ignore_next = false;
+    diff2 = analog_in_data[30] - last_obs2;
+    if ( abs(diff2) > 200 ) {
+        // ignore
+        diff2 = 0;
+        ignore_next = true;
+    } else if ( ignore_next ) {
+        diff2 = 0;
+        ignore_next = false;
+    }
+    last_obs2 = analog_in_data[30];
+#endif
+
+    // cout << " diff2 = " << diff2 << endl;
+    if ( diff2 < -500 ) { diff2 += 1024; }
+    if ( diff2 > 500 ) { diff2 -= 1024; }
+
+    if ( fabs(diff2_ave - diff2) < 200 || fabs(diff2) < fabs(diff2_ave) ) {
+        diff2_ave = (2.0/3.0) * diff2_ave + (1.0/3.0) * diff2;
+    }
+
+    tmp = nav2_obs->getDoubleValue() + (diff2_ave * (72.0/880.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 );
 
     return true;
 }
@@ -683,7 +860,7 @@ bool FGATC610x::do_radio_switches() {
     fgSetBool( "/radios/comm[0]/inputs/power-btn",
                radio_switch_data[7] & 0x01 );
 
-    if ( navcom1_has_power() ) {
+    if ( navcom1_has_power() && comm1_servicable->getBoolValue() ) {
         // Com1 Swap
         int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
         static int last_com1_swap;
@@ -700,7 +877,7 @@ bool FGATC610x::do_radio_switches() {
     fgSetBool( "/radios/comm[1]/inputs/power-btn",
                radio_switch_data[15] & 0x01 );
 
-    if ( navcom2_has_power() ) {
+    if ( navcom2_has_power() && comm2_servicable->getBoolValue() ) {
         // Com2 Swap
         int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
         static int last_com2_swap;
@@ -713,7 +890,7 @@ bool FGATC610x::do_radio_switches() {
         last_com2_swap = com2_swap;
     }
 
-    if ( navcom1_has_power() ) {
+    if ( navcom1_has_power() && nav1_servicable->getBoolValue() ) {
         // Nav1 Swap
         int nav1_swap = radio_switch_data[11] & 0x01;
         static int last_nav1_swap;
@@ -726,7 +903,7 @@ bool FGATC610x::do_radio_switches() {
         last_nav1_swap = nav1_swap;
     }
 
-    if ( navcom2_has_power() ) {
+    if ( navcom2_has_power() && nav2_servicable->getBoolValue() ) {
         // Nav2 Swap
         int nav2_swap = !(radio_switch_data[19] & 0x01);
         static int last_nav2_swap;
@@ -739,7 +916,7 @@ bool FGATC610x::do_radio_switches() {
         last_nav2_swap = nav2_swap;
     }
 
-    if ( navcom1_has_power() ) {
+    if ( navcom1_has_power() && comm1_servicable->getBoolValue() ) {
         // Com1 Tuner
         int com1_tuner_fine = ((radio_switch_data[5] >> 4) & 0x0f) - 1;
         int com1_tuner_coarse = (radio_switch_data[5] & 0x0f) - 1;
@@ -791,7 +968,7 @@ bool FGATC610x::do_radio_switches() {
                     coarse_freq + fine_freq / 40.0 );
     }
 
-    if ( navcom2_has_power() ) {
+    if ( navcom2_has_power() && comm2_servicable->getBoolValue() ) {
         // Com2 Tuner
         int com2_tuner_fine = ((radio_switch_data[13] >> 4) & 0x0f) - 1;
         int com2_tuner_coarse = (radio_switch_data[13] & 0x0f) - 1;
@@ -843,7 +1020,7 @@ bool FGATC610x::do_radio_switches() {
                     coarse_freq + fine_freq / 40.0 );
     }
 
-    if ( navcom1_has_power() ) {
+    if ( navcom1_has_power() && nav1_servicable->getBoolValue() ) {
         // Nav1 Tuner
         int nav1_tuner_fine = ((radio_switch_data[9] >> 4) & 0x0f) - 1;
         int nav1_tuner_coarse = (radio_switch_data[9] & 0x0f) - 1;
@@ -895,7 +1072,7 @@ bool FGATC610x::do_radio_switches() {
                     coarse_freq + fine_freq / 20.0 );
     }
 
-    if ( navcom2_has_power() ) {
+    if ( navcom2_has_power() && nav2_servicable->getBoolValue() ) {
         // Nav2 Tuner
         int nav2_tuner_fine = ((radio_switch_data[17] >> 4) & 0x0f) - 1;
         int nav2_tuner_coarse = (radio_switch_data[17] & 0x0f) - 1;
@@ -954,7 +1131,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() ) {
+    if ( adf_has_power() && adf_servicable->getBoolValue() ) {
         // cout << "adf_stby_mode = " << adf_stby_mode->getIntValue() << endl;
         if ( adf_count_mode->getIntValue() == 2 ) {
             // tune count down timer
@@ -1029,17 +1206,17 @@ bool FGATC610x::do_radio_switches() {
     fgSetInt( "/radios/kr-87/inputs/bfo-btn",
               !(radio_switch_data[23] >> 1 & 0x01) );
     fgSetInt( "/radios/kr-87/inputs/frq-btn",
-              (radio_switch_data[23] >> 2 & 0x01) );
+              !(radio_switch_data[23] >> 2 & 0x01) );
     fgSetInt( "/radios/kr-87/inputs/flt-et-btn",
-                  !(radio_switch_data[23] >> 3 & 0x01) );
+              !(radio_switch_data[23] >> 3 & 0x01) );
     fgSetInt( "/radios/kr-87/inputs/set-rst-btn",
               !(radio_switch_data[23] >> 4 & 0x01) );
     fgSetInt( "/radios/kr-87/inputs/power-btn",
               radio_switch_data[23] >> 5 & 0x01 );
     /* cout << "adf = " << !(radio_switch_data[23] & 0x01)
          << " bfo = " << !(radio_switch_data[23] >> 1 & 0x01)
-         << " stby = " << !(radio_switch_data[23] >> 2 & 0x01)
-         << " timer = " << !(radio_switch_data[23] >> 3 & 0x01)
+         << " frq = " << !(radio_switch_data[23] >> 2 & 0x01)
+         << " flt/et = " << !(radio_switch_data[23] >> 3 & 0x01)
          << " set/rst = " << !(radio_switch_data[23] >> 4 & 0x01)
          << endl; */
 
@@ -1060,7 +1237,7 @@ bool FGATC610x::do_radio_switches() {
         }
     }
 
-    if ( xpdr_has_power() ) {
+    if ( xpdr_has_power() && xpdr_servicable->getBoolValue() ) {
         int id_code = xpdr_id_code->getIntValue();
         int digit[4];
         int place = 1000;
@@ -1108,6 +1285,16 @@ bool FGATC610x::do_radio_switches() {
     fgSetInt( "/radios/kt-70/inputs/ident-btn",
               !(radio_switch_data[27] >> 5 & 0x01) );
 
+    // Audio panel switches
+    fgSetInt( "/radios/nav[0]/audio-btn",
+              (radio_switch_data[3] & 0x01) );
+    fgSetInt( "/radios/nav[1]/audio-btn",
+              (radio_switch_data[3] >> 2 & 0x01) );
+    fgSetInt( "/radios/kr-87/inputs/audio-btn",
+              (radio_switch_data[3] >> 4 & 0x01) );
+    fgSetInt( "/radios/marker-beacon/audio-btn",
+              (radio_switch_data[3] >> 6 & 0x01) );
+
     return true;
 }
 
@@ -1121,7 +1308,7 @@ bool FGATC610x::do_radio_display() {
     char digits[10];
     int i;
 
-    if ( dme_has_power() ) {
+    if ( dme_has_power() && dme_servicable->getBoolValue() ) {
        // DME minutes
        float minutes = dme_min->getFloatValue();
        if ( minutes > 999 ) {
@@ -1166,7 +1353,7 @@ bool FGATC610x::do_radio_display() {
        }
     }
 
-    if ( navcom1_has_power() ) {
+    if ( navcom1_has_power() && comm1_servicable->getBoolValue() ) {
         // Com1 standby frequency
         float com1_stby = com1_stby_freq->getFloatValue();
         if ( fabs(com1_stby) > 999.99 ) {
@@ -1203,7 +1390,7 @@ bool FGATC610x::do_radio_display() {
         radio_display_data[11] = 0xff;
     }
 
-    if ( navcom2_has_power() ) {
+    if ( navcom2_has_power() && comm2_servicable->getBoolValue() ) {
         // Com2 standby frequency
         float com2_stby = com2_stby_freq->getFloatValue();
         if ( fabs(com2_stby) > 999.99 ) {
@@ -1240,7 +1427,7 @@ bool FGATC610x::do_radio_display() {
         radio_display_data[23] = 0xff;
     }
 
-    if ( navcom1_has_power() ) {
+    if ( navcom1_has_power() && nav1_servicable->getBoolValue() ) {
         // Nav1 standby frequency
         float nav1_stby = nav1_stby_freq->getFloatValue();
         if ( fabs(nav1_stby) > 999.99 ) {
@@ -1277,7 +1464,7 @@ bool FGATC610x::do_radio_display() {
         radio_display_data[17] = 0xff;
     }
 
-    if ( navcom2_has_power() ) {
+    if ( navcom2_has_power() && nav2_servicable->getBoolValue() ) {
         // Nav2 standby frequency
         float nav2_stby = nav2_stby_freq->getFloatValue();
         if ( fabs(nav2_stby) > 999.99 ) {
@@ -1315,7 +1502,7 @@ bool FGATC610x::do_radio_display() {
     }
 
     // ADF standby frequency / timer
-    if ( adf_has_power() ) {
+    if ( adf_has_power() && adf_servicable->getBoolValue() ) {
         if ( adf_stby_mode->getIntValue() == 0 ) {
             // frequency
             float adf_stby = adf_stby_freq->getFloatValue();
@@ -1367,9 +1554,9 @@ bool FGATC610x::do_radio_display() {
             for ( i = 0; i < 6; ++i ) {
                 digits[i] -= '0';
             }
-            radio_display_data[30] = digits[3] << 4 | 0x0f;
-            radio_display_data[31] = digits[1] << 4 | digits[2];
-            radio_display_data[32] = 0xf0 | digits[0];
+            radio_display_data[30] = digits[2] << 4 | digits[3];
+            radio_display_data[31] = digits[0] << 4 | digits[1];
+            radio_display_data[32] = 0xff;
         }
 
         // ADF in use frequency
@@ -1387,16 +1574,22 @@ bool FGATC610x::do_radio_display() {
         } else {
             radio_display_data[34] = digits[0] << 4 | digits[1];
         }
+        if ( adf_stby_mode->getIntValue() == 0 ) {
+         radio_display_data[35] = 0xff;
+       } else {
+         radio_display_data[35] = 0x0f;
+       }
     } else {
         radio_display_data[30] = 0xff;
         radio_display_data[31] = 0xff;
         radio_display_data[32] = 0xff;
         radio_display_data[33] = 0xff;
         radio_display_data[34] = 0xff;
+        radio_display_data[35] = 0xff;
     }
     
     // Transponder code and flight level
-    if ( xpdr_has_power() ) {
+    if ( xpdr_has_power() && xpdr_servicable->getBoolValue() ) {
         if ( xpdr_func_knob->getIntValue() == 2 ) {
             // test mode
             radio_display_data[36] = 8 << 4 | 8;
@@ -1627,6 +1820,11 @@ bool FGATC610x::do_switches() {
     fgSetBool( "/controls/circuit-breakers/annunciators",
                switch_matrix[board][7][0] );
 
+    fgSetDouble( "/controls/parking-brake",
+                 switch_matrix[board][7][3] );
+    fgSetDouble( "/radios/marker-beacon/power-btn",
+                 switch_matrix[board][6][1] );
+
     return true;
 }