mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-1504 Added VehicleName to SystemSettings and a GUI in Vehicle configuration to set it.
The name is restricted to 20 chars to save resources.
This commit is contained in:
parent
657ae91f86
commit
1b027d0e7a
@ -20,13 +20,13 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
@ -61,7 +61,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<widget class="QLineEdit" name="nameEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -78,10 +78,10 @@
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>10</number>
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter name of vehicle. Max 10 characters.</string>
|
||||
<string>Enter name of vehicle. Max 20 characters.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -242,7 +242,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>820</width>
|
||||
<height>427</height>
|
||||
<height>435</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
|
@ -121,6 +121,10 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
m_aircraft->saveAircraftToRAM->setVisible(false);
|
||||
}
|
||||
|
||||
SystemSettings *syssettings = SystemSettings::GetInstance(getObjectManager());
|
||||
Q_ASSERT(syssettings);
|
||||
m_aircraft->nameEdit->setMaxLength(syssettings->VEHICLENAME_NUMELEM);
|
||||
|
||||
addApplySaveButtons(m_aircraft->saveAircraftToRAM, m_aircraft->saveAircraftToSD);
|
||||
|
||||
addUAVObject("SystemSettings");
|
||||
@ -158,6 +162,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
addWidget(m_aircraft->ffTestBox1);
|
||||
addWidget(m_aircraft->ffTestBox2);
|
||||
addWidget(m_aircraft->ffTestBox3);
|
||||
addWidget(m_aircraft->nameEdit);
|
||||
|
||||
disableMouseWheelEvents();
|
||||
updateEnableControls();
|
||||
@ -224,6 +229,19 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o)
|
||||
}
|
||||
}
|
||||
|
||||
field = system->getField(QString("VehicleName"));
|
||||
Q_ASSERT(field);
|
||||
QString name;
|
||||
for (uint i = 0; i < field->getNumElements(); ++i) {
|
||||
QChar chr = field->getValue(i).toChar();
|
||||
if (chr != 0) {
|
||||
name.append(chr);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_aircraft->nameEdit->setText(name);
|
||||
|
||||
updateFeedForwardUI();
|
||||
|
||||
setDirty(dirty);
|
||||
@ -270,6 +288,17 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||
vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value());
|
||||
vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value());
|
||||
|
||||
field = system->getField(QString("VehicleName"));
|
||||
Q_ASSERT(field);
|
||||
QString name = m_aircraft->nameEdit->text();
|
||||
for (uint i = 0; i < field->getNumElements(); ++i) {
|
||||
if (i < name.length()) {
|
||||
field->setValue(name.at(i).toLatin1(), i);
|
||||
} else {
|
||||
field->setValue(0, i);
|
||||
}
|
||||
}
|
||||
|
||||
// call refreshWidgetsValues() to reflect actual saved values
|
||||
refreshWidgetsValues();
|
||||
updateFeedForwardUI();
|
||||
|
@ -2,7 +2,7 @@
|
||||
<object name="SystemSettings" singleinstance="true" settings="true" category="System">
|
||||
<description>Select airframe type. Currently used by @ref ActuatorModule to choose mixing from @ref ActuatorDesired to @ref ActuatorCommand</description>
|
||||
<field name="AirframeType" units="" type="enum" elements="1" options="FixedWing,FixedWingElevon,FixedWingVtail,VTOL,HeliCP,QuadX,QuadP,QuadH,Hexa,Octo,Custom,HexaX,HexaH,OctoV,OctoCoaxP,OctoCoaxX,OctoX,HexaCoax,Tri,GroundVehicleCar,GroundVehicleDifferential,GroundVehicleMotorcycle" defaultvalue="QuadX"/>
|
||||
<field name="VehicleName" units="char" type="uint8" elements="10" defaultvalue="0"/>
|
||||
<field name="VehicleName" units="char" type="uint8" elements="20" defaultvalue="0"/>
|
||||
<field name="ThrustControl" units="" type="enum" elements="1" options="Throttle,Collective,None" defaultvalue="Throttle" />
|
||||
<!-- Which way the vehicle controls its thrust. Can be through
|
||||
"Throttle" (quadcopter, simple brushless planes,
|
||||
|
Loading…
x
Reference in New Issue
Block a user