4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "Units/Units.hpp"
25 #include "Units/Descriptor.hpp"
26 #include "Atmosphere/Pressure.hpp"
28 UnitSetting
Units::current
= {
31 Unit::DEGREES_CELCIUS
,
32 Unit::KILOMETER_PER_HOUR
,
33 Unit::METER_PER_SECOND
,
34 Unit::KILOMETER_PER_HOUR
,
35 Unit::KILOMETER_PER_HOUR
,
40 Units::SetConfig(const UnitSetting
&new_config
)
46 Units::GetUserDistanceUnit()
48 return current
.distance_unit
;
52 Units::GetUserAltitudeUnit()
54 return current
.altitude_unit
;
58 Units::GetUserTemperatureUnit()
60 return current
.temperature_unit
;
64 Units::GetUserSpeedUnit()
66 return current
.speed_unit
;
70 Units::GetUserTaskSpeedUnit()
72 return current
.task_speed_unit
;
76 Units::GetUserVerticalSpeedUnit()
78 return current
.vertical_speed_unit
;
82 Units::GetUserWindSpeedUnit()
84 return current
.wind_speed_unit
;
88 Units::GetUserPressureUnit()
90 return current
.pressure_unit
;
94 Units::GetUserUnitByGroup(UnitGroup group
)
96 return current
.GetByGroup(group
);
100 Units::GetSpeedName()
102 return GetUnitName(GetUserSpeedUnit());
106 Units::GetVerticalSpeedName()
108 return GetUnitName(GetUserVerticalSpeedUnit());
112 Units::GetWindSpeedName()
114 return GetUnitName(GetUserWindSpeedUnit());
118 Units::GetDistanceName()
120 return GetUnitName(GetUserDistanceUnit());
124 Units::GetAltitudeName()
126 return GetUnitName(GetUserAltitudeUnit());
130 Units::GetTemperatureName()
132 return GetUnitName(GetUserTemperatureUnit());
136 Units::GetTaskSpeedName()
138 return GetUnitName(GetUserTaskSpeedUnit());
142 Units::GetPressureName()
144 return GetUnitName(GetUserPressureUnit());
148 Units::ToUserPressure(AtmosphericPressure value
)
150 return ToUserPressure(value
.GetHectoPascal());
154 Units::FromUserPressure(fixed value
)
156 return AtmosphericPressure::HectoPascal(ToSysPressure(value
));