dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
matek405.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 
29 #include "matek405.h"
30 
34 #include "board_usb_ids.h"
35 
36 #include "hwmatek405.h"
37 
43 {
44  // Common USB IDs
46  USBInfo(DRONIN_VID_DRONIN_BOOTLOADER, DRONIN_PID_DRONIN_BOOTLOADER, BCD_DEVICE_BOOTLOADER));
48  USBInfo(DRONIN_VID_DRONIN_FIRMWARE, DRONIN_PID_DRONIN_FIRMWARE, BCD_DEVICE_FIRMWARE));
49 
50  boardType = 0x95;
51 
52  // Define the bank of channels that are connected to a given timer
53  channelBanks.resize(5);
54  channelBanks[0] = QVector<int>() << 1;
55  channelBanks[1] = QVector<int>() << 2<< 3 << 4;
56  channelBanks[2] = QVector<int>() << 5;
57  channelBanks[3] = QVector<int>() << 6;
58  channelBanks[4] = QVector<int>() << 7;
59 }
60 
62 {
63 }
64 
66 {
67  return QString("MATEK405");
68 }
69 
71 {
72  return QString("The MATEK405 board");
73 }
74 
77 {
78  switch (capability) {
84  return true;
85  default:
86  break;
87  }
88 
89  return false;
90 }
91 
93 {
94  return QPixmap(":/matek/images/matek405.png");
95 }
96 
99 {
100  switch (type) {
101  case INPUT_TYPE_PWM:
102  case INPUT_TYPE_UNKNOWN:
103  return false;
104  default:
105  break;
106  }
107 
108  return true;
109 }
110 
112 {
113  return "HwMatek405";
114 }
115 
122 {
123  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
124  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
125  HwMatek405 *hwMatek405 = HwMatek405::GetInstance(uavoManager);
126  Q_ASSERT(hwMatek405);
127  if (!hwMatek405)
128  return false;
129 
130  HwMatek405::DataFields settings = hwMatek405->getData();
131 
132  switch (type) {
133  case INPUT_TYPE_PPM:
134  settings.PPM_Receiver = HwMatek405::PPM_RECEIVER_ENABLED;
135  break;
136  case INPUT_TYPE_HOTTSUMD:
137  settings.Uart2 = HwMatek405::UART2_HOTTSUMD;
138  break;
139  case INPUT_TYPE_HOTTSUMH:
140  settings.Uart2 = HwMatek405::UART2_HOTTSUMH;
141  break;
142  case INPUT_TYPE_SBUS:
143  settings.Uart2 = HwMatek405::UART2_SBUS;
144  break;
146  settings.Uart2 = HwMatek405::UART2_SBUSNONINVERTED;
147  break;
148  case INPUT_TYPE_IBUS:
149  settings.Uart2 = HwMatek405::UART2_IBUS;
150  break;
151  case INPUT_TYPE_DSM:
152  settings.Uart2 = HwMatek405::UART2_DSM;
153  break;
154  case INPUT_TYPE_SRXL:
155  settings.Uart2 = HwMatek405::UART2_SRXL;
156  break;
158  settings.Uart2 = HwMatek405::UART2_TBSCROSSFIRE;
159  break;
160  default:
161  return false;
162  }
163 
164  // Apply these changes
165  hwMatek405->setData(settings);
166 
167  return true;
168 }
169 
175 {
176  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
177  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
178  HwMatek405 *hwMatek405 = HwMatek405::GetInstance(uavoManager);
179  Q_ASSERT(hwMatek405);
180  if (!hwMatek405)
181  return INPUT_TYPE_UNKNOWN;
182 
183  HwMatek405::DataFields settings = hwMatek405->getData();
184 
185  switch (settings.PPM_Receiver) {
186  case HwMatek405::PPM_RECEIVER_ENABLED:
187  return INPUT_TYPE_PPM;
188  default:
189  break;
190  }
191 
192  switch (settings.Uart2) {
193  case HwMatek405::UART2_HOTTSUMD:
194  return INPUT_TYPE_HOTTSUMD;
195  case HwMatek405::UART2_HOTTSUMH:
196  return INPUT_TYPE_HOTTSUMH;
197  case HwMatek405::UART2_SBUS:
198  return INPUT_TYPE_SBUS;
199  case HwMatek405::UART2_SBUSNONINVERTED:
201  case HwMatek405::UART2_IBUS:
202  return INPUT_TYPE_IBUS;
203  case HwMatek405::UART2_SRXL:
204  return INPUT_TYPE_SRXL;
205  case HwMatek405::UART2_TBSCROSSFIRE:
207  default:
208  break;
209  }
210 
211  return INPUT_TYPE_UNKNOWN;
212 }
213 
215 {
216  return 2000;
217 }
218 
220 {
221  return QStringList() << "Current" << "Voltage" << "RSSI";
222 }
223 
225 {
226  switch (annunc) {
228  case ANNUNCIATOR_ALARM:
229  case ANNUNCIATOR_BUZZER:
230  case ANNUNCIATOR_RGB:
231  case ANNUNCIATOR_DAC:
232  return true;
233  }
234  return false;
235 }
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
virtual ~MATEK405()
Definition: matek405.cpp:61
QVector< QVector< qint32 > > channelBanks
The channel groups that are driven by timers.
Definition: iboardtype.h:287
virtual bool hasAnnunciator(AnnunciatorType annunc)
Check if the board has the given type of annunciator.
Definition: matek405.cpp:224
virtual QString boardDescription()
Definition: matek405.cpp:70
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
The USBInfo struct.
Definition: iboardtype.h:62
void addFirmwareUSBInfo(USBInfo info)
Definition: iboardtype.h:277
virtual int queryMaxGyroRate()
Query the board for the currently set max rate of the gyro.
Definition: matek405.cpp:214
void addBootloaderUSBInfo(USBInfo info)
Definition: iboardtype.h:278
virtual QString shortName()
Definition: matek405.cpp:65
virtual QPixmap getBoardPicture()
getBoardPicture
Definition: matek405.cpp:92
virtual QStringList getAdcNames()
Definition: matek405.cpp:219
MATEK405()
MATEK405::MATEK405 This is the MATEK405 board definition.
Definition: matek405.cpp:42
virtual Core::IBoardType::InputType getInputType()
getInputOnPort get the current input type
Definition: matek405.cpp:174
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type)
Determine if this board supports configuring the receiver.
Definition: matek405.cpp:98
virtual QString getHwUAVO()
Definition: matek405.cpp:111
virtual bool setInputType(Core::IBoardType::InputType type)
Definition: matek405.cpp:121
virtual bool queryCapabilities(BoardCapabilities capability)
Return which capabilities this board has.
Definition: matek405.cpp:76