dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
seppuku.cpp
Go to the documentation of this file.
1 
11 /*
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20  * for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, see <http://www.gnu.org/licenses/>
24  *
25  * Additional note on redistribution: The copyright and license notices above
26  * must be maintained in each individual source file that is a derivative work
27  * of this source file; otherwise redistribution is prohibited.
28  */
29 
31 
32 #include "seppuku.h"
33 #include "hwseppuku.h"
34 #include "seppukuconfiguration.h"
35 #include "board_usb_ids.h"
36 
42 {
43  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
44  uavoManager = pm->getObject<UAVObjectManager>();
45 
46  boardType = 0xA1;
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 
54  channelBanks.resize(4);
55  channelBanks.clear();
56  channelBanks << (QVector<int>() << 1 << 2); // TIM8
57  channelBanks << (QVector<int>() << 3); // TIM14
58  channelBanks << (QVector<int>() << 4 << 5 << 6); // TIM3
59  channelBanks << (QVector<int>() << 7 << 8); // TIM5
60 }
61 
63 {
64 }
65 
67 {
68  return QString("Seppuku");
69 }
70 
72 {
73  return QString(tr("Seppuku running dRonin firmware"));
74 }
75 
77 {
78  switch (capability) {
85  return true;
86  default:
87  break;
88  }
89  return false;
90 }
91 
93 {
94  switch (type) {
95  case INPUT_TYPE_PWM:
96  case INPUT_TYPE_UNKNOWN:
97  return false;
98  default:
99  break;
100  }
101  return true;
102 }
103 
105 {
106  UAVObjectField *rcvrPort = uavoManager->getField(getHwUAVO(), "RcvrPort");
107  if (!rcvrPort)
108  return false;
109 
110  switch (type) {
111  case INPUT_TYPE_DISABLED:
112  rcvrPort->setValue(HwSeppuku::RCVRPORT_DISABLED);
113  break;
114  case INPUT_TYPE_DSM:
115  rcvrPort->setValue(HwSeppuku::RCVRPORT_DSM);
116  break;
117  case INPUT_TYPE_SBUS:
118  rcvrPort->setValue(HwSeppuku::RCVRPORT_SBUS);
119  break;
121  rcvrPort->setValue(HwSeppuku::RCVRPORT_SBUSNONINVERTED);
122  break;
123  case INPUT_TYPE_HOTTSUMD:
124  rcvrPort->setValue(HwSeppuku::RCVRPORT_HOTTSUMD);
125  break;
126  case INPUT_TYPE_HOTTSUMH:
127  rcvrPort->setValue(HwSeppuku::RCVRPORT_HOTTSUMH);
128  break;
129  case INPUT_TYPE_IBUS:
130  rcvrPort->setValue(HwSeppuku::RCVRPORT_IBUS);
131  break;
132  case INPUT_TYPE_PPM:
133  rcvrPort->setValue(HwSeppuku::RCVRPORT_PPM);
134  break;
135  case INPUT_TYPE_SRXL:
136  rcvrPort->setValue(HwSeppuku::RCVRPORT_SRXL);
137  break;
139  rcvrPort->setValue(HwSeppuku::RCVRPORT_TBSCROSSFIRE);
140  break;
141  default:
142  return false;
143  }
144 
145  return true;
146 }
147 
149 {
150  UAVObjectField *rcvrPort = uavoManager->getField(getHwUAVO(), "RcvrPort");
151  if (!rcvrPort)
152  return INPUT_TYPE_UNKNOWN;
153 
154  switch (static_cast<HwSeppuku::RcvrPortOptions>(rcvrPort->getValue().toInt())) {
155  case HwSeppuku::RCVRPORT_DISABLED:
156  return INPUT_TYPE_DISABLED;
157  case HwSeppuku::RCVRPORT_DSM:
158  return INPUT_TYPE_DSM;
159  case HwSeppuku::RCVRPORT_SRXL:
160  return INPUT_TYPE_SRXL;
161  case HwSeppuku::RCVRPORT_HOTTSUMD:
162  return INPUT_TYPE_HOTTSUMD;
163  case HwSeppuku::RCVRPORT_HOTTSUMH:
164  return INPUT_TYPE_HOTTSUMH;
165  case HwSeppuku::RCVRPORT_PPM:
166  return INPUT_TYPE_PPM;
167  case HwSeppuku::RCVRPORT_SBUS:
168  return INPUT_TYPE_SBUS;
169  case HwSeppuku::RCVRPORT_SBUSNONINVERTED:
171  case HwSeppuku::RCVRPORT_IBUS:
172  return INPUT_TYPE_IBUS;
173  case HwSeppuku::RCVRPORT_TBSCROSSFIRE:
175  default:
176  break;
177  }
178 
179  return INPUT_TYPE_UNKNOWN;
180 }
181 
183 {
184  return 2000;
185 }
186 
187 QStringList Seppuku::getAdcNames()
188 {
189  return QStringList() << "V"
190  << "A"
191  << "RSSI"
192  << "Unmarked";
193 }
194 
196 {
197  return QPixmap(":/dronin/images/seppuku.png");
198 }
199 
201 {
202  return "HwSeppuku";
203 }
204 
206 {
207  return ":/dronin/images/seppuku-connection.svg";
208 }
209 
210 QWidget *Seppuku::getBoardConfiguration(QWidget *parent, bool connected)
211 {
212  Q_UNUSED(connected)
213 
214  return new SeppukuConfiguration(parent);
215 }
216 
218 {
219  switch (annunc) {
220  case ANNUNCIATOR_HEARTBEAT: // auxio1, next to uart3 rx, marked "reserved for future use"
221  case ANNUNCIATOR_ALARM:
222  break;
223  case ANNUNCIATOR_BUZZER:
224  case ANNUNCIATOR_RGB:
225  case ANNUNCIATOR_DAC:
226  return true;
227  }
228  return false;
229 }
230 
Seppuku()
Seppuku:Seppuku This is the Seppuku board definition.
Definition: seppuku.cpp:41
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 hasAnnunciator(AnnunciatorType annunc) override
Check if the board has the given type of annunciator.
Definition: seppuku.cpp:217
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
QVariant getValue(int index=0) const
BoardCapabilities
Types of capabilities boards can support.
Definition: iboardtype.h:92
virtual bool setInputType(Core::IBoardType::InputType type) override
Configure the board to use an receiver input type on a port number.
Definition: seppuku.cpp:104
The USBInfo struct.
Definition: iboardtype.h:62
virtual QString getConnectionDiagram() override
getConnectionDiagram get the connection diagram for this board
Definition: seppuku.cpp:205
void addFirmwareUSBInfo(USBInfo info)
Definition: iboardtype.h:277
void addBootloaderUSBInfo(USBInfo info)
Definition: iboardtype.h:278
virtual QPixmap getBoardPicture() override
getBoardPicture
Definition: seppuku.cpp:195
void setValue(const QVariant &data, int index=0)
virtual bool queryCapabilities(BoardCapabilities capability) override
Query capabilities of the board.
Definition: seppuku.cpp:76
virtual QString boardDescription() override
Definition: seppuku.cpp:71
virtual QStringList getAdcNames() override
Definition: seppuku.cpp:187
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type) override
Determine if this board supports configuring the receiver.
Definition: seppuku.cpp:92
virtual int queryMaxGyroRate() override
Query the board for the currently set max rate of the gyro.
Definition: seppuku.cpp:182
virtual QString shortName() override
Definition: seppuku.cpp:66
virtual Core::IBoardType::InputType getInputType() override
getInputType get the current input type
Definition: seppuku.cpp:148
virtual QWidget * getBoardConfiguration(QWidget *parent, bool connected) override
Return a custom configuration widget, if one is provided.
Definition: seppuku.cpp:210
UAVObjectField * getField(const QString &objName, const QString &fieldName, quint32 instId=0)
getField Get a UAV Object field Success is asserted so there is no need to do this again in the calle...
virtual ~Seppuku()
Definition: seppuku.cpp:62
virtual QString getHwUAVO() override
Definition: seppuku.cpp:200