dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
lux.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 "lux.h"
30 
34 #include "board_usb_ids.h"
35 
36 #include "hwlux.h"
37 #include "luxconfiguration.h"
38 
43 Lux::Lux(void)
44 {
45  // Common USB IDs
47  USBInfo(DRONIN_VID_DRONIN_BOOTLOADER, DRONIN_PID_DRONIN_BOOTLOADER, BCD_DEVICE_BOOTLOADER));
49  USBInfo(DRONIN_VID_DRONIN_FIRMWARE, DRONIN_PID_DRONIN_FIRMWARE, BCD_DEVICE_FIRMWARE));
50  // Legacy USB IDs
52  USBInfo(DRONIN_VID_LUMENIER_LUX, DRONIN_PID_LUMENIER_LUX, BCD_DEVICE_BOOTLOADER));
54  USBInfo(DRONIN_VID_LUMENIER_LUX, DRONIN_PID_LUMENIER_LUX, BCD_DEVICE_FIRMWARE));
55 
56  boardType = 0xCA;
57 
58  // Define the bank of channels that are connected to a given timer
59  channelBanks.resize(1);
60  channelBanks[0] = QVector<int>() << 1 << 2 << 3 << 4; // T3
61 }
62 
64 {
65 }
66 
67 QString Lux::shortName()
68 {
69  return QString("Lux");
70 }
71 
73 {
74  return QString("Lumenier Lux hardware by ReadError.");
75 }
76 
79 {
80  switch (capability) {
84  return true;
85  default:
86  break;
87  }
88 
89  return false;
90 }
91 
93 {
94  return QPixmap(":/brotronics/images/lux.png");
95 }
96 
97 QString Lux::getHwUAVO()
98 {
99  return "HwLux";
100 }
101 
104 {
105  switch (type) {
106  case INPUT_TYPE_PWM:
107  case INPUT_TYPE_UNKNOWN:
108  return false;
109  default:
110  break;
111  }
112 
113  return true;
114 }
115 
122 {
123  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
124  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
125  HwLux *hwLux = HwLux::GetInstance(uavoManager);
126  Q_ASSERT(hwLux);
127  if (!hwLux)
128  return false;
129 
130  HwLux::DataFields settings = hwLux->getData();
131 
132  switch (type) {
133  case INPUT_TYPE_PPM:
134  // always enabled, do nothing
135  break;
136  case INPUT_TYPE_SBUS:
137  settings.RxPort = HwLux::RXPORT_SBUS;
138  break;
140  settings.RxPort = HwLux::RXPORT_SBUSNONINVERTED;
141  break;
142  case INPUT_TYPE_DSM:
143  settings.RxPort = HwLux::RXPORT_DSM;
144  break;
145  case INPUT_TYPE_HOTTSUMD:
146  settings.RxPort = HwLux::RXPORT_HOTTSUMD;
147  break;
148  case INPUT_TYPE_HOTTSUMH:
149  settings.RxPort = HwLux::RXPORT_HOTTSUMH;
150  break;
151  case INPUT_TYPE_IBUS:
152  settings.RxPort = HwLux::RXPORT_IBUS;
153  break;
154  case INPUT_TYPE_SRXL:
155  settings.RxPort = HwLux::RXPORT_SRXL;
156  break;
158  settings.RxPort = HwLux::RXPORT_TBSCROSSFIRE;
159  break;
160  default:
161  return false;
162  }
163 
164  // Apply these changes
165  hwLux->setData(settings);
166 
167  return true;
168 }
169 
175 {
176  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
177  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
178  HwLux *hwLux = HwLux::GetInstance(uavoManager);
179  Q_ASSERT(hwLux);
180  if (!hwLux)
181  return INPUT_TYPE_UNKNOWN;
182 
183  HwLux::DataFields settings = hwLux->getData();
184 
185  switch (settings.RxPort) {
186  case HwLux::RXPORT_SBUS:
187  return INPUT_TYPE_SBUS;
188  case HwLux::RXPORT_SBUSNONINVERTED:
190  case HwLux::RXPORT_DSM:
191  return INPUT_TYPE_DSM;
192  case HwLux::RXPORT_HOTTSUMD:
193  return INPUT_TYPE_HOTTSUMD;
194  case HwLux::RXPORT_HOTTSUMH:
195  return INPUT_TYPE_HOTTSUMH;
196  case HwLux::RXPORT_IBUS:
197  return INPUT_TYPE_IBUS;
198  case HwLux::RXPORT_SRXL:
199  return INPUT_TYPE_SRXL;
200  case HwLux::RXPORT_TBSCROSSFIRE:
202  default:
203  break;
204  }
205 
206  switch (settings.Uart2) {
207  case HwLux::UART2_DSM:
208  return INPUT_TYPE_DSM;
209  case HwLux::UART2_SBUS:
210  return INPUT_TYPE_SBUS;
211  case HwLux::UART2_SBUSNONINVERTED:
213  case HwLux::UART2_IBUS:
214  return INPUT_TYPE_IBUS;
215  case HwLux::UART2_SRXL:
216  return INPUT_TYPE_SRXL;
217  case HwLux::UART2_HOTTSUMD:
218  return INPUT_TYPE_HOTTSUMD;
219  case HwLux::UART2_HOTTSUMH:
220  return INPUT_TYPE_HOTTSUMH;
221  case HwLux::UART2_TBSCROSSFIRE:
223  default:
224  break;
225  }
226 
227  switch (settings.Uart3) {
228  case HwLux::UART3_DSM:
229  return INPUT_TYPE_DSM;
230  case HwLux::UART3_SBUS:
231  return INPUT_TYPE_SBUS;
232  case HwLux::UART3_SBUSNONINVERTED:
234  case HwLux::UART3_IBUS:
235  return INPUT_TYPE_IBUS;
236  case HwLux::UART3_SRXL:
237  return INPUT_TYPE_SRXL;
238  case HwLux::UART3_HOTTSUMD:
239  return INPUT_TYPE_HOTTSUMD;
240  case HwLux::UART3_HOTTSUMH:
241  return INPUT_TYPE_HOTTSUMH;
242  case HwLux::UART3_TBSCROSSFIRE:
244  default:
245  break;
246  }
247 
248  return INPUT_TYPE_PPM;
249 }
250 
252 {
253  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
254  UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
255  HwLux *hwLux = HwLux::GetInstance(uavoManager);
256  Q_ASSERT(hwLux);
257  if (!hwLux)
258  return 0;
259 
260  HwLux::DataFields settings = hwLux->getData();
261 
262  switch (settings.GyroRange) {
263  case HwLux::GYRORANGE_250:
264  return 250;
265  case HwLux::GYRORANGE_500:
266  return 500;
267  case HwLux::GYRORANGE_1000:
268  return 1000;
269  case HwLux::GYRORANGE_2000:
270  return 2000;
271  default:
272  break;
273  }
274 
275  return 500;
276 }
277 
278 QStringList Lux::getAdcNames()
279 {
280  return QStringList() << "VBAT"
281  << "Current"
282  << "RSSI";
283 }
284 
285 QWidget *Lux::getBoardConfiguration(QWidget *parent, bool connected)
286 {
287  Q_UNUSED(connected);
288  return new LuxConfiguration(parent);
289 }
290 
292 {
293  switch (annunc) {
295  case ANNUNCIATOR_ALARM:
296  case ANNUNCIATOR_BUZZER:
297  return true;
298  case ANNUNCIATOR_RGB:
299  case ANNUNCIATOR_DAC:
300  break;
301  }
302  return false;
303 }
virtual QString getHwUAVO()
Definition: lux.cpp:97
qint32 boardType
The numerical board type ID.
Definition: iboardtype.h:284
virtual QWidget * getBoardConfiguration(QWidget *parent, bool connected)
getBoardConfiguration
Definition: lux.cpp:285
InputType
Types of input to configure for the default port.
Definition: iboardtype.h:158
virtual int queryMaxGyroRate()
Query the board for the currently set max rate of the gyro.
Definition: lux.cpp:251
QVector< QVector< qint32 > > channelBanks
The channel groups that are driven by timers.
Definition: iboardtype.h:287
virtual bool setInputType(Core::IBoardType::InputType type)
Definition: lux.cpp:121
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
virtual bool queryCapabilities(BoardCapabilities capability)
Return which capabilities this board has.
Definition: lux.cpp:78
The USBInfo struct.
Definition: iboardtype.h:62
void addFirmwareUSBInfo(USBInfo info)
Definition: iboardtype.h:277
void addBootloaderUSBInfo(USBInfo info)
Definition: iboardtype.h:278
virtual bool hasAnnunciator(AnnunciatorType annunc)
Check if the board has the given type of annunciator.
Definition: lux.cpp:291
Lux()
Lux:Lux This is the Lux board definition.
Definition: lux.cpp:43
virtual QPixmap getBoardPicture()
getBoardPicture
Definition: lux.cpp:92
virtual Core::IBoardType::InputType getInputType()
getInputType get the current input type
Definition: lux.cpp:174
virtual QString shortName()
Definition: lux.cpp:67
virtual QString boardDescription()
Definition: lux.cpp:72
virtual ~Lux()
Definition: lux.cpp:63
virtual bool isInputConfigurationSupported(Core::IBoardType::InputType type)
Determine if this board supports configuring the receiver.
Definition: lux.cpp:103
virtual QStringList getAdcNames()
Definition: lux.cpp:278