dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
gcscontrolgadgetconfiguration.cpp
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 
28 
34  QObject *parent)
35  : IUAVGadgetConfiguration(classId, parent)
36  , rollChannel(-1)
37  , pitchChannel(-1)
38  , yawChannel(-1)
39  , throttleChannel(-1)
40 {
41  int i;
42  for (i = 0; i < 8; i++) {
43  buttonSettings[i].ActionID = 0;
44  buttonSettings[i].FunctionID = 0;
45  buttonSettings[i].Amount = 0;
46  channelReverse[i] = 0;
47  }
48  // if a saved configuration exists load it
49  if (qSettings != nullptr) {
50  controlsMode = qSettings->value("controlsMode").toInt();
51  rollChannel = qSettings->value("rollChannel").toInt();
52  pitchChannel = qSettings->value("pitchChannel").toInt();
53  yawChannel = qSettings->value("yawChannel").toInt();
54  throttleChannel = qSettings->value("throttleChannel").toInt();
55 
56  gcsReceiverMode = qSettings->value("gcsReceiverMode").toBool();
57 
58  for (unsigned int i = 0; i < 8; i++) {
59  buttonSettings[i].ActionID =
60  qSettings->value(QString().sprintf("button%dAction", i)).toInt();
61  buttonSettings[i].FunctionID =
62  qSettings->value(QString().sprintf("button%dFunction", i)).toInt();
63  buttonSettings[i].Amount =
64  qSettings->value(QString().sprintf("button%dAmount", i)).toDouble();
65  channelReverse[i] = qSettings->value(QString().sprintf("channel%dReverse", i)).toBool();
66  }
67  }
68 }
69 
70 void GCSControlGadgetConfiguration::setRPYTchannels(int roll, int pitch, int yaw, int throttle)
71 {
72  rollChannel = roll;
73  pitchChannel = pitch;
74  yawChannel = yaw;
75  throttleChannel = throttle;
76 }
77 
79 {
80  QList<int> ql;
81  ql << rollChannel << pitchChannel << yawChannel << throttleChannel;
82  return ql;
83 }
85 {
86  QList<bool> ql;
87  int i;
88  for (i = 0; i < 8; i++)
89  ql << channelReverse[i];
90 
91  return ql;
92 }
93 
95 {
96  return gcsReceiverMode;
97 }
98 
100 {
101  gcsReceiverMode = enable;
102 }
103 
108 IUAVGadgetConfiguration *GCSControlGadgetConfiguration::clone()
109 {
111 
112  m->controlsMode = controlsMode;
113  m->rollChannel = rollChannel;
114  m->pitchChannel = pitchChannel;
115  m->yawChannel = yawChannel;
116  m->throttleChannel = throttleChannel;
117 
118  m->gcsReceiverMode = gcsReceiverMode;
119 
120  int i;
121  for (i = 0; i < 8; i++) {
122  m->buttonSettings[i].ActionID = buttonSettings[i].ActionID;
123  m->buttonSettings[i].FunctionID = buttonSettings[i].FunctionID;
124  m->buttonSettings[i].Amount = buttonSettings[i].Amount;
125  m->channelReverse[i] = channelReverse[i];
126  }
127 
128  return m;
129 }
130 
135 void GCSControlGadgetConfiguration::saveConfig(QSettings *settings) const
136 {
137  settings->setValue("controlsMode", controlsMode);
138  settings->setValue("rollChannel", rollChannel);
139  settings->setValue("pitchChannel", pitchChannel);
140  settings->setValue("yawChannel", yawChannel);
141  settings->setValue("throttleChannel", throttleChannel);
142 
143  settings->setValue("gcsReceiverMode", gcsReceiverMode);
144 
145  for (unsigned int i = 0; i < 8; i++) {
146  settings->setValue(QString().sprintf("button%dAction", i), buttonSettings[i].ActionID);
147  settings->setValue(QString().sprintf("button%dFunction", i), buttonSettings[i].FunctionID);
148  settings->setValue(QString().sprintf("button%dAmount", i), buttonSettings[i].Amount);
149  settings->setValue(QString().sprintf("channel%dReverse", i), channelReverse[i]);
150  }
151 }
for i
Definition: OPPlots.m:140
GCSControlGadgetConfiguration(QString classId, QSettings *qSettings=nullptr, QObject *parent=nullptr)
void setRPYTchannels(int roll, int pitch, int yaw, int throttle)