1 // altimeter.cxx - an altimeter tied to the static port.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
6 #include <simgear/math/interpolater.hxx>
8 #include "altimeter.hxx"
9 #include <Main/fg_props.hxx>
10 #include <Main/util.hxx>
13 // Altitude based on pressure difference from sea level.
14 // pressure difference inHG, altitude ft
15 static double altitude_data[][2] = {
39 { 29.62, 100000.00 }, // just to fill it in
44 Altimeter::Altimeter ()
45 : _altitude_table(new SGInterpTable)
48 for (int i = 0; altitude_data[i][0] != -1; i++)
49 _altitude_table->addEntry(altitude_data[i][0], altitude_data[i][1]);
52 Altimeter::~Altimeter ()
54 delete _altitude_table;
61 fgGetNode("/instrumentation/altimeter/serviceable", true);
63 fgGetNode("/instrumentation/altimeter/setting-inhg", true);
65 fgGetNode("/systems/static/pressure-inhg", true);
67 fgGetNode("/instrumentation/altimeter/indicated-altitude-ft", true);
71 Altimeter::update (double dt)
73 if (_serviceable_node->getBoolValue()) {
74 double pressure = _pressure_node->getDoubleValue();
75 double setting = _setting_node->getDoubleValue();
77 fgGetLowPass(_altitude_node->getDoubleValue(),
78 _altitude_table->interpolate(setting - pressure),
80 _altitude_node->setDoubleValue(altitude);
84 // end of altimeter.cxx