dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
brainre1.cpp
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 
27 #include "brainre1.h"
28 
32 #include "board_usb_ids.h"
33 
34 #include "brainre1configuration.h"
35 #include "hwbrainre1.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_BRAINFPV_BRAIN, DRONIN_PID_BRAINFPV_BRAIN, BCD_DEVICE_BOOTLOADER));
52  USBInfo(DRONIN_VID_BRAINFPV_BRAIN, DRONIN_PID_BRAINFPV_BRAIN, BCD_DEVICE_FIRMWARE));
53 
54  boardType = 0x8B;
55 }
56 
58 {
59 }
60 
62 {
63  return QString("BrainRE1");
64 }
65 
67 {
68  return QString("BrainFPV RE1 - FPV Racing Flight Controller");
69 }
70 
73 {
74  switch (capability) {
79  return true;
80  default:
81  return false;
82  }
83 }
84 
86 {
87  return QPixmap(":/brainfpv/images/brainre1.png");
88 }
89 
92 {
93  switch (type) {
94  case INPUT_TYPE_PWM:
95  case INPUT_TYPE_UNKNOWN:
96  return false;
97  default:
98  break;
99  }
100 
101  return true;
102 }
103 
105 {
106  return "HwBrainRE1";
107 }
108 
116 {
117  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
118  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
119  HwBrainRE1 *hwBrainRE1 = HwBrainRE1::GetInstance(uavoManager);
120  Q_ASSERT(hwBrainRE1);
121  if (!hwBrainRE1)
122  return false;
123 
124  HwBrainRE1::DataFields settings = hwBrainRE1->getData();
125 
126  switch (type) {
127  case INPUT_TYPE_PPM:
128  settings.RxPort = HwBrainRE1::RXPORT_PPM;
129  break;
130  case INPUT_TYPE_SBUS:
131  settings.RxPort = HwBrainRE1::RXPORT_SBUS;
132  break;
134  settings.RxPort = HwBrainRE1::RXPORT_SBUSNONINVERTED;
135  break;
136  case INPUT_TYPE_DSM:
137  settings.RxPort = HwBrainRE1::RXPORT_DSM;
138  break;
139  case INPUT_TYPE_HOTTSUMD:
140  settings.RxPort = HwBrainRE1::RXPORT_HOTTSUMD;
141  break;
142  case INPUT_TYPE_HOTTSUMH:
143  settings.RxPort = HwBrainRE1::RXPORT_HOTTSUMH;
144  break;
145  case INPUT_TYPE_IBUS:
146  settings.RxPort = HwBrainRE1::RXPORT_IBUS;
147  break;
148  case INPUT_TYPE_SRXL:
149  settings.RxPort = HwBrainRE1::RXPORT_SRXL;
150  break;
152  settings.RxPort = HwBrainRE1::RXPORT_TBSCROSSFIRE;
153  break;
154  default:
155  return false;
156  }
157 
158  // Apply these changes
159  hwBrainRE1->setData(settings);
160 
161  return true;
162 }
163 
170 {
171  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
172  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
173  HwBrainRE1 *hwBrainRE1 = HwBrainRE1::GetInstance(uavoManager);
174  Q_ASSERT(hwBrainRE1);
175  if (!hwBrainRE1)
176  return INPUT_TYPE_UNKNOWN;
177 
178  HwBrainRE1::DataFields settings = hwBrainRE1->getData();
179 
180  switch (settings.RxPort) {
181  case HwBrainRE1::RXPORT_PPM:
182  return INPUT_TYPE_PPM;
183  case HwBrainRE1::RXPORT_SBUS:
184  return INPUT_TYPE_SBUS;
185  case HwBrainRE1::RXPORT_SBUSNONINVERTED:
187  case HwBrainRE1::RXPORT_DSM:
188  return INPUT_TYPE_DSM;
189  case HwBrainRE1::RXPORT_HOTTSUMD:
190  return INPUT_TYPE_HOTTSUMD;
191  case HwBrainRE1::RXPORT_HOTTSUMH:
192  return INPUT_TYPE_HOTTSUMH;
193  case HwBrainRE1::RXPORT_IBUS:
194  return INPUT_TYPE_IBUS;
195  case HwBrainRE1::RXPORT_SRXL:
196  return INPUT_TYPE_SRXL;
197  case HwBrainRE1::RXPORT_TBSCROSSFIRE:
199  default:
200  break;
201  }
202 
203  switch (settings.SerialPort) {
204  case HwBrainRE1::SERIALPORT_TBSCROSSFIRE:
206  default:
207  break;
208  }
209 
210  switch (settings.MultiPortSerial) {
211  case HwBrainRE1::MULTIPORTSERIAL_TBSCROSSFIRE:
213  default:
214  break;
215  }
216 
217  if (settings.MultiPortMode == HwBrainRE1::MULTIPORTMODE_DUALSERIAL4PWM)
218  {
219  switch (settings.MultiPortSerial2) {
220  case HwBrainRE1::MULTIPORTSERIAL2_TBSCROSSFIRE:
222  default:
223  break;
224  }
225  }
226 
227  return INPUT_TYPE_UNKNOWN;
228 }
229 
231 {
232  return 2000;
233 }
234 
236 {
237  return QStringList() << "I"
238  << "V"
239  << "R";
240 }
241 
242 QWidget *BrainRE1::getBoardConfiguration(QWidget *parent, bool connected)
243 {
244  Q_UNUSED(connected);
245  return new BrainRE1Configuration(parent);
246 }
247 
248 QVector<QVector<int>> BrainRE1::getChannelBanks()
249 {
250  QVector<QVector<int>> banks;
251 
252  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
253  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
254  HwBrainRE1 *hwBrainRE1 = HwBrainRE1::GetInstance(uavoManager);
255  if (!hwBrainRE1 || (hwBrainRE1->getMultiPortMode() == 0)) {
256  banks.resize(4);
257  banks[0] = QVector<int>() << 1 << 2 << 3 << 4; // TIM5
258  banks[1] = QVector<int>() << 5; // TIM1
259  banks[2] = QVector<int>() << 6; // TIM2
260  banks[3] = QVector<int>() << 7 << 8; // TIM8
261  } else {
262  banks.resize(3);
263  banks[0] = QVector<int>() << 1 << 2; // TIM5
264  banks[1] = QVector<int>() << 3; // TIM1
265  banks[2] = QVector<int>() << 4; // TIM2
266  }
267 
268  return banks;
269 }
270 
272 {
273  switch (annunc) {
275  case ANNUNCIATOR_ALARM:
276  case ANNUNCIATOR_BUZZER:
277  case ANNUNCIATOR_RGB:
278  return true;
279  case ANNUNCIATOR_DAC:
280  break;
281  }
282  return false;
283 }
virtual QString getHwUAVO()
Definition: brainre1.cpp:104
virtual Core::IBoardType::InputType getInputType()
getInputOnPort get the current input type
Definition: brainre1.cpp:169
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
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
virtual QWidget * getBoardConfiguration(QWidget *parent, bool connected)
Return a custom configuration widget, if one is provided.
Definition: brainre1.cpp:242
virtual QPixmap getBoardPicture()
getBoardPicture
Definition: brainre1.cpp:85
BoardCapabilities
Types of capabilities boards can support.
Definition: iboardtype.h:92
virtual int queryMaxGyroRate()
Query the board for the currently set max rate of the gyro.
Definition: brainre1.cpp:230
virtual QVector< QVector< int > > getChannelBanks()
Get banks of output PWM channels banks on the board.
Definition: brainre1.cpp:248
virtual QStringList getAdcNames()
Definition: brainre1.cpp:235
virtual bool hasAnnunciator(AnnunciatorType annunc)
Check if the board has the given type of annunciator.
Definition: brainre1.cpp:271
The USBInfo struct.
Definition: iboardtype.h:62
void addFirmwareUSBInfo(USBInfo info)
Definition: iboardtype.h:277
void addBootloaderUSBInfo(USBInfo info)
Definition: iboardtype.h:278
virtual ~BrainRE1()
Definition: brainre1.cpp:57
virtual QString boardDescription()
Definition: brainre1.cpp:66
virtual QString shortName()
Definition: brainre1.cpp:61
virtual bool setInputType(Core::IBoardType::InputType type)
Definition: brainre1.cpp:115
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type)
Determine if this board supports configuring the receiver.
Definition: brainre1.cpp:91
BrainRE1()
Brain::Brain This is the Brain board definition.
Definition: brainre1.cpp:41
virtual bool queryCapabilities(BoardCapabilities capability)
Return which capabilities this board has.
Definition: brainre1.cpp:72