android/GlueIOIOPort: fix spurious errors after IOIO baud rate change
[xcsoar.git] / src / Units / Units.cpp
blob5aed9d0b959dcc84873758ef3d3d30d2d938e9be
1 /*
2 Copyright_License {
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 = {
29 Unit::KILOMETER,
30 Unit::METER,
31 Unit::DEGREES_CELCIUS,
32 Unit::KILOMETER_PER_HOUR,
33 Unit::METER_PER_SECOND,
34 Unit::KILOMETER_PER_HOUR,
35 Unit::KILOMETER_PER_HOUR,
36 Unit::HECTOPASCAL,
39 void
40 Units::SetConfig(const UnitSetting &new_config)
42 current = new_config;
45 Unit
46 Units::GetUserDistanceUnit()
48 return current.distance_unit;
51 Unit
52 Units::GetUserAltitudeUnit()
54 return current.altitude_unit;
57 Unit
58 Units::GetUserTemperatureUnit()
60 return current.temperature_unit;
63 Unit
64 Units::GetUserSpeedUnit()
66 return current.speed_unit;
69 Unit
70 Units::GetUserTaskSpeedUnit()
72 return current.task_speed_unit;
75 Unit
76 Units::GetUserVerticalSpeedUnit()
78 return current.vertical_speed_unit;
81 Unit
82 Units::GetUserWindSpeedUnit()
84 return current.wind_speed_unit;
87 Unit
88 Units::GetUserPressureUnit()
90 return current.pressure_unit;
93 Unit
94 Units::GetUserUnitByGroup(UnitGroup group)
96 return current.GetByGroup(group);
99 const TCHAR *
100 Units::GetSpeedName()
102 return GetUnitName(GetUserSpeedUnit());
105 const TCHAR *
106 Units::GetVerticalSpeedName()
108 return GetUnitName(GetUserVerticalSpeedUnit());
111 const TCHAR *
112 Units::GetWindSpeedName()
114 return GetUnitName(GetUserWindSpeedUnit());
117 const TCHAR *
118 Units::GetDistanceName()
120 return GetUnitName(GetUserDistanceUnit());
123 const TCHAR *
124 Units::GetAltitudeName()
126 return GetUnitName(GetUserAltitudeUnit());
129 const TCHAR *
130 Units::GetTemperatureName()
132 return GetUnitName(GetUserTemperatureUnit());
135 const TCHAR *
136 Units::GetTaskSpeedName()
138 return GetUnitName(GetUserTaskSpeedUnit());
141 const TCHAR *
142 Units::GetPressureName()
144 return GetUnitName(GetUserPressureUnit());
147 fixed
148 Units::ToUserPressure(AtmosphericPressure value)
150 return ToUserPressure(value.GetHectoPascal());
153 AtmosphericPressure
154 Units::FromUserPressure(fixed value)
156 return AtmosphericPressure::HectoPascal(ToSysPressure(value));