dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
dtfc.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 "dtfc.h"
34 
38 #include "board_usb_ids.h"
39 
40 #include "hwdtfc.h"
41 #include "dtfcconfiguration.h"
42 
48 {
49  // Common USB IDs
51  USBInfo(DRONIN_VID_DRONIN_BOOTLOADER, DRONIN_PID_DRONIN_BOOTLOADER, BCD_DEVICE_BOOTLOADER));
53  USBInfo(DRONIN_VID_DRONIN_FIRMWARE, DRONIN_PID_DRONIN_FIRMWARE, BCD_DEVICE_FIRMWARE));
54  // Legacy USB IDs
56  USBInfo(DRONIN_VID_DTFAIR_DTFC, DRONIN_PID_DTFAIR_DTFC, BCD_DEVICE_BOOTLOADER));
58  USBInfo(DRONIN_VID_DTFAIR_DTFC, DRONIN_PID_DTFAIR_DTFC, BCD_DEVICE_FIRMWARE));
59 
60  boardType = 0xD7;
61 
62  // Define the bank of channels that are connected to a given timer
63  channelBanks.resize(2);
64  channelBanks[0] = QVector<int>() << 1 << 2; // TIM4
65  channelBanks[1] = QVector<int>() << 3 << 4 << 5 << 6; // TIM2
66 }
67 
69 {
70 }
71 
72 QString Dtfc::shortName()
73 {
74  return QString("DTFc");
75 }
76 
78 {
79  return QString("DTFc Flight Controller");
80 }
81 
84 {
85  switch (capability) {
90  return true;
91  default:
92  break;
93  }
94 
95  return false;
96 }
97 
99 {
100  return QPixmap(":/dtf/images/dtfc.png");
101 }
102 
104 {
105  return "HwDtfc";
106 }
107 
110 {
111  switch (type) {
112  case INPUT_TYPE_PWM:
113  case INPUT_TYPE_UNKNOWN:
114  return false;
115  default:
116  break;
117  }
118 
119  return true;
120 }
121 
128 {
129  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
130  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
131  HwDtfc *hwDtfc = HwDtfc::GetInstance(uavoManager);
132  Q_ASSERT(hwDtfc);
133  if (!hwDtfc)
134  return false;
135 
136  HwDtfc::DataFields settings = hwDtfc->getData();
137 
138  switch (type) {
139  case INPUT_TYPE_PPM:
140  settings.RcvrPort = HwDtfc::RCVRPORT_PPM;
141  break;
142  case INPUT_TYPE_SBUS:
143  settings.RcvrPort = HwDtfc::RCVRPORT_SBUS;
144  break;
146  settings.RcvrPort = HwDtfc::RCVRPORT_SBUSNONINVERTED;
147  break;
148  case INPUT_TYPE_DSM:
149  settings.RcvrPort = HwDtfc::RCVRPORT_DSM;
150  break;
151  case INPUT_TYPE_HOTTSUMD:
152  settings.RcvrPort = HwDtfc::RCVRPORT_HOTTSUMD;
153  break;
154  case INPUT_TYPE_HOTTSUMH:
155  settings.RcvrPort = HwDtfc::RCVRPORT_HOTTSUMH;
156  break;
157  case INPUT_TYPE_IBUS:
158  settings.RcvrPort = HwDtfc::RCVRPORT_IBUS;
159  break;
160  case INPUT_TYPE_SRXL:
161  settings.RcvrPort = HwDtfc::RCVRPORT_SRXL;
162  break;
164  settings.RcvrPort = HwDtfc::RCVRPORT_TBSCROSSFIRE;
165  break;
166  default:
167  return false;
168  }
169 
170  hwDtfc->setData(settings);
171 
172  return true;
173 }
174 
180 {
181  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
182  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
183  HwDtfc *hwDtfc = HwDtfc::GetInstance(uavoManager);
184  Q_ASSERT(hwDtfc);
185  if (!hwDtfc)
186  return INPUT_TYPE_UNKNOWN;
187 
188  HwDtfc::DataFields settings = hwDtfc->getData();
189 
190  switch (settings.RcvrPort) {
191  case HwDtfc::RCVRPORT_PPM:
192  return INPUT_TYPE_PPM;
193  case HwDtfc::RCVRPORT_SBUS:
194  return INPUT_TYPE_SBUS;
195  case HwDtfc::RCVRPORT_SBUSNONINVERTED:
197  case HwDtfc::RCVRPORT_DSM:
198  return INPUT_TYPE_DSM;
199  case HwDtfc::RCVRPORT_HOTTSUMD:
200  return INPUT_TYPE_HOTTSUMD;
201  case HwDtfc::RCVRPORT_HOTTSUMH:
202  return INPUT_TYPE_HOTTSUMH;
203  case HwDtfc::RCVRPORT_IBUS:
204  return INPUT_TYPE_IBUS;
205  case HwDtfc::RCVRPORT_SRXL:
206  return INPUT_TYPE_SRXL;
207  case HwDtfc::RCVRPORT_TBSCROSSFIRE:
209  default:
210  break;
211  }
212 
213  switch (settings.Uart1) {
214  case HwDtfc::UART1_SBUS:
215  return INPUT_TYPE_SBUS;
216  case HwDtfc::UART1_SBUSNONINVERTED:
218  case HwDtfc::UART1_DSM:
219  return INPUT_TYPE_DSM;
220  case HwDtfc::UART1_HOTTSUMD:
221  return INPUT_TYPE_HOTTSUMD;
222  case HwDtfc::UART1_HOTTSUMH:
223  return INPUT_TYPE_HOTTSUMH;
224  case HwDtfc::UART1_IBUS:
225  return INPUT_TYPE_IBUS;
226  case HwDtfc::UART1_SRXL:
227  return INPUT_TYPE_SRXL;
228  case HwDtfc::UART1_TBSCROSSFIRE:
230  default:
231  break;
232  }
233 
234  switch (settings.Uart2) {
235  case HwDtfc::UART2_SBUS:
236  return INPUT_TYPE_SBUS;
237  case HwDtfc::UART2_SBUSNONINVERTED:
239  case HwDtfc::UART2_DSM:
240  return INPUT_TYPE_DSM;
241  case HwDtfc::UART2_HOTTSUMD:
242  return INPUT_TYPE_HOTTSUMD;
243  case HwDtfc::UART2_HOTTSUMH:
244  return INPUT_TYPE_HOTTSUMH;
245  case HwDtfc::UART2_IBUS:
246  return INPUT_TYPE_IBUS;
247  case HwDtfc::UART2_SRXL:
248  return INPUT_TYPE_SRXL;
249  case HwDtfc::UART2_TBSCROSSFIRE:
251  default:
252  break;
253  }
254 
255  return INPUT_TYPE_UNKNOWN;
256 }
257 
259 {
260  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
261  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
262  HwDtfc *hwDtfc = HwDtfc::GetInstance(uavoManager);
263  Q_ASSERT(hwDtfc);
264  if (!hwDtfc)
265  return 0;
266 
267  HwDtfc::DataFields settings = hwDtfc->getData();
268 
269  switch (settings.GyroRange) {
270  case HwDtfc::GYRORANGE_250:
271  return 250;
272  case HwDtfc::GYRORANGE_500:
273  return 500;
274  case HwDtfc::GYRORANGE_1000:
275  return 1000;
276  case HwDtfc::GYRORANGE_2000:
277  return 2000;
278  default:
279  break;
280  }
281 
282  return 500;
283 }
284 
285 QStringList Dtfc::getAdcNames()
286 {
287  return QStringList() << "Current"
288  << "Battery";
289 }
290 
291 QWidget *Dtfc::getBoardConfiguration(QWidget *parent, bool connected)
292 {
293  Q_UNUSED(connected);
294  return new DtfcConfiguration(parent);
295 }
296 
298 {
299  switch (annunc) {
301  case ANNUNCIATOR_ALARM:
302  case ANNUNCIATOR_BUZZER:
303  return true;
304  case ANNUNCIATOR_RGB:
305  case ANNUNCIATOR_DAC:
306  break;
307  }
308  return false;
309 }
qint32 boardType
The numerical board type ID.
Definition: iboardtype.h:284
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type)
Determine if this board supports configuring the receiver.
Definition: dtfc.cpp:109
virtual QPixmap getBoardPicture()
getBoardPicture
Definition: dtfc.cpp:98
virtual Core::IBoardType::InputType getInputType()
getInputOnPort get the current input type
Definition: dtfc.cpp:179
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 QStringList getAdcNames()
Definition: dtfc.cpp:285
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
Dtfc()
Dtfc:Dtfc This is the DTFc board definition.
Definition: dtfc.cpp:47
virtual QString getHwUAVO()
Definition: dtfc.cpp:103
BoardCapabilities
Types of capabilities boards can support.
Definition: iboardtype.h:92
virtual bool queryCapabilities(BoardCapabilities capability)
Return which capabilities this board has.
Definition: dtfc.cpp:83
The USBInfo struct.
Definition: iboardtype.h:62
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: dtfc.cpp:258
virtual QString shortName()
Definition: dtfc.cpp:72
virtual QString boardDescription()
Definition: dtfc.cpp:77
virtual bool setInputType(Core::IBoardType::InputType type)
Definition: dtfc.cpp:127
virtual QWidget * getBoardConfiguration(QWidget *parent, bool connected)
getBoardConfiguration
Definition: dtfc.cpp:291
virtual ~Dtfc()
Definition: dtfc.cpp:68
virtual bool hasAnnunciator(AnnunciatorType annunc)
Check if the board has the given type of annunciator.
Definition: dtfc.cpp:297