1
0
Fork 0

Minor code cleanups.

This commit is contained in:
david 2003-02-12 18:35:04 +00:00
parent 1693a364e4
commit 0a6d2b7559
3 changed files with 25 additions and 9 deletions

View file

@ -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. // Written by David Megginson, started 2002.
// //
// This file is in the Public Domain and comes with no warranty. // This file is in the Public Domain and comes with no warranty.
@ -12,6 +12,10 @@
#include <Main/util.hxx> #include <Main/util.hxx>
// A higher number means more responsive.
#define RESPONSIVENESS 50.0
AirspeedIndicator::AirspeedIndicator () AirspeedIndicator::AirspeedIndicator ()
{ {
} }
@ -58,7 +62,12 @@ AirspeedIndicator::update (double dt)
// Now, reverse the equation // Now, reverse the equation
double v_fps = sqrt((2 * q) / SEA_LEVEL_DENSITY_SLUGFT3); 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));
} }
} }

View file

@ -10,6 +10,10 @@
#include <Main/util.hxx> #include <Main/util.hxx>
// A higher number means more responsive
#define RESPONSIVENESS 10.0
// Altitude based on pressure difference from sea level. // Altitude based on pressure difference from sea level.
// pressure difference inHG, altitude ft // pressure difference inHG, altitude ft
static double altitude_data[][2] = { static double altitude_data[][2] = {
@ -73,11 +77,14 @@ Altimeter::update (double dt)
if (_serviceable_node->getBoolValue()) { if (_serviceable_node->getBoolValue()) {
double pressure = _pressure_node->getDoubleValue(); double pressure = _pressure_node->getDoubleValue();
double setting = _setting_node->getDoubleValue(); double setting = _setting_node->getDoubleValue();
double altitude =
fgGetLowPass(_altitude_node->getDoubleValue(), // Move towards the current setting
_altitude_table->interpolate(setting - pressure), double last_altitude = _altitude_node->getDoubleValue();
dt * 10); double current_altitude =
_altitude_node->setDoubleValue(altitude); _altitude_table->interpolate(setting - pressure);
_altitude_node->setDoubleValue(fgGetLowPass(last_altitude,
current_altitude,
dt * RESPONSIVENESS));
} }
} }

View file

@ -9,8 +9,8 @@
// Use a bigger number to be more responsive, or a smaller number // Use a bigger number to be more responsive, or a smaller number
// to be more sluggish (the base time is 1.0). // to be more sluggish.
#define RESPONSIVENESS 0.25 #define RESPONSIVENESS 0.5
TurnIndicator::TurnIndicator () : TurnIndicator::TurnIndicator () :