mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-16 08:29:15 +01:00
Merge branch 'thread/OP-1222_FW_Wizard' of ssh://git.openpilot.org/OpenPilot into laurent/OP-1222_FW_Wizard
This commit is contained in:
commit
6f74ffdc8d
@ -82,6 +82,9 @@ bool AirframeInitialTuningPage::validatePage()
|
|||||||
if (ui->templateList->currentRow() >= 0) {
|
if (ui->templateList->currentRow() >= 0) {
|
||||||
templ = ui->templateList->item(ui->templateList->currentRow())->data(Qt::UserRole + 1).value<QJsonObject *>();
|
templ = ui->templateList->item(ui->templateList->currentRow())->data(Qt::UserRole + 1).value<QJsonObject *>();
|
||||||
}
|
}
|
||||||
|
if (getWizard()->getVehicleTemplate() != NULL) {
|
||||||
|
delete getWizard()->getVehicleTemplate();
|
||||||
|
}
|
||||||
getWizard()->setVehicleTemplate(new QJsonObject(*templ));
|
getWizard()->setVehicleTemplate(new QJsonObject(*templ));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -114,8 +117,11 @@ void AirframeInitialTuningPage::updateDescription(QJsonObject *templ)
|
|||||||
if (templ != NULL) {
|
if (templ != NULL) {
|
||||||
QString description;
|
QString description;
|
||||||
description.append("<b>").append(tr("Name of Vehicle: ")).append("</b>").append(templ->value("name").toString()).append("<br>");
|
description.append("<b>").append(tr("Name of Vehicle: ")).append("</b>").append(templ->value("name").toString()).append("<br>");
|
||||||
description.append("<b>").append(tr("Name of Owner: ")).append("</b>").append(templ->value("owner").toString())
|
description.append("<b>").append(tr("Name of Owner: ")).append("</b>").append(templ->value("owner").toString());
|
||||||
.append(" (").append(templ->value("nick").toString()).append(")").append("<br>");
|
if (templ->value("nick") != "") {
|
||||||
|
description.append(" (").append(templ->value("nick").toString()).append(")");
|
||||||
|
}
|
||||||
|
description.append("<br>");
|
||||||
description.append("<b>").append(tr("Size: ")).append("</b>").append(templ->value("size").toString()).append("<br>");
|
description.append("<b>").append(tr("Size: ")).append("</b>").append(templ->value("size").toString()).append("<br>");
|
||||||
description.append("<b>").append(tr("Weight: ")).append("</b>").append(templ->value("weight").toString()).append("<br>");
|
description.append("<b>").append(tr("Weight: ")).append("</b>").append(templ->value("weight").toString()).append("<br>");
|
||||||
description.append("<b>").append(tr("Motor(s): ")).append("</b>").append(templ->value("motor").toString()).append("<br>");
|
description.append("<b>").append(tr("Motor(s): ")).append("</b>").append(templ->value("motor").toString()).append("<br>");
|
||||||
@ -163,19 +169,13 @@ void AirframeInitialTuningPage::loadValidFiles()
|
|||||||
QJsonObject json = templateDoc.object();
|
QJsonObject json = templateDoc.object();
|
||||||
if (json["type"].toInt() == getWizard()->getVehicleType() &&
|
if (json["type"].toInt() == getWizard()->getVehicleType() &&
|
||||||
json["subtype"].toInt() == getWizard()->getVehicleSubType()) {
|
json["subtype"].toInt() == getWizard()->getVehicleSubType()) {
|
||||||
QString nameKey = getTemplateKey(&json);
|
QString uuid = json["uuid"].toString();
|
||||||
int index = 0;
|
if (!m_templates.contains(uuid)) {
|
||||||
while (true) {
|
m_templates[json["uuid"].toString()] = new QJsonObject(json);
|
||||||
if (!m_templates.contains(nameKey)) {
|
|
||||||
m_templates[nameKey] = new QJsonObject(json);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
nameKey = QString("%1 - %2").arg(nameKey).arg(++index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.close();
|
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,15 +185,17 @@ void AirframeInitialTuningPage::setupTemplateList()
|
|||||||
|
|
||||||
item->setData(Qt::UserRole + 1, QVariant::fromValue((QJsonObject *)NULL));
|
item->setData(Qt::UserRole + 1, QVariant::fromValue((QJsonObject *)NULL));
|
||||||
foreach(QString templ, m_templates.keys()) {
|
foreach(QString templ, m_templates.keys()) {
|
||||||
item = new QListWidgetItem(templ, ui->templateList);
|
QJsonObject *json = m_templates[templ];
|
||||||
item->setData(Qt::UserRole + 1, QVariant::fromValue(m_templates[templ]));
|
|
||||||
|
item = new QListWidgetItem(json->value("name").toString(), ui->templateList);
|
||||||
|
item->setData(Qt::UserRole + 1, QVariant::fromValue(json));
|
||||||
}
|
}
|
||||||
ui->templateList->setCurrentRow(0);
|
ui->templateList->setCurrentRow(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AirframeInitialTuningPage::getTemplateKey(QJsonObject *templ)
|
QString AirframeInitialTuningPage::getTemplateKey(QJsonObject *templ)
|
||||||
{
|
{
|
||||||
return QString("%1 - %2").arg(templ->value("nick").toString()).arg(templ->value("name").toString());
|
return QString(templ->value("name").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirframeInitialTuningPage::resizeEvent(QResizeEvent *)
|
void AirframeInitialTuningPage::resizeEvent(QResizeEvent *)
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "gpssettings.h"
|
#include "gpssettings.h"
|
||||||
#include "airspeedsettings.h"
|
#include "airspeedsettings.h"
|
||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
const qint16 VehicleConfigurationHelper::LEGACY_ESC_FREQUENCE = 50;
|
const qint16 VehicleConfigurationHelper::LEGACY_ESC_FREQUENCE = 50;
|
||||||
const qint16 VehicleConfigurationHelper::RAPID_ESC_FREQUENCE = 400;
|
const qint16 VehicleConfigurationHelper::RAPID_ESC_FREQUENCE = 400;
|
||||||
@ -82,6 +83,8 @@ bool VehicleConfigurationHelper::setupVehicle(bool save)
|
|||||||
applyStabilizationConfiguration();
|
applyStabilizationConfiguration();
|
||||||
applyManualControlDefaults();
|
applyManualControlDefaults();
|
||||||
|
|
||||||
|
applyTemplateSettings();
|
||||||
|
|
||||||
bool result = saveChangesToController(save);
|
bool result = saveChangesToController(save);
|
||||||
emit saveProgress(m_modifiedObjects.count() + 1, ++m_progress, result ? tr("Done!") : tr("Failed!"));
|
emit saveProgress(m_modifiedObjects.count() + 1, ++m_progress, result ? tr("Done!") : tr("Failed!"));
|
||||||
return result;
|
return result;
|
||||||
@ -747,6 +750,22 @@ void VehicleConfigurationHelper::applyManualControlDefaults()
|
|||||||
addModifiedObject(mcSettings, tr("Writing manual control defaults"));
|
addModifiedObject(mcSettings, tr("Writing manual control defaults"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VehicleConfigurationHelper::applyTemplateSettings()
|
||||||
|
{
|
||||||
|
if (m_configSource->getVehicleTemplate() != NULL) {
|
||||||
|
QJsonObject *json = m_configSource->getVehicleTemplate();
|
||||||
|
QList<UAVObject *> updatedObjects;
|
||||||
|
m_uavoManager->fromJson(*json, &updatedObjects);
|
||||||
|
foreach(UAVObject * object, updatedObjects) {
|
||||||
|
UAVDataObject *dataObj = dynamic_cast<UAVDataObject *>(object);
|
||||||
|
|
||||||
|
if (dataObj != NULL) {
|
||||||
|
addModifiedObject(dataObj, QString(tr("Writing template settings for %1")).arg(object->getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool VehicleConfigurationHelper::saveChangesToController(bool save)
|
bool VehicleConfigurationHelper::saveChangesToController(bool save)
|
||||||
{
|
{
|
||||||
qDebug() << "Saving modified objects to controller. " << m_modifiedObjects.count() << " objects in found.";
|
qDebug() << "Saving modified objects to controller. " << m_modifiedObjects.count() << " objects in found.";
|
||||||
|
@ -87,6 +87,7 @@ private:
|
|||||||
void applySensorBiasConfiguration();
|
void applySensorBiasConfiguration();
|
||||||
void applyStabilizationConfiguration();
|
void applyStabilizationConfiguration();
|
||||||
void applyManualControlDefaults();
|
void applyManualControlDefaults();
|
||||||
|
void applyTemplateSettings();
|
||||||
|
|
||||||
void applyMixerConfiguration(mixerChannelSettings channels[]);
|
void applyMixerConfiguration(mixerChannelSettings channels[]);
|
||||||
|
|
||||||
|
@ -199,6 +199,8 @@ void VehicleTemplateExportDialog::accept()
|
|||||||
exportObject["propeller"] = ui->Propeller->text();
|
exportObject["propeller"] = ui->Propeller->text();
|
||||||
exportObject["controller"] = ui->Controllers->currentText();
|
exportObject["controller"] = ui->Controllers->currentText();
|
||||||
exportObject["comment"] = ui->Comment->document()->toPlainText();
|
exportObject["comment"] = ui->Comment->document()->toPlainText();
|
||||||
|
QUuid uuid = QUuid::createUuid();
|
||||||
|
exportObject["uuid"] = uuid.toString();
|
||||||
|
|
||||||
QByteArray bytes;
|
QByteArray bytes;
|
||||||
QBuffer buffer(&bytes);
|
QBuffer buffer(&bytes);
|
||||||
@ -209,13 +211,12 @@ void VehicleTemplateExportDialog::accept()
|
|||||||
|
|
||||||
QJsonDocument saveDoc(exportObject);
|
QJsonDocument saveDoc(exportObject);
|
||||||
|
|
||||||
QString fileName = QString("%1/%2/%3-%4-%5-%6.optmpl")
|
QString fileName = QString("%1/%2/%3-%4-%5.optmpl")
|
||||||
.arg(EXPORT_BASE_NAME)
|
.arg(EXPORT_BASE_NAME)
|
||||||
.arg(getTypeDirectory())
|
.arg(getTypeDirectory())
|
||||||
.arg(fixFilenameString(ui->ForumNick->text(), 15))
|
|
||||||
.arg(fixFilenameString(ui->Name->text(), 20))
|
.arg(fixFilenameString(ui->Name->text(), 20))
|
||||||
.arg(fixFilenameString(ui->Type->text(), 30))
|
.arg(fixFilenameString(ui->Type->text(), 30))
|
||||||
.arg(fixFilenameString(QUuid::createUuid().toString().right(12)));
|
.arg(fixFilenameString(uuid.toString().right(12)));
|
||||||
QFile saveFile(fileName);
|
QFile saveFile(fileName);
|
||||||
QDir dir;
|
QDir dir;
|
||||||
dir.mkpath(QFileInfo(saveFile).absoluteDir().absolutePath());
|
dir.mkpath(QFileInfo(saveFile).absoluteDir().absolutePath());
|
||||||
|
@ -540,6 +540,25 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>Type</tabstop>
|
||||||
|
<tabstop>Name</tabstop>
|
||||||
|
<tabstop>Owner</tabstop>
|
||||||
|
<tabstop>ForumNick</tabstop>
|
||||||
|
<tabstop>Size</tabstop>
|
||||||
|
<tabstop>Weight</tabstop>
|
||||||
|
<tabstop>Motor</tabstop>
|
||||||
|
<tabstop>Esc</tabstop>
|
||||||
|
<tabstop>Servo</tabstop>
|
||||||
|
<tabstop>Battery</tabstop>
|
||||||
|
<tabstop>Propeller</tabstop>
|
||||||
|
<tabstop>Controllers</tabstop>
|
||||||
|
<tabstop>Comment</tabstop>
|
||||||
|
<tabstop>ImportButton</tabstop>
|
||||||
|
<tabstop>acceptBtn</tabstop>
|
||||||
|
<tabstop>cancelBtn</tabstop>
|
||||||
|
<tabstop>Photo</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
@ -340,7 +340,7 @@ void UAVObjectManager::toJson(QJsonObject &jsonObject, const QList<UAVObject *>
|
|||||||
jsonObject["objects"] = jObjects;
|
jsonObject["objects"] = jObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVObjectManager::fromJson(const QJsonObject &jsonObject)
|
void UAVObjectManager::fromJson(const QJsonObject &jsonObject, QList<UAVObject *> *updatedObjects)
|
||||||
{
|
{
|
||||||
QJsonArray jObjects = jsonObject["objects"].toArray();
|
QJsonArray jObjects = jsonObject["objects"].toArray();
|
||||||
|
|
||||||
@ -349,6 +349,9 @@ void UAVObjectManager::fromJson(const QJsonObject &jsonObject)
|
|||||||
UAVObject *object = getObject(jObject["name"].toString(), jObject["instance"].toInt());
|
UAVObject *object = getObject(jObject["name"].toString(), jObject["instance"].toInt());
|
||||||
if (object != NULL) {
|
if (object != NULL) {
|
||||||
object->fromJson(jObject);
|
object->fromJson(jObject);
|
||||||
|
if (updatedObjects != NULL) {
|
||||||
|
updatedObjects->append(object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
void toJson(QJsonObject &jsonObject, JSON_EXPORT_OPTION what = JSON_EXPORT_ALL);
|
void toJson(QJsonObject &jsonObject, JSON_EXPORT_OPTION what = JSON_EXPORT_ALL);
|
||||||
void toJson(QJsonObject &jsonObject, const QList<QString> &objectsToExport);
|
void toJson(QJsonObject &jsonObject, const QList<QString> &objectsToExport);
|
||||||
void toJson(QJsonObject &jsonObject, const QList<UAVObject *> &objectsToExport);
|
void toJson(QJsonObject &jsonObject, const QList<UAVObject *> &objectsToExport);
|
||||||
void fromJson(const QJsonObject &jsonObject);
|
void fromJson(const QJsonObject &jsonObject, QList<UAVObject *> *updatedObjects = NULL);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newObject(UAVObject *obj);
|
void newObject(UAVObject *obj);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<xml>
|
<xml>
|
||||||
<object name="Mpu6000Settings" singleinstance="true" settings="true" category="Sensors">
|
<object name="Mpu6000Settings" singleinstance="true" settings="true" category="Sensors">
|
||||||
<description>Settings for the @ref MPU6000 sensor used on CC3D and Revolution. Reboot the board for this to takes effect</description>
|
<description>Settings for the @ref MPU6000 sensor used on CC3D and Revolution. Reboot the board for this to takes effect</description>
|
||||||
<field name="GyroScale" units="deg/s" type="enum" elements="1" defaultvalue="Scale_1000">
|
<field name="GyroScale" units="deg/s" type="enum" elements="1" defaultvalue="Scale_2000">
|
||||||
<options>
|
<options>
|
||||||
<option>Scale_250</option>
|
<option>Scale_250</option>
|
||||||
<option>Scale_500</option>
|
<option>Scale_500</option>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user