dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
sprf3e.cpp
Go to the documentation of this file.
1 
11 /*
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20  * for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, see <http://www.gnu.org/licenses/>
24  *
25  * Additional note on redistribution: The copyright and license notices above
26  * must be maintained in each individual source file that is a derivative work
27  * of this source file; otherwise redistribution is prohibited.
28  */
29 
31 
32 #include "sprf3e.h"
33 #include "hwsprf3e.h"
34 #include "sprf3econfiguration.h"
35 #include "board_usb_ids.h"
36 
37 
40 
41 
47 {
48  // Common USB IDs
49  addBootloaderUSBInfo(USBInfo(DRONIN_VID_DRONIN_BOOTLOADER, DRONIN_PID_DRONIN_BOOTLOADER, BCD_DEVICE_BOOTLOADER));
50  addFirmwareUSBInfo(USBInfo(DRONIN_VID_DRONIN_FIRMWARE, DRONIN_PID_DRONIN_FIRMWARE, BCD_DEVICE_FIRMWARE));
51 
52  boardType = 0xCF;
53 
54  channelBanks.resize(3);
55  channelBanks.clear();
56  channelBanks << (QVector<int>() << 1 << 2); // TIM2
57  channelBanks << (QVector<int>() << 3 << 4); // TIM15
58  channelBanks << (QVector<int>() << 5 << 6 << 7 << 8); // TIM3
59 }
60 
62 {
63 }
64 
66 {
67  return QString("Sprf3e");
68 }
69 
71 {
72  return QString(tr("SP Racing F3 E / FrSky XSRF3E running dRonin firmware"));
73 }
74 
76 {
77  switch (capability) {
83  return true;
84  default:
85  break;
86  }
87  return false;
88 }
89 
91 {
92  switch (type) {
93  case INPUT_TYPE_PWM:
94  case INPUT_TYPE_UNKNOWN:
95  return false;
96  default:
97  break;
98  }
99  return true;
100 }
101 
103 {
104  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
105  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
106  HwSprf3e *hwSprf3e = HwSprf3e::GetInstance(uavoManager);
107  Q_ASSERT(hwSprf3e);
108  if (!hwSprf3e)
109  return false;
110 
111  HwSprf3e::DataFields settings = hwSprf3e->getData();
112 
113  switch(type) {
114  case INPUT_TYPE_DSM:
115  settings.Uart2 = HwSprf3e::UART2_DSM;
116  break;
117  case INPUT_TYPE_SRXL:
118  settings.Uart2 = HwSprf3e::UART2_SRXL;
119  break;
120  case INPUT_TYPE_HOTTSUMD:
121  settings.Uart2 = HwSprf3e::UART2_HOTTSUMD;
122  break;
123  case INPUT_TYPE_HOTTSUMH:
124  settings.Uart2 = HwSprf3e::UART2_HOTTSUMH;
125  break;
126  case INPUT_TYPE_PPM:
127  settings.Uart2 = HwSprf3e::UART2_PPM;
128  break;
129  case INPUT_TYPE_SBUS:
130  settings.Uart2 = HwSprf3e::UART2_SBUS;
131  break;
133  settings.Uart2 = HwSprf3e::UART2_SBUSNONINVERTED;
134  break;
135  case INPUT_TYPE_IBUS:
136  settings.Uart2 = HwSprf3e::UART2_IBUS;
137  break;
139  settings.Uart2 = HwSprf3e::UART2_TBSCROSSFIRE;
140  break;
141  default:
142  return false;
143  }
144 
145  // Apply these changes
146  hwSprf3e->setData(settings);
147 
148  return true;
149 }
150 
152 {
153  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
154  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
155  HwSprf3e *hwSprf3e = HwSprf3e::GetInstance(uavoManager);
156  Q_ASSERT(hwSprf3e);
157  if (!hwSprf3e)
158  return INPUT_TYPE_UNKNOWN;
159 
160  HwSprf3e::DataFields settings = hwSprf3e->getData();
161 
162  switch(settings.Uart1) {
163  case HwSprf3e::UART1_DSM:
164  return INPUT_TYPE_DSM;
165  case HwSprf3e::UART1_SRXL:
166  return INPUT_TYPE_SRXL;
167  case HwSprf3e::UART1_HOTTSUMD:
168  return INPUT_TYPE_HOTTSUMD;
169  case HwSprf3e::UART1_HOTTSUMH:
170  return INPUT_TYPE_HOTTSUMH;
171  case HwSprf3e::UART1_SBUS:
172  return INPUT_TYPE_SBUS;
173  case HwSprf3e::UART1_SBUSNONINVERTED:
175  case HwSprf3e::UART1_IBUS:
176  return INPUT_TYPE_IBUS;
177  case HwSprf3e::UART1_TBSCROSSFIRE:
179  default:
180  break;
181  }
182 
183  switch(settings.Uart2) {
184  case HwSprf3e::UART2_DSM:
185  return INPUT_TYPE_DSM;
186  case HwSprf3e::UART2_SRXL:
187  return INPUT_TYPE_SRXL;
188  case HwSprf3e::UART2_HOTTSUMD:
189  return INPUT_TYPE_HOTTSUMD;
190  case HwSprf3e::UART2_HOTTSUMH:
191  return INPUT_TYPE_HOTTSUMH;
192  case HwSprf3e::UART2_SBUS:
193  return INPUT_TYPE_SBUS;
194  case HwSprf3e::UART2_SBUSNONINVERTED:
196  case HwSprf3e::UART2_IBUS:
197  return INPUT_TYPE_IBUS;
198  case HwSprf3e::UART2_PPM:
199  return INPUT_TYPE_PPM;
200  case HwSprf3e::UART2_TBSCROSSFIRE:
202  default:
203  break;
204  }
205 
206  switch(settings.Uart3) {
207  case HwSprf3e::UART3_DSM:
208  return INPUT_TYPE_DSM;
209  case HwSprf3e::UART3_SRXL:
210  return INPUT_TYPE_SRXL;
211  case HwSprf3e::UART3_HOTTSUMD:
212  return INPUT_TYPE_HOTTSUMD;
213  case HwSprf3e::UART3_HOTTSUMH:
214  return INPUT_TYPE_HOTTSUMH;
215  case HwSprf3e::UART3_SBUS:
216  return INPUT_TYPE_SBUS;
217  case HwSprf3e::UART3_SBUSNONINVERTED:
219  case HwSprf3e::UART3_IBUS:
220  return INPUT_TYPE_IBUS;
221  case HwSprf3e::UART3_TBSCROSSFIRE:
223  default:
224  break;
225  }
226 
227  return INPUT_TYPE_PPM;
228 }
229 
231 {
232  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
233  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
234  HwSprf3e *hwSprf3e = HwSprf3e::GetInstance(uavoManager);
235  Q_ASSERT(hwSprf3e);
236  if (!hwSprf3e)
237  return 0;
238 
239  HwSprf3e::DataFields settings = hwSprf3e->getData();
240 
241  switch(settings.GyroRange) {
242  case HwSprf3e::GYRORANGE_250:
243  return 250;
244  case HwSprf3e::GYRORANGE_500:
245  return 500;
246  case HwSprf3e::GYRORANGE_1000:
247  return 1000;
248  case HwSprf3e::GYRORANGE_2000:
249  return 2000;
250  default:
251  break;
252  }
253 
254  return 2000;
255 }
256 
257 QStringList Sprf3e::getAdcNames()
258 {
259  return QStringList() << "V" << "A" << "RSSI";
260 }
261 
263 {
264  return QPixmap(":/dronin/images/sprf3e.png");
265 }
266 
268 {
269  return "HwSprf3e";
270 }
271 
273 {
274  return ":/dronin/images/sprf3e-connection.svg";
275 }
276 
277 QWidget *Sprf3e::getBoardConfiguration(QWidget *parent, bool connected)
278 {
279  Q_UNUSED(connected)
280 
281  return new Sprf3eConfiguration(parent);
282 }
283 
285 {
286  switch (annunc) {
288  case ANNUNCIATOR_ALARM:
289  case ANNUNCIATOR_BUZZER:
290  return true;
291  case ANNUNCIATOR_RGB:
292  case ANNUNCIATOR_DAC:
293  break;
294  }
295  return false;
296 }
297 
qint32 boardType
The numerical board type ID.
Definition: iboardtype.h:284
virtual bool hasAnnunciator(AnnunciatorType annunc)
Check if the board has the given type of annunciator.
Definition: sprf3e.cpp:284
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type)
Determine if this board supports configuring the receiver.
Definition: sprf3e.cpp:90
virtual QStringList getAdcNames()
Definition: sprf3e.cpp:257
InputType
Types of input to configure for the default port.
Definition: iboardtype.h:158
QVector< QVector< qint32 > > channelBanks
The channel groups that are driven by timers.
Definition: iboardtype.h:287
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
BoardCapabilities
Types of capabilities boards can support.
Definition: iboardtype.h:92
virtual QString getConnectionDiagram()
getConnectionDiagram get the connection diagram for this board
Definition: sprf3e.cpp:272
virtual bool queryCapabilities(BoardCapabilities capability)
Query capabilities of the board.
Definition: sprf3e.cpp:75
virtual QWidget * getBoardConfiguration(QWidget *parent, bool connected)
getBoardConfiguration
Definition: sprf3e.cpp:277
The USBInfo struct.
Definition: iboardtype.h:62
virtual QString boardDescription()
Definition: sprf3e.cpp:70
void addFirmwareUSBInfo(USBInfo info)
Definition: iboardtype.h:277
virtual int queryMaxGyroRate()
Query the board for the currently set max rate of the gyro.
Definition: sprf3e.cpp:230
void addBootloaderUSBInfo(USBInfo info)
Definition: iboardtype.h:278
virtual Core::IBoardType::InputType getInputType()
getInputType get the current input type
Definition: sprf3e.cpp:151
virtual bool setInputType(Core::IBoardType::InputType type)
Definition: sprf3e.cpp:102
virtual QString getHwUAVO()
Definition: sprf3e.cpp:267
virtual ~Sprf3e()
Definition: sprf3e.cpp:61
virtual QPixmap getBoardPicture()
getBoardPicture
Definition: sprf3e.cpp:262
Sprf3e()
Sprf3e:Sprf3e This is the Sprf3e board definition.
Definition: sprf3e.cpp:46
virtual QString shortName()
Definition: sprf3e.cpp:65