From f025c65c60ba34c2fd91bc52f201463d992cf613 Mon Sep 17 00:00:00 2001 From: John Denker Date: Mon, 30 Nov 2009 03:19:17 -0700 Subject: [PATCH] Fix ADF bugs ... including still driving the needle when power off. ADF bug fixes from John Denker. Changes from current behaviour are: * Include the power button in the electrical checks * Raise the required input voltage from 1V to 8V * Don't reset the heading to 90 degrees when out of range or no power (heading is now only reset to 90 in ANT or TEST mode) --- src/Instrumentation/adf.cxx | 23 ++++++++++++++--------- src/Instrumentation/adf.hxx | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Instrumentation/adf.cxx b/src/Instrumentation/adf.cxx index 6da2a2ed4..41ee7700e 100644 --- a/src/Instrumentation/adf.cxx +++ b/src/Instrumentation/adf.cxx @@ -101,6 +101,10 @@ ADF::init () _bearing_node = node->getChild("indicated-bearing-deg", 0, true); _ident_node = node->getChild("ident", 0, true); _ident_audible_node = node->getChild("ident-audible", 0, true); + _power_btn_node = node->getChild("power-btn", 0, true); + + if (_power_btn_node->getType() == simgear::props::NONE) + _power_btn_node->setBoolValue(true); // front end didn't implement a power button SGSoundMgr *smgr = globals->get_soundmgr(); _sgr = smgr->find("avionics", true); @@ -117,13 +121,19 @@ void ADF::update (double delta_time_sec) { // If it's off, don't waste any time. - if (_electrical_node->getDoubleValue() < 1.0 - || !_serviceable_node->getBoolValue()) { - set_bearing(delta_time_sec, 90); + if (_electrical_node->getDoubleValue() < 8.0 + || !_serviceable_node->getBoolValue() + || !_power_btn_node->getBoolValue() ) { _ident_node->setStringValue(""); return; } + string mode = _mode_node->getStringValue(); + if (mode == "ant" || mode == "test") set_bearing(delta_time_sec, 90); + if (mode != "bfo" && mode != "adf") { + _ident_node->setStringValue(""); + return; + } // Get the frequency int frequency_khz = _frequency_node->getIntValue(); if (frequency_khz != _last_frequency_khz) { @@ -144,11 +154,7 @@ ADF::update (double delta_time_sec) if (_time_before_search_sec < 0) search(frequency_khz, longitude_rad, latitude_rad, altitude_m); - // If it's off, don't bother. - string mode = _mode_node->getStringValue(); - if (!_transmitter_valid || (mode != "bfo" && mode != "adf")) - { - set_bearing(delta_time_sec, 90); + if (!_transmitter_valid) { _ident_node->setStringValue(""); return; } @@ -208,7 +214,6 @@ ADF::update (double delta_time_sec) } } else { _in_range_node->setBoolValue(false); - set_bearing(delta_time_sec, 90); _ident_node->setStringValue(""); _sgr->stop( _adf_ident ); } diff --git a/src/Instrumentation/adf.hxx b/src/Instrumentation/adf.hxx index f2c2bdeb8..88817a8ee 100644 --- a/src/Instrumentation/adf.hxx +++ b/src/Instrumentation/adf.hxx @@ -82,6 +82,7 @@ private: SGPropertyNode_ptr _ident_node; SGPropertyNode_ptr _ident_audible_node; SGPropertyNode_ptr _volume_node; + SGPropertyNode_ptr _power_btn_node; double _time_before_search_sec; -- 2.39.5