dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
sparky.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 "sparky.h"
29 
33 #include "board_usb_ids.h"
34 
35 #include "hwsparky.h"
36 
42 {
43  // Common USB IDs
45  USBInfo(DRONIN_VID_DRONIN_BOOTLOADER, DRONIN_PID_DRONIN_BOOTLOADER, BCD_DEVICE_BOOTLOADER));
47  USBInfo(DRONIN_VID_DRONIN_FIRMWARE, DRONIN_PID_DRONIN_FIRMWARE, BCD_DEVICE_FIRMWARE));
48  // Legacy USB IDs
50  USBInfo(DRONIN_VID_TAULABS_SPARKY, DRONIN_PID_TAULABS_SPARKY, BCD_DEVICE_BOOTLOADER));
52  USBInfo(DRONIN_VID_TAULABS_SPARKY, DRONIN_PID_TAULABS_SPARKY, BCD_DEVICE_FIRMWARE));
53 
54  boardType = 0x88;
55 
56  // Define the bank of channels that are connected to a given timer
57  channelBanks.resize(6);
58  channelBanks[0] = QVector<int>() << 1 << 2; // TIM15
59  channelBanks[1] = QVector<int>() << 3; // TIM1
60  channelBanks[2] = QVector<int>() << 4 << 7 << 9; // TIM3
61  channelBanks[3] = QVector<int>() << 5; // TIM16
62  channelBanks[4] = QVector<int>() << 6 << 10; // TIM2
63  channelBanks[5] = QVector<int>() << 8; // TIM17
64 }
65 
67 {
68 }
69 
71 {
72  return QString("Sparky");
73 }
74 
76 {
77  return QString("The Tau Labs project Sparky boards");
78 }
79 
81 bool Sparky::queryCapabilities(BoardCapabilities capability)
82 {
83  switch (capability) {
89  return true;
90  default:
91  break;
92  }
93 
94  return false;
95 }
96 
98 {
99  return QPixmap(":/taulabs/images/sparky.png");
100 }
101 
103 {
104  return "HwSparky";
105 }
106 
109 {
110  switch (type) {
111  case INPUT_TYPE_PWM:
112  case INPUT_TYPE_UNKNOWN:
113  return false;
114  default:
115  break;
116  }
117 
118  return true;
119 }
120 
127 {
128  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
129  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
130  HwSparky *hwSparky = HwSparky::GetInstance(uavoManager);
131  Q_ASSERT(hwSparky);
132  if (!hwSparky)
133  return false;
134 
135  HwSparky::DataFields settings = hwSparky->getData();
136 
137  switch (type) {
138  case INPUT_TYPE_PPM:
139  settings.RcvrPort = HwSparky::RCVRPORT_PPM;
140  break;
141  case INPUT_TYPE_SBUS:
142  settings.RcvrPort = HwSparky::RCVRPORT_SBUS;
143  break;
145  settings.RcvrPort = HwSparky::RCVRPORT_SBUSNONINVERTED;
146  break;
147  case INPUT_TYPE_DSM:
148  settings.RcvrPort = HwSparky::RCVRPORT_DSM;
149  break;
150  case INPUT_TYPE_IBUS:
151  settings.RcvrPort = HwSparky::RCVRPORT_IBUS;
152  break;
153  case INPUT_TYPE_SRXL:
154  settings.RcvrPort = HwSparky::RCVRPORT_SRXL;
155  break;
156  default:
157  return false;
158  }
159 
160  // Apply these changes
161  hwSparky->setData(settings);
162 
163  return true;
164 }
165 
171 {
172  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
173  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
174  HwSparky *hwSparky = HwSparky::GetInstance(uavoManager);
175  Q_ASSERT(hwSparky);
176  if (!hwSparky)
177  return INPUT_TYPE_UNKNOWN;
178 
179  HwSparky::DataFields settings = hwSparky->getData();
180 
181  switch (settings.RcvrPort) {
182  case HwSparky::RCVRPORT_PPM:
183  return INPUT_TYPE_PPM;
184  case HwSparky::RCVRPORT_SBUS:
185  return INPUT_TYPE_SBUS;
186  case HwSparky::RCVRPORT_SBUSNONINVERTED:
188  case HwSparky::RCVRPORT_DSM:
189  return INPUT_TYPE_DSM;
190  case HwSparky::RCVRPORT_IBUS:
191  return INPUT_TYPE_IBUS;
192  case HwSparky::RCVRPORT_SRXL:
193  return INPUT_TYPE_SRXL;
194  default:
195  break;
196  }
197 
198  switch (settings.FlexiPort) {
199  case HwSparky::FLEXIPORT_DSM:
200  return INPUT_TYPE_DSM;
201  case HwSparky::FLEXIPORT_SBUS:
202  return INPUT_TYPE_SBUS;
203  case HwSparky::FLEXIPORT_SBUSNONINVERTED:
205  case HwSparky::FLEXIPORT_IBUS:
206  return INPUT_TYPE_IBUS;
207  case HwSparky::FLEXIPORT_SRXL:
208  return INPUT_TYPE_SRXL;
209  default:
210  break;
211  }
212 
213  switch (settings.MainPort) {
214  case HwSparky::MAINPORT_DSM:
215  return INPUT_TYPE_DSM;
216  case HwSparky::MAINPORT_SBUS:
217  return INPUT_TYPE_SBUS;
218  case HwSparky::MAINPORT_SBUSNONINVERTED:
220  case HwSparky::MAINPORT_IBUS:
221  return INPUT_TYPE_IBUS;
222  case HwSparky::MAINPORT_SRXL:
223  return INPUT_TYPE_SRXL;
224  default:
225  break;
226  }
227 
228  return INPUT_TYPE_UNKNOWN;
229 }
230 
232 {
233  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
234  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
235  HwSparky *hwSparky = HwSparky::GetInstance(uavoManager);
236  Q_ASSERT(hwSparky);
237  if (!hwSparky)
238  return 0;
239 
240  HwSparky::DataFields settings = hwSparky->getData();
241 
242  switch (settings.GyroRange) {
243  case HwSparky::GYRORANGE_250:
244  return 250;
245  case HwSparky::GYRORANGE_500:
246  return 500;
247  case HwSparky::GYRORANGE_1000:
248  return 1000;
249  case HwSparky::GYRORANGE_2000:
250  return 2000;
251  default:
252  break;
253  }
254 
255  return 500;
256 }
257 
258 QStringList Sparky::getAdcNames()
259 {
260  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
261  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
262  HwSparky *hwSparky = HwSparky::GetInstance(uavoManager);
263  Q_ASSERT(hwSparky);
264  if (!hwSparky)
265  return QStringList();
266 
267  QStringList names;
268  HwSparky::DataFields settings = hwSparky->getData();
269  if (settings.OutPort == HwSparky::OUTPORT_PWM82ADC
270  || settings.OutPort == HwSparky::OUTPORT_PWM72ADCPWM_IN)
271  names << "PWM10"
272  << "PWM9"
273  << "Disabled";
274  else if (settings.OutPort == HwSparky::OUTPORT_PWM73ADC)
275  names << "PWM10"
276  << "PWM9"
277  << "PWM8";
278  else
279  names << "Disabled"
280  << "Disabled"
281  << "Disabled";
282 
283  return names;
284 }
285 
287 {
288  switch (annunc) {
290  case ANNUNCIATOR_ALARM:
291  return true;
292  case ANNUNCIATOR_BUZZER:
293  case ANNUNCIATOR_RGB:
294  case ANNUNCIATOR_DAC:
295  break;
296  }
297  return false;
298 }
virtual QPixmap getBoardPicture()
getBoardPicture
Definition: sparky.cpp:97
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: sparky.cpp:286
InputType
Types of input to configure for the default port.
Definition: iboardtype.h:158
virtual Core::IBoardType::InputType getInputType()
getInputType get the current input type
Definition: sparky.cpp:170
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
virtual QString boardDescription()
Definition: sparky.cpp:75
The USBInfo struct.
Definition: iboardtype.h:62
void addFirmwareUSBInfo(USBInfo info)
Definition: iboardtype.h:277
void addBootloaderUSBInfo(USBInfo info)
Definition: iboardtype.h:278
Sparky()
Sparky::Sparky This is the Sparky board definition.
Definition: sparky.cpp:41
virtual bool setInputType(Core::IBoardType::InputType type)
Definition: sparky.cpp:126
virtual bool queryCapabilities(BoardCapabilities capability)
Return which capabilities this board has.
Definition: sparky.cpp:81
virtual int queryMaxGyroRate()
Query the board for the currently set max rate of the gyro.
Definition: sparky.cpp:231
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type)
Determine if this board supports configuring the receiver.
Definition: sparky.cpp:108
virtual QString shortName()
Definition: sparky.cpp:70
virtual QString getHwUAVO()
Definition: sparky.cpp:102
virtual ~Sparky()
Definition: sparky.cpp:66
virtual QStringList getAdcNames()
Definition: sparky.cpp:258