dlgTextEntry_Keyboard: rename to TouchTextEntry
[xcsoar.git] / src / Input / InputEventsVega.cpp
blob6b529bc8532f772480af0d101a6e35dcd1b13b3e
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 "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"
33 static VegaDevice *
34 GetVegaDevice(DeviceDescriptor &device)
36 return !device.IsOccupied() && device.GetState() == PortState::READY &&
37 device.IsVega() && device.GetDevice() != nullptr
38 ? (VegaDevice *)device.GetDevice()
39 : NULL;
42 static void
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]);
49 if (vega != NULL)
50 vega->SendSetting(name, value, env);
54 static void
55 AllVegasRequestSetting(const char *name)
57 PopupOperationEnvironment env;
59 for (unsigned i = 0; i < NUMDEV; ++i) {
60 VegaDevice *vega = GetVegaDevice(*device_list[i]);
61 if (vega != NULL)
62 vega->RequestSetting(name, env);
66 // AdjustVarioFilter
67 // When connected to the Vega variometer, this adjusts
68 // the filter time constant
69 // slow/medium/fast
70 // The following arguments can be used for diagnostics purposes
71 // statistics:
72 // diagnostics:
73 // psraw:
74 // switch:
75 // The following arguments can be used to trigger demo modes:
76 // climbdemo:
77 // stfdemo:
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
82 void
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"))) {
107 switch (naccel) {
108 case 0:
109 AllVegasRequestSetting("AccelerometerSlopeX");
110 break;
111 case 1:
112 AllVegasRequestSetting("AccelerometerSlopeY");
113 break;
114 case 2:
115 AllVegasRequestSetting("AccelerometerOffsetX");
116 break;
117 case 3:
118 AllVegasRequestSetting("AccelerometerOffsetY");
119 break;
120 default:
121 naccel = 0;
122 break;
124 naccel++;
125 if (naccel > 3)
126 naccel = 0;
128 } else if (StringIsEqual(misc, _T("xdemo"))) {
129 dlgVegaDemoShowModal();
130 } else if (StringIsEqual(misc, _T("zero"))) {
131 // zero, no mixing
132 if (!CommonInterface::Calculated().flight.flying) {
133 AllVegasSendSetting("ZeroASI", 1);
135 } else if (StringIsEqual(misc, _T("save"))) {
136 AllVegasSendSetting("StoreToEeprom", 2);
138 // accel calibration
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);