dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
quanton.cpp
Go to the documentation of this file.
1 
14 /*
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful, but
21  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  * for more details.
24  *
25  * You should have received a copy of the GNU General Public License along
26  * with this program; if not, see <http://www.gnu.org/licenses/>
27  */
28 
29 #include "quanton.h"
30 
34 #include "board_usb_ids.h"
35 
36 #include "hwquanton.h"
37 
43 {
44  // Common USB IDs
46  USBInfo(DRONIN_VID_DRONIN_BOOTLOADER, DRONIN_PID_DRONIN_BOOTLOADER, BCD_DEVICE_BOOTLOADER));
48  USBInfo(DRONIN_VID_DRONIN_FIRMWARE, DRONIN_PID_DRONIN_FIRMWARE, BCD_DEVICE_FIRMWARE));
49  // Legacy USB IDs
50  addBootloaderUSBInfo(USBInfo(DRONIN_VID_QUANTECNETWORKS_QUANTON,
51  DRONIN_PID_QUANTECNETWORKS_QUANTON, BCD_DEVICE_BOOTLOADER));
52  addFirmwareUSBInfo(USBInfo(DRONIN_VID_QUANTECNETWORKS_QUANTON,
53  DRONIN_PID_QUANTECNETWORKS_QUANTON, BCD_DEVICE_FIRMWARE));
54 
55  boardType = 0x86;
56 
57  // Define the bank of channels that are connected to a given timer
58  channelBanks.resize(6);
59  channelBanks[0] = QVector<int>() << 1 << 2 << 3 << 4;
60  channelBanks[1] = QVector<int>() << 5 << 6;
61  channelBanks[2] = QVector<int>() << 7;
62  channelBanks[3] = QVector<int>() << 8;
63 }
64 
66 {
67 }
68 
70 {
71  return QString("quanton");
72 }
73 
75 {
76  return QString("quanton flight control rev. 1 by Quantec Networks GmbH");
77 }
78 
80 {
81  return 0x84;
82 }
83 
86 {
87  switch (capability) {
93  return true;
94  default:
95  break;
96  }
97 
98  return false;
99 }
100 
102 {
103  return QPixmap(":/quantec/images/quanton.png");
104 }
105 
108 {
109  switch (type) {
110  case INPUT_TYPE_UNKNOWN:
111  return false;
112  default:
113  break;
114  }
115 
116  return true;
117 }
118 
120 {
121  return "HwQuanton";
122 }
123 
130 {
131  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
132  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
133  HwQuanton *HwQuanton = HwQuanton::GetInstance(uavoManager);
134  Q_ASSERT(HwQuanton);
135  if (!HwQuanton)
136  return false;
137 
138  HwQuanton::DataFields settings = HwQuanton->getData();
139 
140  switch (type) {
141  case INPUT_TYPE_PPM:
142  settings.InPort = HwQuanton::INPORT_PPM;
143  break;
144  case INPUT_TYPE_PWM:
145  settings.InPort = HwQuanton::INPORT_PWM;
146  break;
147  case INPUT_TYPE_HOTTSUMD:
148  settings.Uart1 = HwQuanton::UART1_HOTTSUMD;
149  break;
150  case INPUT_TYPE_HOTTSUMH:
151  settings.Uart1 = HwQuanton::UART1_HOTTSUMD;
152  break;
153  case INPUT_TYPE_SBUS:
154  settings.Uart2 = HwQuanton::UART2_SBUS;
155  break;
157  settings.Uart1 = HwQuanton::UART1_SBUSNONINVERTED;
158  break;
159  case INPUT_TYPE_IBUS:
160  settings.Uart1 = HwQuanton::UART1_IBUS;
161  break;
162  case INPUT_TYPE_SRXL:
163  settings.Uart1 = HwQuanton::UART1_SRXL;
164  break;
166  settings.Uart1 = HwQuanton::UART1_TBSCROSSFIRE;
167  break;
168  case INPUT_TYPE_DSM:
169  settings.Uart1 = HwQuanton::UART1_DSM;
170  break;
171  default:
172  return false;
173  }
174 
175  // Apply these changes
176  HwQuanton->setData(settings);
177 
178  return true;
179 }
180 
186 {
187  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
188  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
189  HwQuanton *HwQuanton = HwQuanton::GetInstance(uavoManager);
190  Q_ASSERT(HwQuanton);
191  if (!HwQuanton)
192  return INPUT_TYPE_UNKNOWN;
193 
194  HwQuanton::DataFields settings = HwQuanton->getData();
195 
196  switch (settings.InPort) {
197  case HwQuanton::INPORT_PPM:
198  case HwQuanton::INPORT_PPMADC:
199  case HwQuanton::INPORT_PPMOUTPUTS:
200  case HwQuanton::INPORT_PPMOUTPUTSADC:
201  // discutable, are these PPM, PWM or defined by the InPortSerial port?
202  // For now defined as PPM.
203  case HwQuanton::INPORT_PPMSERIAL:
204  case HwQuanton::INPORT_PPMSERIALADC:
205  case HwQuanton::INPORT_PPMPWM:
206  case HwQuanton::INPORT_PPMPWMADC:
207  return INPUT_TYPE_PPM;
208  case HwQuanton::INPORT_PWM:
209  case HwQuanton::INPORT_PWMADC:
210  return INPUT_TYPE_PWM;
211  case HwQuanton::INPORT_SERIAL:
212  switch (settings.InPortSerial) {
213  case HwQuanton::INPORTSERIAL_DSM:
214  return INPUT_TYPE_DSM;
215  case HwQuanton::INPORTSERIAL_HOTTSUMD:
216  return INPUT_TYPE_HOTTSUMD;
217  case HwQuanton::INPORTSERIAL_HOTTSUMH:
218  return INPUT_TYPE_HOTTSUMH;
219  case HwQuanton::INPORTSERIAL_SBUSNONINVERTED:
221  case HwQuanton::INPORTSERIAL_IBUS:
222  return INPUT_TYPE_IBUS;
223  case HwQuanton::INPORTSERIAL_SRXL:
224  return INPUT_TYPE_SRXL;
225  case HwQuanton::INPORTSERIAL_TBSCROSSFIRE:
227  default:
228  break;
229  }
230  break;
231  default:
232  break;
233  }
234 
235  switch (settings.Uart1) {
236  case HwQuanton::UART1_DSM:
237  return INPUT_TYPE_DSM;
238  case HwQuanton::UART1_HOTTSUMD:
239  return INPUT_TYPE_HOTTSUMD;
240  case HwQuanton::UART1_HOTTSUMH:
241  return INPUT_TYPE_HOTTSUMH;
242  case HwQuanton::UART1_SBUSNONINVERTED:
244  case HwQuanton::UART1_IBUS:
245  return INPUT_TYPE_IBUS;
246  case HwQuanton::UART1_SRXL:
247  return INPUT_TYPE_SRXL;
248  case HwQuanton::UART1_TBSCROSSFIRE:
250  default:
251  break;
252  }
253 
254  switch (settings.Uart2) {
255  case HwQuanton::UART2_DSM:
256  return INPUT_TYPE_DSM;
257  case HwQuanton::UART2_HOTTSUMD:
258  return INPUT_TYPE_HOTTSUMD;
259  case HwQuanton::UART2_HOTTSUMH:
260  return INPUT_TYPE_HOTTSUMH;
261  case HwQuanton::UART2_SBUS:
262  return INPUT_TYPE_SBUS;
263  case HwQuanton::UART2_SBUSNONINVERTED:
265  case HwQuanton::UART2_IBUS:
266  return INPUT_TYPE_IBUS;
267  case HwQuanton::UART2_SRXL:
268  return INPUT_TYPE_SRXL;
269  case HwQuanton::UART2_TBSCROSSFIRE:
271  default:
272  break;
273  }
274 
275  switch (settings.Uart3) {
276  case HwQuanton::UART3_DSM:
277  return INPUT_TYPE_DSM;
278  case HwQuanton::UART3_HOTTSUMD:
279  return INPUT_TYPE_HOTTSUMD;
280  case HwQuanton::UART3_HOTTSUMH:
281  return INPUT_TYPE_HOTTSUMH;
282  case HwQuanton::UART3_SBUSNONINVERTED:
284  case HwQuanton::UART3_IBUS:
285  return INPUT_TYPE_IBUS;
286  case HwQuanton::UART3_SRXL:
287  return INPUT_TYPE_SRXL;
288  case HwQuanton::UART3_TBSCROSSFIRE:
290  default:
291  break;
292  }
293 
294  switch (settings.Uart4) {
295  case HwQuanton::UART4_DSM:
296  return INPUT_TYPE_DSM;
297  case HwQuanton::UART4_HOTTSUMD:
298  return INPUT_TYPE_HOTTSUMD;
299  case HwQuanton::UART4_HOTTSUMH:
300  return INPUT_TYPE_HOTTSUMH;
301  case HwQuanton::UART4_SBUSNONINVERTED:
303  case HwQuanton::UART4_IBUS:
304  return INPUT_TYPE_IBUS;
305  case HwQuanton::UART4_SRXL:
306  return INPUT_TYPE_SRXL;
307  case HwQuanton::UART4_TBSCROSSFIRE:
309  default:
310  break;
311  }
312 
313  switch (settings.Uart5) {
314  case HwQuanton::UART5_DSM:
315  return INPUT_TYPE_DSM;
316  case HwQuanton::UART5_HOTTSUMD:
317  return INPUT_TYPE_HOTTSUMD;
318  case HwQuanton::UART5_HOTTSUMH:
319  return INPUT_TYPE_HOTTSUMH;
320  case HwQuanton::UART5_SBUSNONINVERTED:
322  case HwQuanton::UART5_IBUS:
323  return INPUT_TYPE_IBUS;
324  case HwQuanton::UART5_SRXL:
325  return INPUT_TYPE_SRXL;
326  case HwQuanton::UART5_TBSCROSSFIRE:
328  default:
329  break;
330  }
331 
332  return INPUT_TYPE_UNKNOWN;
333 }
334 
336 {
337  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
338  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
339  HwQuanton *hwQuanton = HwQuanton::GetInstance(uavoManager);
340  Q_ASSERT(hwQuanton);
341  if (!hwQuanton)
342  return 0;
343 
344  HwQuanton::DataFields settings = hwQuanton->getData();
345 
346  switch (settings.GyroRange) {
347  case HwQuanton::GYRORANGE_250:
348  return 250;
349  case HwQuanton::GYRORANGE_500:
350  return 500;
351  case HwQuanton::GYRORANGE_1000:
352  return 1000;
353  case HwQuanton::GYRORANGE_2000:
354  return 2000;
355  default:
356  break;
357  }
358 
359  return 500;
360 }
361 
362 QStringList Quanton::getAdcNames()
363 {
364  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
365  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
366  HwQuanton *hwQuanton = HwQuanton::GetInstance(uavoManager);
367  Q_ASSERT(hwQuanton);
368  if (!hwQuanton)
369  return QStringList();
370 
371  HwQuanton::DataFields settings = hwQuanton->getData();
372  if (settings.InPort == HwQuanton::INPORT_OUTPUTSADC
373  || settings.InPort == HwQuanton::INPORT_PPMADC
374  || settings.InPort == HwQuanton::INPORT_PPMOUTPUTSADC
375  || settings.InPort == HwQuanton::INPORT_PPMPWMADC
376  || settings.InPort == HwQuanton::INPORT_PWMADC
377  || settings.InPort == HwQuanton::INPORT_PPMSERIALADC) {
378  return QStringList() << "IN 7"
379  << "IN 8";
380  }
381 
382  return QStringList() << "Disabled"
383  << "Disabled";
384 }
385 
387 {
388  switch (annunc) {
390  case ANNUNCIATOR_ALARM:
391  case ANNUNCIATOR_BUZZER:
392  case ANNUNCIATOR_RGB:
393  return true;
394  case ANNUNCIATOR_DAC:
395  break;
396  }
397  return false;
398 }
qint32 boardType
The numerical board type ID.
Definition: iboardtype.h:284
virtual QString boardDescription()
Definition: quanton.cpp:74
virtual bool queryCapabilities(BoardCapabilities capability)
Return which capabilities this board has.
Definition: quanton.cpp:85
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type)
Determine if this board supports configuring the receiver.
Definition: quanton.cpp:107
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 bool setInputType(Core::IBoardType::InputType type)
Definition: quanton.cpp:129
virtual bool hasAnnunciator(AnnunciatorType annunc)
Check if the board has the given type of annunciator.
Definition: quanton.cpp:386
Quanton()
Quanton::Quanton This is the Quanton board definition.
Definition: quanton.cpp:42
The USBInfo struct.
Definition: iboardtype.h:62
virtual ~Quanton()
Definition: quanton.cpp:65
void addFirmwareUSBInfo(USBInfo info)
Definition: iboardtype.h:277
void addBootloaderUSBInfo(USBInfo info)
Definition: iboardtype.h:278
virtual QString shortName()
Definition: quanton.cpp:69
virtual QString getHwUAVO()
Definition: quanton.cpp:119
virtual int queryMaxGyroRate()
Query the board for the currently set max rate of the gyro.
Definition: quanton.cpp:335
virtual Core::IBoardType::InputType getInputType()
getInputOnPort get the current input type
Definition: quanton.cpp:185
virtual int minBootLoaderVersion()
Returns the minimum bootloader version required.
Definition: quanton.cpp:79
virtual QStringList getAdcNames()
Definition: quanton.cpp:362
virtual QPixmap getBoardPicture()
getBoardPicture
Definition: quanton.cpp:101