2011-02-02 06:28:54 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file configccpmtwidget.h
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @addtogroup GCSPlugins GCS Plugins
|
|
|
|
* @{
|
|
|
|
* @addtogroup ConfigPlugin Config Plugin
|
|
|
|
* @{
|
|
|
|
* @brief ccpm configuration panel
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
#ifndef CONFIGccpmWIDGET_H
|
|
|
|
#define CONFIGccpmWIDGET_H
|
|
|
|
|
|
|
|
#include "ui_ccpm.h"
|
|
|
|
#include "configtaskwidget.h"
|
|
|
|
#include "extensionsystem/pluginmanager.h"
|
|
|
|
#include "uavobjectmanager.h"
|
|
|
|
#include "uavobject.h"
|
|
|
|
#include <QtSvg/QSvgRenderer>
|
|
|
|
#include <QtSvg/QGraphicsSvgItem>
|
2011-06-24 07:38:29 +02:00
|
|
|
#include <QGraphicsEllipseItem>
|
2011-02-02 06:28:54 +01:00
|
|
|
#include <QtGui/QWidget>
|
|
|
|
#include <QList>
|
|
|
|
|
|
|
|
#define CCPM_MAX_SWASH_SERVOS 4
|
|
|
|
|
|
|
|
class Ui_Widget;
|
|
|
|
|
2011-02-05 06:30:42 +01:00
|
|
|
typedef struct {
|
|
|
|
int ServoChannels[CCPM_MAX_SWASH_SERVOS];
|
|
|
|
int Used[CCPM_MAX_SWASH_SERVOS];
|
|
|
|
int Max[CCPM_MAX_SWASH_SERVOS];
|
|
|
|
int Neutral[CCPM_MAX_SWASH_SERVOS];
|
|
|
|
int Min[CCPM_MAX_SWASH_SERVOS];
|
|
|
|
} SwashplateServoSettingsStruct;
|
|
|
|
|
2011-06-14 02:46:53 +02:00
|
|
|
typedef struct {
|
|
|
|
uint SwasplateType:3;
|
|
|
|
uint FirstServoIndex:2;
|
|
|
|
uint CorrectionAngle:9;
|
|
|
|
uint ccpmCollectivePassthroughState:1;
|
|
|
|
uint ccpmLinkCyclicState:1;
|
|
|
|
uint ccpmLinkRollState:1;
|
2011-06-16 06:09:27 +02:00
|
|
|
uint CollectiveChannel:3;//20bits
|
|
|
|
uint SliderValue0:7;
|
|
|
|
uint SliderValue1:7;
|
|
|
|
uint SliderValue2:7;//41bits
|
2011-06-16 06:33:07 +02:00
|
|
|
uint ServoIndexW:4;
|
|
|
|
uint ServoIndexX:4;
|
|
|
|
uint ServoIndexY:4;
|
|
|
|
uint ServoIndexZ:4;//57bits
|
|
|
|
uint padding:7;
|
2011-06-14 06:10:28 +02:00
|
|
|
} __attribute__((packed)) heliGUISettingsStruct;
|
2011-06-14 02:46:53 +02:00
|
|
|
|
2011-06-16 06:09:27 +02:00
|
|
|
typedef union
|
2011-06-14 03:40:39 +02:00
|
|
|
{
|
2011-06-16 06:33:07 +02:00
|
|
|
uint UAVObject[2];//32bits * 2
|
|
|
|
heliGUISettingsStruct heli;//64bits
|
2011-06-14 03:40:39 +02:00
|
|
|
} GUIConfigDataUnion;
|
2011-06-14 02:46:53 +02:00
|
|
|
|
2011-02-02 06:28:54 +01:00
|
|
|
class ConfigccpmWidget: public ConfigTaskWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ConfigccpmWidget(QWidget *parent = 0);
|
|
|
|
~ConfigccpmWidget();
|
|
|
|
|
2011-08-01 14:28:58 +02:00
|
|
|
friend class ConfigAirframeWidget;
|
|
|
|
|
2011-02-02 06:28:54 +01:00
|
|
|
private:
|
|
|
|
Ui_ccpmWidget *m_ccpm;
|
|
|
|
QGraphicsSvgItem *SwashplateImg;
|
|
|
|
QGraphicsSvgItem *CurveImg;
|
|
|
|
//QGraphicsSvgItem *ServoW;
|
|
|
|
//QGraphicsSvgItem *ServoX;
|
|
|
|
//QGraphicsSvgItem *ServoY;
|
|
|
|
//QGraphicsSvgItem *ServoZ;
|
|
|
|
//QGraphicsTextItem *ServoWText;
|
|
|
|
//QGraphicsTextItem *ServoXText;
|
|
|
|
//QGraphicsTextItem *ServoYText;
|
|
|
|
//QGraphicsTextItem *ServoZText;
|
|
|
|
QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS];
|
|
|
|
QGraphicsTextItem *ServosText[CCPM_MAX_SWASH_SERVOS];
|
|
|
|
QGraphicsLineItem *ServoLines[CCPM_MAX_SWASH_SERVOS];
|
2011-06-24 07:38:29 +02:00
|
|
|
QGraphicsEllipseItem *ServosTextCircles[CCPM_MAX_SWASH_SERVOS];
|
2011-02-02 06:28:54 +01:00
|
|
|
QSpinBox *SwashLvlSpinBoxes[CCPM_MAX_SWASH_SERVOS];
|
|
|
|
|
2011-02-05 06:30:42 +01:00
|
|
|
bool SwashLvlConfigurationInProgress;
|
|
|
|
UAVObject::Metadata SwashLvlaccInitialData;
|
2011-02-02 06:28:54 +01:00
|
|
|
int SwashLvlState;
|
2011-02-07 04:05:30 +01:00
|
|
|
int SwashLvlServoInterlock;
|
2011-02-02 06:28:54 +01:00
|
|
|
|
2011-02-05 06:30:42 +01:00
|
|
|
SwashplateServoSettingsStruct oldSwashLvlConfiguration;
|
|
|
|
SwashplateServoSettingsStruct newSwashLvlConfiguration;
|
|
|
|
|
2011-06-16 06:09:27 +02:00
|
|
|
GUIConfigDataUnion GUIConfigData;
|
|
|
|
|
2011-02-02 06:28:54 +01:00
|
|
|
int MixerChannelData[6];
|
|
|
|
int ShowDisclaimer(int messageID);
|
2011-06-07 16:56:16 +02:00
|
|
|
virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget
|
2011-06-16 06:09:27 +02:00
|
|
|
|
2011-06-14 02:46:53 +02:00
|
|
|
bool updatingFromHardware;
|
2011-06-17 07:01:55 +02:00
|
|
|
bool updatingToHardware;
|
2011-02-02 06:28:54 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void ccpmSwashplateUpdate();
|
2011-02-09 06:04:07 +01:00
|
|
|
void ccpmSwashplateRedraw();
|
2011-02-02 06:28:54 +01:00
|
|
|
void UpdateCurveSettings();
|
|
|
|
void GenerateCurve();
|
|
|
|
void UpdateMixer();
|
|
|
|
void UpdateType();
|
|
|
|
void resetMixer(MixerCurveWidget *mixer, int numElements);
|
|
|
|
void UpdateCurveWidgets();
|
|
|
|
void updatePitchCurveValue(QList<double>,double);
|
|
|
|
void updateThrottleCurveValue(QList<double>,double);
|
|
|
|
|
|
|
|
void SwashLvlStartButtonPressed();
|
|
|
|
void SwashLvlNextButtonPressed();
|
|
|
|
void SwashLvlCancelButtonPressed();
|
|
|
|
void SwashLvlFinishButtonPressed();
|
|
|
|
|
2011-09-04 10:09:48 +02:00
|
|
|
void UpdateCCPMOptionsFromUI();
|
|
|
|
void UpdateCCPMUIFromOptions();
|
2011-06-16 06:09:27 +02:00
|
|
|
|
2011-06-14 02:46:53 +02:00
|
|
|
void SetUIComponentVisibilities();
|
2011-06-21 04:40:22 +02:00
|
|
|
void ccpmChannelCheck();
|
2011-06-12 06:17:32 +02:00
|
|
|
|
2011-02-05 06:30:42 +01:00
|
|
|
void enableSwashplateLevellingControl(bool state);
|
|
|
|
void setSwashplateLevel(int percent);
|
|
|
|
void SwashLvlSpinBoxChanged(int value);
|
2011-06-07 16:56:16 +02:00
|
|
|
virtual void refreshValues() {}; // Not used
|
|
|
|
|
2011-02-02 06:28:54 +01:00
|
|
|
public slots:
|
|
|
|
void requestccpmUpdate();
|
|
|
|
void sendccpmUpdate();
|
|
|
|
void saveccpmUpdate();
|
2011-06-07 16:56:16 +02:00
|
|
|
|
2011-02-02 06:28:54 +01:00
|
|
|
protected:
|
|
|
|
void showEvent(QShowEvent *event);
|
|
|
|
void resizeEvent(QResizeEvent *event);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONFIGccpmWIDGET_H
|