36 #include "camerastabsettings.h"
37 #include "modulesettings.h"
38 #include "mixersettings.h"
39 #include "actuatorcommand.h"
44 m_camerastabilization =
new Ui_CameraStabilizationWidget();
45 m_camerastabilization->setupUi(
this);
49 QComboBox *outputs[] = {
50 m_camerastabilization->rollChannel,
51 m_camerastabilization->pitchChannel,
52 m_camerastabilization->yawChannel,
55 const int NUM_OUTPUTS =
sizeof(outputs) /
sizeof(outputs[0]);
58 for (
int i = 0;
i < NUM_OUTPUTS;
i++) {
60 outputs[
i]->addItem(
"None");
61 for (quint32 j = 0; j < ActuatorCommand::CHANNEL_NUMELEM; j++)
62 outputs[
i]->addItem(QString(
"Channel %1").arg(j + 1));
70 addWidget(m_camerastabilization->enableCameraStabilization);
71 addWidget(m_camerastabilization->rollChannel);
72 addWidget(m_camerastabilization->pitchChannel);
73 addWidget(m_camerastabilization->yawChannel);
87 &ConfigCameraStabilizationWidget::defaultRequestedSlot);
103 void ConfigCameraStabilizationWidget::refreshWidgetsValues(
UAVObject *obj)
110 ModuleSettings *moduleSettings = ModuleSettings::GetInstance(
getObjectManager());
111 ModuleSettings::DataFields moduleSettingsData = moduleSettings->getData();
113 m_camerastabilization->enableCameraStabilization->setChecked(
114 moduleSettingsData.AdminState[ModuleSettings::ADMINSTATE_CAMERASTAB]
115 == ModuleSettings::ADMINSTATE_ENABLED);
118 MixerSettings *mixerSettings = MixerSettings::GetInstance(
getObjectManager());
119 MixerSettings::DataFields mixerSettingsData = mixerSettings->getData();
123 quint8 *mixerTypes[] = {
124 &mixerSettingsData.Mixer1Type, &mixerSettingsData.Mixer2Type,
125 &mixerSettingsData.Mixer3Type, &mixerSettingsData.Mixer4Type,
126 &mixerSettingsData.Mixer5Type, &mixerSettingsData.Mixer6Type,
127 &mixerSettingsData.Mixer7Type, &mixerSettingsData.Mixer8Type,
128 &mixerSettingsData.Mixer9Type, &mixerSettingsData.Mixer10Type,
130 const int NUM_MIXERS =
sizeof(mixerTypes) /
sizeof(mixerTypes[0]);
132 QComboBox *outputs[] = { m_camerastabilization->rollChannel,
133 m_camerastabilization->pitchChannel,
134 m_camerastabilization->yawChannel };
135 const int NUM_OUTPUTS =
sizeof(outputs) /
sizeof(outputs[0]);
137 for (
int i = 0;
i < NUM_OUTPUTS;
i++) {
140 outputs[
i]->setCurrentIndex(0);
141 for (
int j = 0; j < NUM_MIXERS; j++)
142 if (*mixerTypes[j] == (MixerSettings::MIXER1TYPE_CAMERAROLL +
i)
143 && outputs[
i]->currentIndex() != (j + 1))
144 outputs[
i]->setCurrentIndex(j + 1);
157 void ConfigCameraStabilizationWidget::updateObjectsFromWidgets()
162 quint8 enableModule = m_camerastabilization->enableCameraStabilization->isChecked()
163 ? (ModuleSettings::ADMINSTATE_ENABLED)
164 : (ModuleSettings::ADMINSTATE_DISABLED);
165 ModuleSettings *moduleSettings = ModuleSettings::GetInstance(
getObjectManager());
166 moduleSettings->setAdminState(ModuleSettings::ADMINSTATE_CAMERASTAB, enableModule);
170 MixerSettings *mixerSettings = MixerSettings::GetInstance(
getObjectManager());
171 MixerSettings::DataFields mixerSettingsData = mixerSettings->getData();
175 quint8 *mixerTypes[] = {
176 &mixerSettingsData.Mixer1Type, &mixerSettingsData.Mixer2Type,
177 &mixerSettingsData.Mixer3Type, &mixerSettingsData.Mixer4Type,
178 &mixerSettingsData.Mixer5Type, &mixerSettingsData.Mixer6Type,
179 &mixerSettingsData.Mixer7Type, &mixerSettingsData.Mixer8Type,
180 &mixerSettingsData.Mixer9Type, &mixerSettingsData.Mixer10Type,
182 const int NUM_MIXERS =
sizeof(mixerTypes) /
sizeof(mixerTypes[0]);
184 QComboBox *outputs[] = { m_camerastabilization->rollChannel,
185 m_camerastabilization->pitchChannel,
186 m_camerastabilization->yawChannel };
187 const int NUM_OUTPUTS =
sizeof(outputs) /
sizeof(outputs[0]);
189 m_camerastabilization->message->setText(
"");
192 widgetUpdated =
false;
194 for (
int i = 0;
i < NUM_OUTPUTS;
i++) {
196 int mixerNum = outputs[
i]->currentIndex() - 1;
198 if ((mixerNum >= 0) &&
199 (*mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_DISABLED)
200 && (*mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_CAMERAROLL +
i)) {
203 outputs[
i]->setCurrentIndex(0);
204 m_camerastabilization->message->setText(
205 "One of the channels is already assigned, reverted to none");
208 widgetUpdated =
true;
211 for (
int j = 0; j < NUM_MIXERS; j++)
212 if (*mixerTypes[j] == (MixerSettings::MIXER1TYPE_CAMERAROLL +
i))
213 *mixerTypes[j] = MixerSettings::MIXER1TYPE_DISABLED;
217 if ((mixerNum >= 0) && (mixerNum < NUM_MIXERS))
218 *mixerTypes[mixerNum] = MixerSettings::MIXER1TYPE_CAMERAROLL +
i;
221 }
while (widgetUpdated);
225 mixerSettings->setData(mixerSettingsData);
234 void ConfigCameraStabilizationWidget::defaultRequestedSlot(
int group)
252 QComboBox *outputs[] = {
253 m_camerastabilization->rollChannel,
254 m_camerastabilization->pitchChannel,
255 m_camerastabilization->yawChannel,
257 const int NUM_OUTPUTS =
sizeof(outputs) /
sizeof(outputs[0]);
259 for (
int i = 0;
i < NUM_OUTPUTS;
i++) {
260 outputs[
i]->setCurrentIndex(0);
ConfigCameraStabilizationWidget(QWidget *parent=nullptr)
~ConfigCameraStabilizationWidget()