]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/atc610x.cxx
Updated adf property names.
[flightgear.git] / src / Network / atc610x.cxx
index 70e79cecdfc539b043406a71b8335942c02d9887..6e41ef7bc2a9b5d2448d46ec960253d14ecd9cc8 100644 (file)
@@ -396,14 +396,16 @@ bool FGATC610x::open() {
     nav2_stby_freq
        = fgGetNode( "/radios/nav[1]/frequencies/standby-mhz", true );
 
-    adf_on_off_vol = fgGetNode( "/radios/adf/on-off-volume", true );
-    adf_freq = fgGetNode( "/radios/adf/frequencies/selected-khz", true );
-    adf_stby_freq = fgGetNode( "/radios/adf/frequencies/standby-khz", true );
-    adf_stby_mode = fgGetNode( "/radios/adf/stby-mode", true );
-    adf_timer_mode = fgGetNode( "/radios/adf/timer-mode", true );
-    adf_count_mode = fgGetNode( "/radios/adf/count-mode", true );
-    adf_flight_timer = fgGetNode( "/radios/adf/flight-timer", true );
-    adf_elapsed_timer = fgGetNode( "/radios/adf/elapsed-timer", true );
+    adf_on_off_vol = fgGetNode( "/radios/kr-87/on-off-volume", true );
+    adf_adf_btn = fgGetNode( "/radios/kr-87/adf-btn", true );
+    adf_bfo_btn = fgGetNode( "/radios/kr-87/bfo-btn", true );
+    adf_freq = fgGetNode( "/radios/kr-87/frequencies/selected-khz", true );
+    adf_stby_freq = fgGetNode( "/radios/kr-87/frequencies/standby-khz", true );
+    adf_stby_mode = fgGetNode( "/radios/kr-87/stby-mode", true );
+    adf_timer_mode = fgGetNode( "/radios/kr-87/timer-mode", true );
+    adf_count_mode = fgGetNode( "/radios/kr-87/count-mode", true );
+    adf_flight_timer = fgGetNode( "/radios/kr-87/flight-timer", true );
+    adf_elapsed_timer = fgGetNode( "/radios/kr-87/elapsed-timer", true );
 
     inner = fgGetNode( "/radios/marker-beacon/inner", true );
     middle = fgGetNode( "/radios/marker-beacon/middle", true );
@@ -470,7 +472,7 @@ bool FGATC610x::do_analog_in() {
 
     // adf volume
     tmp = (float)analog_in_data[26] / 1024.0f;
-    fgSetFloat( "/radios/adf/on-off-volume", tmp );
+    fgSetFloat( "/radios/kr-87/on-off-volume", tmp );
 
     // nav2 obs tuner
     tmp = (float)analog_in_data[29] * 360.0f / 1024.0f;
@@ -489,12 +491,46 @@ bool FGATC610x::do_analog_in() {
 // Write the lights
 /////////////////////////////////////////////////////////////////////
 
-bool FGATC610x::do_lights() {
+bool FGATC610x::do_lights( double dt ) {
 
+    // Marker beacons
     ATC610xSetLamp( lamps_fd, 4, inner->getBoolValue() );
     ATC610xSetLamp( lamps_fd, 5, middle->getBoolValue() );
     ATC610xSetLamp( lamps_fd, 3, outer->getBoolValue() );
 
+    // ADF annunciators
+    if ( adf_on_off_vol->getDoubleValue() >= 0.01 ) {
+        ATC610xSetLamp( lamps_fd, 11, !adf_adf_btn->getBoolValue() ); // ANT
+        ATC610xSetLamp( lamps_fd, 12, adf_adf_btn->getBoolValue() ); // ADF
+        ATC610xSetLamp( lamps_fd, 13, adf_bfo_btn->getBoolValue() ); // BFO
+        ATC610xSetLamp( lamps_fd, 14, !adf_stby_mode->getBoolValue() ); // FRQ
+        ATC610xSetLamp( lamps_fd, 15, adf_stby_mode->getBoolValue() &&
+                        !adf_timer_mode->getBoolValue() ); // FLT
+
+        // ET needs to blink when we are in ET set countdown time
+        if ( adf_count_mode->getIntValue() < 2 ) {
+            ATC610xSetLamp( lamps_fd, 16, adf_stby_mode->getBoolValue() &&
+                            adf_timer_mode->getBoolValue() ); // ET
+        } else {
+            et_flash_time += dt;
+            if ( et_flash && et_flash_time > 0.5 ) {
+                et_flash = false;
+                et_flash_time -= 0.5;
+            } else if ( !et_flash && et_flash_time > 0.2 ) {
+                et_flash = true;
+                et_flash_time -= 0.2;
+            }
+            ATC610xSetLamp( lamps_fd, 16, et_flash ); // ET
+        }
+    } else {
+        ATC610xSetLamp( lamps_fd, 11, false ); // ANT
+        ATC610xSetLamp( lamps_fd, 12, false ); // ADF
+        ATC610xSetLamp( lamps_fd, 13, false ); // BFO
+        ATC610xSetLamp( lamps_fd, 14, false ); // FRQ
+        ATC610xSetLamp( lamps_fd, 15, false ); // FLT
+        ATC610xSetLamp( lamps_fd, 16, false ); // ET
+    }
+
     return true;
 }
 
@@ -829,21 +865,21 @@ bool FGATC610x::do_radio_switches() {
     last_adf_tuner_coarse = adf_tuner_coarse;
 
     if ( adf_count_mode->getIntValue() == 2 ) {
-        fgSetFloat( "/radios/adf/elapsed-timer", value );
+        fgSetFloat( "/radios/kr-87/elapsed-timer", value );
     } else {
         if ( adf_stby_mode->getIntValue() == 1 ) {
-            fgSetFloat( "/radios/adf/frequencies/selected-khz", value );
+            fgSetFloat( "/radios/kr-87/frequencies/selected-khz", value );
         } else {
-            fgSetFloat( "/radios/adf/frequencies/standby-khz", value );
+            fgSetFloat( "/radios/kr-87/frequencies/standby-khz", value );
         }
     }
 
     // ADF Modes 
-    fgSetInt( "/radios/adf/adf-btn", !(radio_switch_data[23] & 0x01) );
-    fgSetInt( "/radios/adf/bfo-btn", !(radio_switch_data[23] >> 1 & 0x01) );
-    fgSetInt( "/radios/adf/frq-btn", !(radio_switch_data[23] >> 2 & 0x01) );
-    fgSetInt( "/radios/adf/flt-et-btn", !(radio_switch_data[23] >> 3 & 0x01) );
-    fgSetInt( "/radios/adf/set-rst-btn", !(radio_switch_data[23] >> 4 & 0x01) );
+    fgSetInt( "/radios/kr-87/adf-btn", !(radio_switch_data[23] & 0x01) );
+    fgSetInt( "/radios/kr-87/bfo-btn", !(radio_switch_data[23] >> 1 & 0x01) );
+    fgSetInt( "/radios/kr-87/frq-btn", !(radio_switch_data[23] >> 2 & 0x01) );
+    fgSetInt( "/radios/kr-87/flt-et-btn", !(radio_switch_data[23] >> 3 & 0x01) );
+    fgSetInt( "/radios/kr-87/set-rst-btn", !(radio_switch_data[23] >> 4 & 0x01) );
     /* cout << "adf = " << !(radio_switch_data[23] & 0x01)
          << " bfo = " << !(radio_switch_data[23] >> 1 & 0x01)
          << " stby = " << !(radio_switch_data[23] >> 2 & 0x01)
@@ -1232,12 +1268,17 @@ bool FGATC610x::do_switches() {
 
 
 bool FGATC610x::process() {
+    SGTimeStamp current;
+    current.stamp();
+
+    double dt = (double)(current - last_time_stamp) / 1000000;
+    last_time_stamp.stamp();
 
     // Lock the hardware, skip if it's not ready yet
     if ( ATC610xLock( lock_fd ) > 0 ) {
 
        do_analog_in();
-       do_lights();
+       do_lights( dt );
        do_radio_switches();
        do_radio_display();
        do_steppers();