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 "InputEvents.hpp"
25 #include "Dialogs/Device/Vega/VegaDialogs.hpp"
26 #include "Device/List.hpp"
27 #include "Device/Descriptor.hpp"
28 #include "Device/Driver/Vega/Internal.hpp"
29 #include "Util/StringUtil.hpp"
30 #include "Interface.hpp"
31 #include "Operation/PopupOperationEnvironment.hpp"
34 GetVegaDevice(DeviceDescriptor
&device
)
36 return !device
.IsOccupied() && device
.GetState() == PortState::READY
&&
37 device
.IsVega() && device
.GetDevice() != nullptr
38 ? (VegaDevice
*)device
.GetDevice()
43 AllVegasSendSetting(const char *name
, int value
)
45 PopupOperationEnvironment env
;
47 for (unsigned i
= 0; i
< NUMDEV
; ++i
) {
48 VegaDevice
*vega
= GetVegaDevice(*device_list
[i
]);
50 vega
->SendSetting(name
, value
, env
);
55 AllVegasRequestSetting(const char *name
)
57 PopupOperationEnvironment env
;
59 for (unsigned i
= 0; i
< NUMDEV
; ++i
) {
60 VegaDevice
*vega
= GetVegaDevice(*device_list
[i
]);
62 vega
->RequestSetting(name
, env
);
67 // When connected to the Vega variometer, this adjusts
68 // the filter time constant
70 // The following arguments can be used for diagnostics purposes
75 // The following arguments can be used to trigger demo modes:
78 // Other arguments control vario setup:
79 // save: saves the vario configuration to nonvolatile memory on the instrument
80 // zero: Zero's the airspeed indicator's offset
83 InputEvents::eventAdjustVarioFilter(const TCHAR
*misc
)
85 static int naccel
= 0;
86 if (StringIsEqual(misc
, _T("slow")))
87 AllVegasSendSetting("VarioTimeConstant", 3);
88 else if (StringIsEqual(misc
, _T("medium")))
89 AllVegasSendSetting("VarioTimeConstant", 2);
90 else if (StringIsEqual(misc
, _T("fast")))
91 AllVegasSendSetting("VarioTimeConstant", 1);
92 else if (StringIsEqual(misc
, _T("statistics")))
93 AllVegasSendSetting("Diagnostics", 1);
94 else if (StringIsEqual(misc
, _T("diagnostics")))
95 AllVegasSendSetting("Diagnostics", 2);
96 else if (StringIsEqual(misc
, _T("psraw")))
97 AllVegasSendSetting("Diagnostics", 3);
98 else if (StringIsEqual(misc
, _T("switch")))
99 AllVegasSendSetting("Diagnostics", 4);
100 else if (StringIsEqual(misc
, _T("democlimb"))) {
101 AllVegasSendSetting("DemoMode", 0);
102 AllVegasSendSetting("DemoMode", 2);
103 } else if (StringIsEqual(misc
, _T("demostf"))) {
104 AllVegasSendSetting("DemoMode", 0);
105 AllVegasSendSetting("DemoMode", 1);
106 } else if (StringIsEqual(misc
, _T("accel"))) {
109 AllVegasRequestSetting("AccelerometerSlopeX");
112 AllVegasRequestSetting("AccelerometerSlopeY");
115 AllVegasRequestSetting("AccelerometerOffsetX");
118 AllVegasRequestSetting("AccelerometerOffsetY");
128 } else if (StringIsEqual(misc
, _T("xdemo"))) {
129 dlgVegaDemoShowModal();
130 } else if (StringIsEqual(misc
, _T("zero"))) {
132 if (!CommonInterface::Calculated().flight
.flying
) {
133 AllVegasSendSetting("ZeroASI", 1);
135 } else if (StringIsEqual(misc
, _T("save"))) {
136 AllVegasSendSetting("StoreToEeprom", 2);
139 } else if (!CommonInterface::Calculated().flight
.flying
) {
140 if (StringIsEqual(misc
, _T("X1")))
141 AllVegasSendSetting("CalibrateAccel", 1);
142 else if (StringIsEqual(misc
, _T("X2")))
143 AllVegasSendSetting("CalibrateAccel", 2);
144 else if (StringIsEqual(misc
, _T("X3")))
145 AllVegasSendSetting("CalibrateAccel", 3);
146 else if (StringIsEqual(misc
, _T("X4")))
147 AllVegasSendSetting("CalibrateAccel", 4);
148 else if (StringIsEqual(misc
, _T("X5")))
149 AllVegasSendSetting("CalibrateAccel", 5);