mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Several bugfixes.
Created "simple wizard" button witch bypasses the sticks identification screen. Small bugfix to fix GCS crashing if trying to upload a firmware bigger then the HW capacity.
This commit is contained in:
parent
7bf9f4e817
commit
0d92e00125
@ -45,8 +45,6 @@ ConfigCCAttitudeWidget::ConfigCCAttitudeWidget(QWidget *parent) :
|
||||
setupButtons(ui->applyButton,ui->saveButton);
|
||||
addUAVObject("AttitudeSettings");
|
||||
|
||||
UAVObject * settings = AttitudeSettings::GetInstance(getObjectManager());
|
||||
|
||||
// Connect the help button
|
||||
connect(ui->ccAttitudeHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
||||
addUAVObjectToWidgetRelation("AttitudeSettings","ZeroDuringArming",ui->zeroGyroBiasOnArming);
|
||||
|
@ -71,7 +71,11 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
}
|
||||
goWizard=new QPushButton(tr("Start Wizard"),this);
|
||||
m_config->advancedPage->layout()->addWidget(goWizard);
|
||||
connect(goWizard,SIGNAL(clicked()),this,SLOT(goToWizard()));
|
||||
connect(goWizard,SIGNAL(clicked()),this,SLOT(goToNormalWizard()));
|
||||
goSimpleWizard=new QPushButton(tr("Start Simple Wizard"),this);
|
||||
m_config->advancedPage->layout()->addWidget(goSimpleWizard);
|
||||
connect(goSimpleWizard,SIGNAL(clicked()),this,SLOT(goToSimpleWizard()));
|
||||
|
||||
connect(m_config->wzNext,SIGNAL(clicked()),this,SLOT(wzNext()));
|
||||
connect(m_config->wzCancel,SIGNAL(clicked()),this,SLOT(wzCancel()));
|
||||
connect(m_config->wzBack,SIGNAL(clicked()),this,SLOT(wzBack()));
|
||||
@ -92,9 +96,10 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
addUAVObjectToWidgetRelation("ManualControlSettings","Stabilization3Settings",m_config->fmsSsPos3Yaw,"Yaw");
|
||||
|
||||
addUAVObjectToWidgetRelation("ManualControlSettings","Arming",m_config->armControl);
|
||||
addUAVObjectToWidgetRelation("ManualControlSettings","armTimeout",m_config->armTimeout,0,1000);
|
||||
addUAVObject("ManualControlCommand");
|
||||
addUAVObjectToWidgetRelation("ManualControlSettings","ArmedTimeout",m_config->armTimeout,0,1000);
|
||||
connect( ManualControlCommand::GetInstance(getObjectManager()),SIGNAL(objectUpdated(UAVObject*)),this,SLOT(moveFMSlider()));
|
||||
addWidget(goWizard);
|
||||
addWidget(goSimpleWizard);
|
||||
enableControls(false);
|
||||
|
||||
populateWidgets();
|
||||
@ -252,7 +257,16 @@ void ConfigInputWidget::openHelp()
|
||||
|
||||
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Input+Configuration", QUrl::StrictMode) );
|
||||
}
|
||||
|
||||
void ConfigInputWidget::goToSimpleWizard()
|
||||
{
|
||||
isSimple=true;
|
||||
goToWizard();
|
||||
}
|
||||
void ConfigInputWidget::goToNormalWizard()
|
||||
{
|
||||
isSimple=false;
|
||||
goToWizard();
|
||||
}
|
||||
void ConfigInputWidget::goToWizard()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
@ -357,7 +371,7 @@ void ConfigInputWidget::setupWizardWidget(int step)
|
||||
m_config->checkBoxesLayout->layout()->addWidget(mode2);
|
||||
wizardStep=wizardChooseMode;
|
||||
}
|
||||
else if(step==wizardIdentifySticks)
|
||||
else if(step==wizardIdentifySticks && !isSimple)
|
||||
{
|
||||
usedChannels.clear();
|
||||
if(wizardStep==wizardChooseMode)
|
||||
@ -380,8 +394,19 @@ void ConfigInputWidget::setupWizardWidget(int step)
|
||||
connect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
||||
m_config->wzNext->setEnabled(false);
|
||||
}
|
||||
else if(step==wizardIdentifyCenter)
|
||||
else if(step==wizardIdentifyCenter || (isSimple && step==wizardIdentifySticks))
|
||||
{
|
||||
if(wizardStep==wizardChooseMode)
|
||||
{
|
||||
QRadioButton * mode=qobject_cast<QRadioButton *>(extraWidgets.at(0));
|
||||
if(mode->isChecked())
|
||||
transmitterMode=mode1;
|
||||
else
|
||||
transmitterMode=mode2;
|
||||
delete extraWidgets.at(0);
|
||||
delete extraWidgets.at(1);
|
||||
extraWidgets.clear();
|
||||
}
|
||||
setTxMovement(centerAll);
|
||||
if(wizardStep==wizardIdentifySticks)
|
||||
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
||||
@ -409,10 +434,17 @@ void ConfigInputWidget::setupWizardWidget(int step)
|
||||
}
|
||||
manualSettingsObj->setData(manualSettingsData);
|
||||
}
|
||||
foreach (QWidget * wd, extraWidgets)
|
||||
if(wizardStep==wizardIdentifyInverted)
|
||||
{
|
||||
if(wd)
|
||||
delete wd;
|
||||
foreach(QWidget * wd,extraWidgets)
|
||||
{
|
||||
QCheckBox * cb=qobject_cast<QCheckBox *>(wd);
|
||||
if(cb)
|
||||
{
|
||||
disconnect(cb,SIGNAL(toggled(bool)),this,SLOT(invertControls()));
|
||||
delete cb;
|
||||
}
|
||||
}
|
||||
}
|
||||
extraWidgets.clear();
|
||||
disconnect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
||||
@ -423,7 +455,7 @@ void ConfigInputWidget::setupWizardWidget(int step)
|
||||
mdata.flightTelemetryUpdatePeriod = 150;
|
||||
manualCommandObj->setMetadata(mdata);
|
||||
manualSettingsData=manualSettingsObj->getData();
|
||||
for(int i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
||||
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
||||
{
|
||||
manualSettingsData.ChannelMin[i]=manualSettingsData.ChannelNeutral[i];
|
||||
manualSettingsData.ChannelMax[i]=manualSettingsData.ChannelNeutral[i];
|
||||
@ -460,8 +492,11 @@ void ConfigInputWidget::setupWizardWidget(int step)
|
||||
{
|
||||
QCheckBox * cb=qobject_cast<QCheckBox *>(wd);
|
||||
if(cb)
|
||||
{
|
||||
disconnect(cb,SIGNAL(toggled(bool)),this,SLOT(invertControls()));
|
||||
delete cb;
|
||||
}
|
||||
}
|
||||
wizardStep=wizardFinish;
|
||||
extraWidgets.clear();
|
||||
m_config->wzText->setText(QString(tr("You have completed this wizard, please check below if the picture below mimics your sticks movement.\n"
|
||||
@ -537,7 +572,7 @@ void ConfigInputWidget::identifyControls()
|
||||
void ConfigInputWidget::identifyLimits()
|
||||
{
|
||||
manualCommandData=manualCommandObj->getData();
|
||||
for(int i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
||||
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
||||
{
|
||||
if(manualSettingsData.ChannelMin[i]>manualCommandData.Channel[i])
|
||||
manualSettingsData.ChannelMin[i]=manualCommandData.Channel[i];
|
||||
@ -878,7 +913,10 @@ void ConfigInputWidget::dimOtherControls(bool value)
|
||||
void ConfigInputWidget::enableControls(bool enable)
|
||||
{
|
||||
if(goWizard)
|
||||
{
|
||||
goWizard->setEnabled(enable);
|
||||
goSimpleWizard->setEnabled(enable);
|
||||
}
|
||||
ConfigTaskWidget::enableControls(enable);
|
||||
|
||||
}
|
||||
@ -890,10 +928,11 @@ void ConfigInputWidget::invertControls()
|
||||
{
|
||||
QCheckBox * cb=qobject_cast<QCheckBox *>(wd);
|
||||
if(cb)
|
||||
{
|
||||
if(cb->isChecked())
|
||||
{
|
||||
int index=manualSettingsObj->getFields().at(0)->getElementNames().indexOf(cb->text());
|
||||
if((cb->isChecked() && (manualSettingsData.ChannelMax[index]>manualSettingsData.ChannelMin[index])) ||
|
||||
(!cb->isChecked() && (manualSettingsData.ChannelMax[index]<manualSettingsData.ChannelMin[index])))
|
||||
{
|
||||
qint16 aux;
|
||||
aux=manualSettingsData.ChannelMax[index];
|
||||
manualSettingsData.ChannelMax[index]=manualSettingsData.ChannelMin[index];
|
||||
@ -903,20 +942,19 @@ void ConfigInputWidget::invertControls()
|
||||
}
|
||||
manualSettingsObj->setData(manualSettingsData);
|
||||
}
|
||||
void ConfigInputWidget::refreshWidgetsValues()
|
||||
void ConfigInputWidget::moveFMSlider()
|
||||
{
|
||||
ConfigTaskWidget::refreshWidgetsValues();
|
||||
manualSettingsData = manualSettingsObj->getData();
|
||||
manualCommandData=manualCommandObj->getData();
|
||||
uint chIndex = manualSettingsData.ChannelNumber[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE];
|
||||
ManualControlSettings::DataFields manualSettingsDataPriv = manualSettingsObj->getData();
|
||||
ManualControlCommand::DataFields manualCommandDataPriv=manualCommandObj->getData();
|
||||
uint chIndex = manualSettingsDataPriv.ChannelNumber[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE];
|
||||
if (chIndex < 8) {
|
||||
float valueScaled;
|
||||
|
||||
int chMin = manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE];
|
||||
int chMax = manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE];
|
||||
int chNeutral = manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE];
|
||||
int chMin = manualSettingsDataPriv.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE];
|
||||
int chMax = manualSettingsDataPriv.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE];
|
||||
int chNeutral = manualSettingsDataPriv.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE];
|
||||
|
||||
int value = manualCommandData.Channel[chIndex];
|
||||
int value = manualCommandDataPriv.Channel[chIndex];
|
||||
if ((chMax > chMin && value >= chNeutral) || (chMin > chMax && value <= chNeutral))
|
||||
{
|
||||
if (chMax != chNeutral)
|
||||
|
@ -82,7 +82,7 @@ private:
|
||||
QEventLoop * loop;
|
||||
bool skipflag;
|
||||
|
||||
int currentCommand;
|
||||
uint currentCommand;
|
||||
|
||||
ManualControlCommand * manualCommandObj;
|
||||
ManualControlCommand::DataFields manualCommandData;
|
||||
@ -117,23 +117,27 @@ private:
|
||||
void resetTxControls();
|
||||
void setMoveFromCommand(int command);
|
||||
QPushButton * goWizard;
|
||||
QPushButton * goSimpleWizard;
|
||||
bool isSimple;
|
||||
void goToWizard();
|
||||
private slots:
|
||||
void wzNext();
|
||||
void wzBack();
|
||||
void wzCancel();
|
||||
void goToWizard();
|
||||
void goToNormalWizard();
|
||||
void goToSimpleWizard();
|
||||
void openHelp();
|
||||
void identifyControls();
|
||||
void identifyLimits();
|
||||
void moveTxControls();
|
||||
void moveSticks();
|
||||
void dimOtherControls(bool value);
|
||||
void moveFMSlider();
|
||||
void invertControls();
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
virtual void enableControls(bool enable);
|
||||
protected slots:
|
||||
virtual void refreshWidgetsValues();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
|
||||
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),smartsave(NULL),dirty(false)
|
||||
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false)
|
||||
{
|
||||
pm = ExtensionSystem::PluginManager::instance();
|
||||
objManager = pm->getObject<UAVObjectManager>();
|
||||
@ -72,7 +72,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
|
||||
ow->scale=scale;
|
||||
objOfInterest.append(ow);
|
||||
if(obj)
|
||||
smartsave->addObject(obj);
|
||||
smartsave->addObject((UAVDataObject*)obj);
|
||||
if(widget==NULL)
|
||||
{
|
||||
// do nothing
|
||||
@ -148,11 +148,14 @@ double ConfigTaskWidget::listMean(QList<double> list)
|
||||
|
||||
void ConfigTaskWidget::onAutopilotDisconnect()
|
||||
{
|
||||
isConnected=false;
|
||||
enableControls(false);
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::onAutopilotConnect()
|
||||
{
|
||||
dirty=false;
|
||||
isConnected=true;
|
||||
enableControls(true);
|
||||
refreshWidgetsValues();
|
||||
}
|
||||
@ -262,7 +265,10 @@ void ConfigTaskWidget::setDirty(bool value)
|
||||
}
|
||||
bool ConfigTaskWidget::isDirty()
|
||||
{
|
||||
if(isConnected)
|
||||
return dirty;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::refreshValues()
|
||||
|
@ -79,6 +79,7 @@ private slots:
|
||||
virtual void refreshValues();
|
||||
virtual void updateObjectsFromWidgets();
|
||||
private:
|
||||
bool isConnected;
|
||||
QStringList objectsList;
|
||||
QList <objectToWidget*> objOfInterest;
|
||||
ExtensionSystem::PluginManager *pm;
|
||||
|
@ -24,8 +24,11 @@ void smartSaveButton::processClick()
|
||||
bool error=false;
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>();
|
||||
foreach(UAVObject * obj,objects)
|
||||
foreach(UAVDataObject * obj,objects)
|
||||
{
|
||||
UAVObject::Metadata mdata= obj->getMetadata();
|
||||
if(mdata.gcsAccess==UAVObject::ACCESS_READONLY)
|
||||
continue;
|
||||
up_result=false;
|
||||
current_object=obj;
|
||||
for(int i=0;i<3;++i)
|
||||
@ -35,9 +38,9 @@ void smartSaveButton::processClick()
|
||||
connect(&timer,SIGNAL(timeout()),&loop,SLOT(quit()));
|
||||
obj->updated();
|
||||
timer.start(1000);
|
||||
qDebug()<<"begin loop";
|
||||
//qDebug()<<"begin loop";
|
||||
loop.exec();
|
||||
qDebug()<<"end loop";
|
||||
//qDebug()<<"end loop";
|
||||
timer.stop();
|
||||
disconnect(obj,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(transaction_finished(UAVObject*, bool)));
|
||||
disconnect(&timer,SIGNAL(timeout()),&loop,SLOT(quit()));
|
||||
@ -46,15 +49,17 @@ void smartSaveButton::processClick()
|
||||
}
|
||||
if(up_result==false)
|
||||
{
|
||||
//qDebug()<<"Object upload error:"<<obj->getName();
|
||||
error=true;
|
||||
continue;
|
||||
}
|
||||
sv_result=false;
|
||||
current_objectID=obj->getObjID();
|
||||
if(save)
|
||||
if(save && (obj->isSettings()))
|
||||
{
|
||||
for(int i=0;i<3;++i)
|
||||
{
|
||||
//qDebug()<<"try to save:"<<obj->getName();
|
||||
connect(utilMngr,SIGNAL(saveCompleted(int,bool)),this,SLOT(saving_finished(int,bool)));
|
||||
connect(&timer,SIGNAL(timeout()),&loop,SLOT(quit()));
|
||||
utilMngr->saveObjectToSD(obj);
|
||||
@ -85,12 +90,12 @@ void smartSaveButton::processClick()
|
||||
emit endOp();
|
||||
}
|
||||
|
||||
void smartSaveButton::setObjects(QList<UAVObject *> list)
|
||||
void smartSaveButton::setObjects(QList<UAVDataObject *> list)
|
||||
{
|
||||
objects=list;
|
||||
}
|
||||
|
||||
void smartSaveButton::addObject(UAVObject * obj)
|
||||
void smartSaveButton::addObject(UAVDataObject * obj)
|
||||
{
|
||||
if(!objects.contains(obj))
|
||||
objects.append(obj);
|
||||
@ -114,7 +119,7 @@ void smartSaveButton::saving_finished(int id, bool result)
|
||||
if(id==current_objectID)
|
||||
{
|
||||
sv_result=result;
|
||||
qDebug()<<"saving_finished result="<<result;
|
||||
//qDebug()<<"saving_finished result="<<result;
|
||||
loop.quit();
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ public:
|
||||
Q_OBJECT
|
||||
public:
|
||||
smartSaveButton(QPushButton * update,QPushButton * save);
|
||||
void setObjects(QList<UAVObject *>);
|
||||
void addObject(UAVObject *);
|
||||
void setObjects(QList<UAVDataObject *>);
|
||||
void addObject(UAVDataObject *);
|
||||
void clearObjects();
|
||||
signals:
|
||||
void preProcessOperations();
|
||||
@ -34,11 +34,11 @@ private:
|
||||
QPushButton *bupdate;
|
||||
QPushButton *bsave;
|
||||
quint32 current_objectID;
|
||||
UAVObject * current_object;
|
||||
UAVDataObject * current_object;
|
||||
bool up_result;
|
||||
bool sv_result;
|
||||
QEventLoop loop;
|
||||
QList<UAVObject *> objects;
|
||||
QList<UAVDataObject *> objects;
|
||||
protected:
|
||||
public slots:
|
||||
void enableControls(bool value);
|
||||
|
@ -303,6 +303,9 @@ void deviceWidget::loadFirmware()
|
||||
myDevice->youdont->setChecked(false);
|
||||
QByteArray desc = loadedFW.right(100);
|
||||
QPixmap px;
|
||||
if(loadedFW.length()>m_dfu->devices[deviceID].SizeOfCode)
|
||||
myDevice->lblCRCL->setText(tr("Can't calculate, file too big for device"));
|
||||
else
|
||||
myDevice->lblCRCL->setText( QString::number(DFUObject::CRCFromQBArray(loadedFW,m_dfu->devices[deviceID].SizeOfCode)));
|
||||
//myDevice->lblFirmwareSizeL->setText(QString("Firmware size: ")+QVariant(loadedFW.length()).toString()+ QString(" bytes"));
|
||||
if (populateLoadedStructuredDescription(desc))
|
||||
|
@ -956,7 +956,7 @@ quint32 DFUObject::CRC32WideFast(quint32 Crc, quint32 Size, quint32 *Buffer)
|
||||
*/
|
||||
quint32 DFUObject::CRCFromQBArray(QByteArray array, quint32 Size)
|
||||
{
|
||||
int pad=Size-array.length();
|
||||
quint32 pad=Size-array.length();
|
||||
array.append(QByteArray(pad,255));
|
||||
quint32 t[Size/4];
|
||||
for(int x=0;x<array.length()/4;x++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user