From 0a6d2b75591fa02fb38457b583790fb8c4fa22a2 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 12 Feb 2003 18:35:04 +0000 Subject: [PATCH] Minor code cleanups. --- src/Instrumentation/airspeed_indicator.cxx | 13 +++++++++++-- src/Instrumentation/altimeter.cxx | 17 ++++++++++++----- src/Instrumentation/turn_indicator.cxx | 4 ++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/Instrumentation/airspeed_indicator.cxx b/src/Instrumentation/airspeed_indicator.cxx index bc83602de..46eb585c8 100644 --- a/src/Instrumentation/airspeed_indicator.cxx +++ b/src/Instrumentation/airspeed_indicator.cxx @@ -1,4 +1,4 @@ -// airspeed_indicator.cxx - a regular VSI. +// airspeed_indicator.cxx - a regular pitot-static airspeed indicator. // Written by David Megginson, started 2002. // // This file is in the Public Domain and comes with no warranty. @@ -12,6 +12,10 @@ #include
+// A higher number means more responsive. +#define RESPONSIVENESS 50.0 + + AirspeedIndicator::AirspeedIndicator () { } @@ -58,7 +62,12 @@ AirspeedIndicator::update (double dt) // Now, reverse the equation double v_fps = sqrt((2 * q) / SEA_LEVEL_DENSITY_SLUGFT3); - _speed_node->setDoubleValue(v_fps * FPSTOKTS); + // Publish the indicated airspeed + double last_speed_kt = _speed_node->getDoubleValue(); + double current_speed_kt = v_fps * FPSTOKTS; + _speed_node->setDoubleValue(fgGetLowPass(last_speed_kt, + current_speed_kt, + dt * RESPONSIVENESS)); } } diff --git a/src/Instrumentation/altimeter.cxx b/src/Instrumentation/altimeter.cxx index 993672e6f..2a9578705 100644 --- a/src/Instrumentation/altimeter.cxx +++ b/src/Instrumentation/altimeter.cxx @@ -10,6 +10,10 @@ #include
+// A higher number means more responsive +#define RESPONSIVENESS 10.0 + + // Altitude based on pressure difference from sea level. // pressure difference inHG, altitude ft static double altitude_data[][2] = { @@ -73,11 +77,14 @@ Altimeter::update (double dt) if (_serviceable_node->getBoolValue()) { double pressure = _pressure_node->getDoubleValue(); double setting = _setting_node->getDoubleValue(); - double altitude = - fgGetLowPass(_altitude_node->getDoubleValue(), - _altitude_table->interpolate(setting - pressure), - dt * 10); - _altitude_node->setDoubleValue(altitude); + + // Move towards the current setting + double last_altitude = _altitude_node->getDoubleValue(); + double current_altitude = + _altitude_table->interpolate(setting - pressure); + _altitude_node->setDoubleValue(fgGetLowPass(last_altitude, + current_altitude, + dt * RESPONSIVENESS)); } } diff --git a/src/Instrumentation/turn_indicator.cxx b/src/Instrumentation/turn_indicator.cxx index 6d4faedaa..1edb0bb4d 100644 --- a/src/Instrumentation/turn_indicator.cxx +++ b/src/Instrumentation/turn_indicator.cxx @@ -9,8 +9,8 @@ // Use a bigger number to be more responsive, or a smaller number -// to be more sluggish (the base time is 1.0). -#define RESPONSIVENESS 0.25 +// to be more sluggish. +#define RESPONSIVENESS 0.5 TurnIndicator::TurnIndicator () : -- 2.39.5