dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
revolution.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  * Additional note on redistribution: The copyright and license notices above
29  * must be maintained in each individual source file that is a derivative work
30  * of this source file; otherwise redistribution is prohibited.
31  */
32 
33 #include "revolution.h"
34 
38 #include "board_usb_ids.h"
39 
40 #include "hwrevolution.h"
41 
47 {
48  // Common USB IDs
50  USBInfo(DRONIN_VID_DRONIN_BOOTLOADER, DRONIN_PID_DRONIN_BOOTLOADER, BCD_DEVICE_BOOTLOADER));
52  USBInfo(DRONIN_VID_DRONIN_FIRMWARE, DRONIN_PID_DRONIN_FIRMWARE, BCD_DEVICE_FIRMWARE));
53  // Legacy USB IDs
54  addBootloaderUSBInfo(USBInfo(DRONIN_VID_OPENPILOT_REVOLUTION, DRONIN_PID_OPENPILOT_REVOLUTION,
56  addFirmwareUSBInfo(USBInfo(DRONIN_VID_OPENPILOT_REVOLUTION, DRONIN_PID_OPENPILOT_REVOLUTION,
58 
59  boardType = 0x09;
60 
61  // Define the bank of channels that are connected to a given timer
62  channelBanks.resize(6);
63  channelBanks[0] = QVector<int>() << 1 << 2; // Tim3
64  channelBanks[1] = QVector<int>() << 3; // Tim9
65  channelBanks[2] = QVector<int>() << 4; // Tim2
66  channelBanks[3] = QVector<int>() << 5 << 6; // Tim5
67  channelBanks[4] = QVector<int>() << 7 << 12; // Tim12
68  channelBanks[5] = QVector<int>() << 8 << 9 << 10 << 11; // Tim8
69 
70  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
71  uavoUtilManager = pm->getObject<UAVObjectUtilManager>();
72 }
73 
75 {
76 }
77 
79 {
80  return 0x84;
81 }
82 
84 {
85  return QString("Revolution");
86 }
87 
89 {
90  return QString("The OpenPilot project Revolution board");
91 }
92 
95 {
96  switch (capability) {
103  return true;
104  default:
105  break;
106  }
107 
108  return false;
109 }
110 
112 {
113  return QPixmap(":/openpilot/images/revolution.png");
114 }
115 
117 {
118  return "HwRevolution";
119 }
120 
122 HwRevolution *Revolution::getSettings()
123 {
124  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
125  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
126 
127  HwRevolution *hwRevolution = HwRevolution::GetInstance(uavoManager);
128  Q_ASSERT(hwRevolution);
129 
130  return hwRevolution;
131 }
134 {
135  switch (type) {
136  case INPUT_TYPE_UNKNOWN:
137  return false;
138  default:
139  break;
140  }
141 
142  return true;
143 }
144 
151 {
152  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
153  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
154  HwRevolution *hwRevolution = HwRevolution::GetInstance(uavoManager);
155  Q_ASSERT(hwRevolution);
156  if (!hwRevolution)
157  return false;
158 
159  HwRevolution::DataFields settings = hwRevolution->getData();
160 
161  switch (type) {
162  case INPUT_TYPE_PPM:
163  settings.RxPort = HwRevolution::RXPORT_PPM;
164  break;
165  case INPUT_TYPE_PWM:
166  settings.RxPort = HwRevolution::RXPORT_PWM;
167  break;
168  case INPUT_TYPE_SBUS:
169  settings.MainPort = HwRevolution::MAINPORT_SBUS;
170  break;
172  settings.MainPort = HwRevolution::MAINPORT_SBUSNONINVERTED;
173  break;
174  case INPUT_TYPE_DSM:
175  settings.FlexiPort = HwRevolution::FLEXIPORT_DSM;
176  break;
177  case INPUT_TYPE_HOTTSUMD:
178  settings.FlexiPort = HwRevolution::FLEXIPORT_HOTTSUMD;
179  break;
180  case INPUT_TYPE_HOTTSUMH:
181  settings.FlexiPort = HwRevolution::FLEXIPORT_HOTTSUMH;
182  break;
183  case INPUT_TYPE_IBUS:
184  settings.FlexiPort = HwRevolution::FLEXIPORT_IBUS;
185  break;
186  case INPUT_TYPE_SRXL:
187  settings.FlexiPort = HwRevolution::FLEXIPORT_SRXL;
188  break;
190  settings.FlexiPort = HwRevolution::FLEXIPORT_TBSCROSSFIRE;
191  break;
192  default:
193  return false;
194  }
195 
196  // Apply these changes
197  hwRevolution->setData(settings);
198 
199  return true;
200 }
201 
207 {
208  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
209  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
210  HwRevolution *hwRevolution = HwRevolution::GetInstance(uavoManager);
211  Q_ASSERT(hwRevolution);
212  if (!hwRevolution)
213  return INPUT_TYPE_UNKNOWN;
214 
215  HwRevolution::DataFields settings = hwRevolution->getData();
216 
217  switch (settings.MainPort) {
218  case HwRevolution::MAINPORT_DSM:
219  return INPUT_TYPE_DSM;
220  case HwRevolution::MAINPORT_HOTTSUMD:
221  return INPUT_TYPE_HOTTSUMD;
222  case HwRevolution::MAINPORT_HOTTSUMH:
223  return INPUT_TYPE_HOTTSUMH;
224  case HwRevolution::MAINPORT_SBUS:
225  return INPUT_TYPE_SBUS;
226  case HwRevolution::MAINPORT_SBUSNONINVERTED:
228  case HwRevolution::MAINPORT_IBUS:
229  return INPUT_TYPE_IBUS;
230  case HwRevolution::MAINPORT_SRXL:
231  return INPUT_TYPE_SRXL;
232  case HwRevolution::MAINPORT_TBSCROSSFIRE:
234  default:
235  break;
236  }
237 
238  switch (settings.FlexiPort) {
239  case HwRevolution::FLEXIPORT_DSM:
240  return INPUT_TYPE_DSM;
241  case HwRevolution::FLEXIPORT_HOTTSUMD:
242  return INPUT_TYPE_HOTTSUMD;
243  case HwRevolution::FLEXIPORT_HOTTSUMH:
244  return INPUT_TYPE_HOTTSUMH;
245  case HwRevolution::FLEXIPORT_SBUSNONINVERTED:
247  case HwRevolution::FLEXIPORT_IBUS:
248  return INPUT_TYPE_IBUS;
249  case HwRevolution::FLEXIPORT_SRXL:
250  return INPUT_TYPE_SRXL;
251  case HwRevolution::FLEXIPORT_TBSCROSSFIRE:
253  default:
254  break;
255  }
256 
257  switch (settings.RxPort) {
258  case HwRevolution::RXPORT_PPM:
259  case HwRevolution::RXPORT_PPMPWM:
260  case HwRevolution::RXPORT_PPMOUTPUTS:
261  case HwRevolution::RXPORT_PPMUART:
262  return INPUT_TYPE_PPM;
263  case HwRevolution::RXPORT_PWM:
264  return INPUT_TYPE_PWM;
265  case HwRevolution::RXPORT_UART:
266  switch (settings.RxPortUsart) {
267  case HwRevolution::RXPORTUSART_DSM:
268  return INPUT_TYPE_DSM;
269  case HwRevolution::RXPORTUSART_HOTTSUMD:
270  return INPUT_TYPE_HOTTSUMD;
271  case HwRevolution::RXPORTUSART_HOTTSUMH:
272  return INPUT_TYPE_HOTTSUMH;
273  case HwRevolution::RXPORTUSART_SBUSNONINVERTED:
275  case HwRevolution::RXPORTUSART_IBUS:
276  return INPUT_TYPE_IBUS;
277  case HwRevolution::RXPORTUSART_SRXL:
278  return INPUT_TYPE_SRXL;
279  case HwRevolution::RXPORTUSART_TBSCROSSFIRE:
281  default:
282  break;
283  }
284  break;
285  default:
286  break;
287  }
288 
289  return INPUT_TYPE_UNKNOWN;
290 }
291 
293 {
294  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
295  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
296  HwRevolution *hwRevolution = HwRevolution::GetInstance(uavoManager);
297  Q_ASSERT(hwRevolution);
298  if (!hwRevolution)
299  return 0;
300 
301  HwRevolution::DataFields settings = hwRevolution->getData();
302 
303  switch (settings.GyroRange) {
304  case HwRevolution::GYRORANGE_250:
305  return 250;
306  case HwRevolution::GYRORANGE_500:
307  return 500;
308  case HwRevolution::GYRORANGE_1000:
309  return 1000;
310  case HwRevolution::GYRORANGE_2000:
311  return 2000;
312  default:
313  break;
314  }
315 
316  return 2000;
317 }
318 
320 {
321  return QStringList() << "Pwr Sen Pin 3"
322  << "Pwr Sen Pin 4";
323 }
324 
326 {
327  switch (annunc) {
329  case ANNUNCIATOR_RGB:
330  return true;
331  case ANNUNCIATOR_BUZZER:
332  /* TODO: would be nice to have a distinct "revision" for this */
333  case ANNUNCIATOR_ALARM:
334  if (uavoUtilManager->getBoardRevision() == 3)
335  return true;
336  else
337  break;
338  case ANNUNCIATOR_DAC:
339  break;
340  }
341  return false;
342 }
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
virtual bool queryCapabilities(BoardCapabilities capability)
Return which capabilities this board has.
Definition: revolution.cpp:94
virtual bool hasAnnunciator(AnnunciatorType annunc)
Check if the board has the given type of annunciator.
Definition: revolution.cpp:325
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type)
Determine if this board supports configuring the receiver.
Definition: revolution.cpp:133
BoardCapabilities
Types of capabilities boards can support.
Definition: iboardtype.h:92
virtual QString getHwUAVO()
Definition: revolution.cpp:116
virtual int minBootLoaderVersion()
Returns the minimum bootloader version required.
Definition: revolution.cpp:78
The USBInfo struct.
Definition: iboardtype.h:62
virtual Core::IBoardType::InputType getInputType()
getInputType get the current input type
Definition: revolution.cpp:206
void addFirmwareUSBInfo(USBInfo info)
Definition: iboardtype.h:277
void addBootloaderUSBInfo(USBInfo info)
Definition: iboardtype.h:278
virtual int queryMaxGyroRate()
Query the board for the currently set max rate of the gyro.
Definition: revolution.cpp:292
virtual QStringList getAdcNames()
Definition: revolution.cpp:319
virtual QPixmap getBoardPicture()
getBoardPicture
Definition: revolution.cpp:111
HwRevolution * getSettings()
Get the settings object.
Definition: revolution.cpp:122
virtual bool setInputType(Core::IBoardType::InputType type)
Definition: revolution.cpp:150
Revolution()
Revolution::Revolution This is the Revolution board definition.
Definition: revolution.cpp:46
virtual QString boardDescription()
Definition: revolution.cpp:88
virtual ~Revolution()
Definition: revolution.cpp:74
virtual QString shortName()
Definition: revolution.cpp:83
int getBoardRevision()
Get the connected board hardware revision.