dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
sparky2.cpp
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #include "sparky2.h"
29 
32 #include "board_usb_ids.h"
33 
39 {
40  // Common USB IDs
42  USBInfo(DRONIN_VID_DRONIN_BOOTLOADER, DRONIN_PID_DRONIN_BOOTLOADER, BCD_DEVICE_BOOTLOADER));
44  USBInfo(DRONIN_VID_DRONIN_FIRMWARE, DRONIN_PID_DRONIN_FIRMWARE, BCD_DEVICE_FIRMWARE));
45  // Legacy USB IDs
47  USBInfo(DRONIN_VID_TAULABS_SPARKY, DRONIN_PID_TAULABS_SPARKY, BCD_DEVICE_BOOTLOADER));
49  USBInfo(DRONIN_VID_TAULABS_SPARKY, DRONIN_PID_TAULABS_SPARKY, BCD_DEVICE_FIRMWARE));
50 
51  boardType = 0x92;
52 
53  // Define the bank of channels that are connected to a given timer
54  // Ch1 TIM3
55  // Ch2 TIM3
56  // Ch3 TIM9
57  // Ch4 TIM9
58  // Ch5 TIM5
59  // Ch6 TIM5
60  // LED1 TIM12
61  // LED2 TIM12
62  // LED3 TIM8
63  // LED4 TIM8
64  channelBanks.resize(6);
65  channelBanks[0] = QVector<int>() << 1 << 2;
66  channelBanks[1] = QVector<int>() << 3 << 4;
67  channelBanks[2] = QVector<int>() << 5 << 6;
68  channelBanks[3] = QVector<int>() << 7 << 8;
69  channelBanks[4] = QVector<int>() << 9 << 10;
70  channelBanks[5] = QVector<int>();
71 
72  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
73  uavoUtilManager = pm->getObject<UAVObjectUtilManager>();
74 }
75 
77 {
78 }
79 
81 {
82  return QString("Sparky2");
83 }
84 
86 {
87  return QString("The Tau Labs project Sparky2 boards");
88 }
89 
92 {
93  switch (capability) {
100  return true;
101  default:
102  break;
103  }
104 
105  return false;
106 }
107 
109 {
110  return QPixmap(":/taulabs/images/sparky2.png");
111 }
112 
114 {
115  return "HwSparky2";
116 }
117 
120 {
121  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
122  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
123 
124  HwSparky2 *hwSparky2 = HwSparky2::GetInstance(uavoManager);
125  Q_ASSERT(hwSparky2);
126 
127  return hwSparky2;
128 }
129 
132 {
133  switch (type) {
134  case INPUT_TYPE_PWM:
135  case INPUT_TYPE_UNKNOWN:
136  return false;
137  default:
138  break;
139  }
140 
141  return true;
142 }
143 
150 {
151  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
152  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
153  HwSparky2 *hwSparky2 = HwSparky2::GetInstance(uavoManager);
154  Q_ASSERT(hwSparky2);
155  if (!hwSparky2)
156  return false;
157 
158  HwSparky2::DataFields settings = hwSparky2->getData();
159 
160  switch (type) {
161  case INPUT_TYPE_PPM:
162  settings.RcvrPort = HwSparky2::RCVRPORT_PPM;
163  break;
164  case INPUT_TYPE_SBUS:
165  settings.RcvrPort = HwSparky2::RCVRPORT_SBUS;
166  break;
168  settings.RcvrPort = HwSparky2::RCVRPORT_SBUSNONINVERTED;
169  break;
170  case INPUT_TYPE_DSM:
171  settings.RcvrPort = HwSparky2::RCVRPORT_DSM;
172  break;
173  case INPUT_TYPE_HOTTSUMD:
174  settings.RcvrPort = HwSparky2::RCVRPORT_HOTTSUMD;
175  break;
176  case INPUT_TYPE_HOTTSUMH:
177  settings.RcvrPort = HwSparky2::RCVRPORT_HOTTSUMH;
178  break;
179  case INPUT_TYPE_IBUS:
180  settings.RcvrPort = HwSparky2::RCVRPORT_IBUS;
181  break;
182  case INPUT_TYPE_SRXL:
183  settings.RcvrPort = HwSparky2::RCVRPORT_SRXL;
184  break;
186  settings.RcvrPort = HwSparky2::RCVRPORT_TBSCROSSFIRE;
187  break;
188  default:
189  return false;
190  }
191 
192  // Apply these changes
193  hwSparky2->setData(settings);
194 
195  return true;
196 }
197 
203 {
204  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
205  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
206  HwSparky2 *hwSparky2 = HwSparky2::GetInstance(uavoManager);
207  Q_ASSERT(hwSparky2);
208  if (!hwSparky2)
209  return INPUT_TYPE_UNKNOWN;
210 
211  HwSparky2::DataFields settings = hwSparky2->getData();
212 
213  switch (settings.RcvrPort) {
214  case HwSparky2::RCVRPORT_PPM:
215  return INPUT_TYPE_PPM;
216  case HwSparky2::RCVRPORT_SBUS:
217  return INPUT_TYPE_SBUS;
218  case HwSparky2::RCVRPORT_SBUSNONINVERTED:
220  case HwSparky2::RCVRPORT_DSM:
221  return INPUT_TYPE_DSM;
222  case HwSparky2::RCVRPORT_HOTTSUMD:
223  return INPUT_TYPE_HOTTSUMD;
224  case HwSparky2::RCVRPORT_HOTTSUMH:
225  return INPUT_TYPE_HOTTSUMH;
226  case HwSparky2::RCVRPORT_IBUS:
227  return INPUT_TYPE_IBUS;
228  case HwSparky2::RCVRPORT_SRXL:
229  return INPUT_TYPE_SRXL;
230  case HwSparky2::RCVRPORT_TBSCROSSFIRE:
232  default:
233  break;
234  }
235 
236  switch (settings.MainPort) {
237  case HwSparky2::MAINPORT_DSM:
238  return INPUT_TYPE_DSM;
239  case HwSparky2::MAINPORT_HOTTSUMD:
240  return INPUT_TYPE_HOTTSUMD;
241  case HwSparky2::MAINPORT_HOTTSUMH:
242  return INPUT_TYPE_HOTTSUMH;
243  case HwSparky2::MAINPORT_SBUSNONINVERTED:
245  case HwSparky2::MAINPORT_IBUS:
246  return INPUT_TYPE_IBUS;
247  case HwSparky2::MAINPORT_SRXL:
248  return INPUT_TYPE_SRXL;
249  case HwSparky2::MAINPORT_TBSCROSSFIRE:
251  default:
252  break;
253  }
254 
255  switch (settings.FlexiPort) {
256  case HwSparky2::FLEXIPORT_DSM:
257  return INPUT_TYPE_DSM;
258  case HwSparky2::FLEXIPORT_HOTTSUMD:
259  return INPUT_TYPE_HOTTSUMD;
260  case HwSparky2::FLEXIPORT_HOTTSUMH:
261  return INPUT_TYPE_HOTTSUMH;
262  case HwSparky2::FLEXIPORT_SBUSNONINVERTED:
264  case HwSparky2::FLEXIPORT_IBUS:
265  return INPUT_TYPE_IBUS;
266  case HwSparky2::FLEXIPORT_SRXL:
267  return INPUT_TYPE_SRXL;
268  case HwSparky2::FLEXIPORT_TBSCROSSFIRE:
270  default:
271  break;
272  }
273 
274  return INPUT_TYPE_UNKNOWN;
275 }
276 
278 {
279  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
280  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
281  HwSparky2 *hwSparky2 = HwSparky2::GetInstance(uavoManager);
282  Q_ASSERT(hwSparky2);
283  if (!hwSparky2)
284  return 0;
285 
286  HwSparky2::DataFields settings = hwSparky2->getData();
287 
288  switch (settings.GyroRange) {
289  case HwSparky2::GYRORANGE_250:
290  return 250;
291  case HwSparky2::GYRORANGE_500:
292  return 500;
293  case HwSparky2::GYRORANGE_1000:
294  return 1000;
295  case HwSparky2::GYRORANGE_2000:
296  return 2000;
297  default:
298  break;
299  }
300 
301  return 500;
302 }
303 
304 QStringList Sparky2::getAdcNames()
305 {
306  return QStringList() << "Analog CUR"
307  << "Analog VOLT"
308  << "DAC";
309 }
310 
311 bool Sparky2::hasAnnunciator(AnnunciatorType annunc)
312 {
313  switch (annunc) {
315  case ANNUNCIATOR_ALARM:
316  return true;
317  case ANNUNCIATOR_BUZZER:
318  case ANNUNCIATOR_RGB:
319  case ANNUNCIATOR_DAC:
320  break;
321  }
322  return false;
323 }
virtual bool queryCapabilities(BoardCapabilities capability)
Return which capabilities this board has.
Definition: sparky2.cpp:91
qint32 boardType
The numerical board type ID.
Definition: iboardtype.h:284
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 getHwUAVO()
Definition: sparky2.cpp:113
Sparky2()
Sparky2::Sparky2 This is the Sparky board definition.
Definition: sparky2.cpp:38
The USBInfo struct.
Definition: iboardtype.h:62
void addFirmwareUSBInfo(USBInfo info)
Definition: iboardtype.h:277
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type)
Determine if this board supports configuring the receiver.
Definition: sparky2.cpp:131
virtual QPixmap getBoardPicture()
getBoardPicture
Definition: sparky2.cpp:108
virtual bool hasAnnunciator(AnnunciatorType annunc)
Definition: sparky2.cpp:311
void addBootloaderUSBInfo(USBInfo info)
Definition: iboardtype.h:278
HwSparky2 * getSettings()
Get the settings object.
Definition: sparky2.cpp:119
virtual int queryMaxGyroRate()
Query the board for the currently set max rate of the gyro.
Definition: sparky2.cpp:277
virtual bool setInputType(Core::IBoardType::InputType type)
Definition: sparky2.cpp:149
virtual QString shortName()
Definition: sparky2.cpp:80
virtual QString boardDescription()
Definition: sparky2.cpp:85
virtual ~Sparky2()
Definition: sparky2.cpp:76
virtual QStringList getAdcNames()
Definition: sparky2.cpp:304
virtual Core::IBoardType::InputType getInputType()
getInputType get the current input type
Definition: sparky2.cpp:202