Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
801 - 1
/***************************************************************************
2
 *   Copyright (C) 2009 by Manuel Schrape                                  *
3
 *   manuel.schrape@gmx.de                                                 *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License.        *
8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
19
 
20
#include <QCryptographicHash>
21
#include <QFileDialog>
22
#include <QMessageBox>
23
#include <QSettings>
24
 
25
#include "dlg_Main.h"
26
 
27
// Konstruktor Main-Form
28
dlg_Main::dlg_Main()
29
{
30
    setupUi(this);
31
 
32
    o_Settings = new cSettings();
33
 
34
    wg_Connection->set_Client(ID_SETTINGS, QA_NAME + " " + QA_VERSION, DataFields);
35
 
36
    o_Timer = new QTimer();
37
    o_Timer->setInterval(500);
38
 
39
    f_MotorMixer = new dlg_MotorMixer(this);
40
 
41
    init_Directorys();
42
    init_GUI();
43
    init_Connections();
44
}
45
 
46
// Grafische Oberfläche initialisieren
47
void dlg_Main::init_GUI()
48
{
49
    setWindowTitle(QA_NAME + " " + QA_VERSION);
50
 
51
    resize(o_Settings->GUI.Size);
52
    move(o_Settings->GUI.Point);
53
 
54
    if (o_Settings->GUI.isMax)
55
    {
56
        showMaximized();
57
    }
58
 
59
    wg_Connection->set_SelectVisible(false);
60
    wg_Connection->set_IntervalVisible(false);
61
 
62
    ac_Toolbar->setChecked(o_Settings->GUI.Toolbar);
63
 
64
    if (ac_Toolbar->isChecked())
65
    {
66
        wg_Connection->set_ButtonVisible(false);
67
    }
68
    else
69
    {
70
        ToolBar->setVisible(false);
71
    }
72
}
73
 
74
// Signale mit Slots verbinden
75
void dlg_Main::init_Connections()
76
{
77
    connect(o_Timer, SIGNAL(timeout()), this, SLOT(slot_Timer()));
78
 
79
    connect(ac_Connect, SIGNAL(triggered()), wg_Connection, SLOT(slot_btn_Connect()));
80
    connect(ac_Toolbar, SIGNAL(triggered()), this, SLOT(slot_ac_Toolbar()));
81
 
82
    connect(ac_Write, SIGNAL(triggered()), this, SLOT(slot_ac_Write()));
83
    connect(ac_Read, SIGNAL(triggered()), this, SLOT(slot_ac_Read()));
84
    connect(ac_Save, SIGNAL(triggered()), this, SLOT(slot_ac_Save()));
85
    connect(ac_Load, SIGNAL(triggered()), this, SLOT(slot_ac_Load()));
86
 
87
    connect(ac_MotorMixer, SIGNAL(triggered()), this, SLOT(slot_ac_MotorMixer()));
88
 
89
    // About QMK-Settings & About-QT Dialog einfügen
90
    connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About()));
91
    menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt()));
92
 
93
    connect(wg_Connection, SIGNAL(sig_Status(int)), this, SLOT(slot_ConnectionStatus(int)));
94
    connect(wg_Connection, SIGNAL(sig_MK_Version(s_Hardware)), this, SLOT(slot_MK_Version(s_Hardware)));
95
    connect(wg_Connection, SIGNAL(sig_MK_ReadSettings(s_MK_Settings)), this, SLOT(slot_MK_ReadSettings(s_MK_Settings)));
96
    connect(wg_Connection, SIGNAL(sig_MK_WriteSettings(int)), this, SLOT(slot_MK_WriteSettings(int)));
97
    connect(wg_Connection, SIGNAL(sig_MK_ReadMotorMixer(s_MK_Mixer)), this, SLOT(slot_MK_ReadMotorMixer(s_MK_Mixer)));
98
    connect(wg_Connection, SIGNAL(sig_MK_WriteMotorMixer(int)), this, SLOT(slot_MK_WriteMotorMixer(int)));
99
    connect(wg_Connection, SIGNAL(sig_MK_PPMData(s_MK_PPM_Data)), this, SLOT(slot_MK_PPMData(s_MK_PPM_Data)));
100
 
101
    connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(slot_PageChange(int)));
102
 
103
    // Settings - LED's J16
104
    connect(J16_0,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
105
    connect(J16_1,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
106
    connect(J16_2,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
107
    connect(J16_3,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
108
    connect(J16_4,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
109
    connect(J16_5,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
110
    connect(J16_6,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
111
    connect(J16_7,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
112
 
113
    // Settings - LED's J17
114
    connect(J17_0,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
115
    connect(J17_1,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
116
    connect(J17_2,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
117
    connect(J17_3,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
118
    connect(J17_4,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
119
    connect(J17_5,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
120
    connect(J17_6,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
121
    connect(J17_7,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
122
 
123
    // Settings - LED's J16
124
    connect(J16_A_0,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
125
    connect(J16_A_1,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
126
    connect(J16_A_2,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
127
    connect(J16_A_3,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
128
    connect(J16_A_4,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
129
    connect(J16_A_5,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
130
    connect(J16_A_6,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
131
    connect(J16_A_7,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
132
 
133
    // Settings - LED's J17
134
    connect(J17_A_0,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
135
    connect(J17_A_1,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
136
    connect(J17_A_2,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
137
    connect(J17_A_3,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
138
    connect(J17_A_4,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
139
    connect(J17_A_5,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
140
    connect(J17_A_6,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
141
    connect(J17_A_7,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
142
 
143
    connect(sb_11_1, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED16(int)));
144
    connect(sb_11_3, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED17(int)));
145
    connect(sb_11_5, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED16A(int)));
146
    connect(sb_11_6, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED17A(int)));
147
 
148
    connect(tb_9_6,  SIGNAL(clicked()), this, SLOT(slot_tbUp()));
149
    connect(tb_9_7,  SIGNAL(clicked()), this, SLOT(slot_tbDown()));
150
    connect(tb_9_8,  SIGNAL(clicked()), this, SLOT(slot_tbLeft()));
151
    connect(tb_9_9,  SIGNAL(clicked()), this, SLOT(slot_tbRight()));
152
}
153
 
154
void dlg_Main::init_Directorys()
155
{
156
    QDir *t_Dir = new QDir();
157
 
158
    s_Dir.MainData = QDir::homePath() + "/QMK-Data";
159
    if (!t_Dir->exists(s_Dir.MainData))
160
    {
161
        t_Dir->mkdir(s_Dir.MainData);
162
    }
163
 
164
    s_Dir.Settings = s_Dir.MainData + "/Settings";
165
    if (!t_Dir->exists(s_Dir.Settings))
166
    {
167
        t_Dir->mkdir(s_Dir.Settings);
168
    }
169
}
170
 
171
///////////
172
// Slots //
173
///////////
174
 
175
// About-Dialog
176
void dlg_Main::slot_ac_About()
177
{
178
    QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT);
179
}
180
 
181
void dlg_Main::slot_ac_Toolbar()
182
{
183
    if (ac_Toolbar->isChecked())
184
    {
185
        wg_Connection->set_ButtonVisible(false);
186
        ToolBar->setVisible(true);
187
    }
188
    else
189
    {
190
        wg_Connection->set_ButtonVisible(true);
191
        ToolBar->setVisible(false);
192
    }
193
}
194
 
195
void dlg_Main::slot_ConnectionStatus(int li_Status)
196
{
197
    if (li_Status)
198
    {
199
        ac_Connect->setChecked(true);
200
        ac_Connect->setText(tr("Trennen"));
201
    }
202
    else
203
    {
204
        ac_Connect->setChecked(false);
205
        ac_Connect->setText(tr("Verbinden"));
206
    }
207
}
208
 
209
void dlg_Main::slot_MK_Version(s_Hardware ls_Version)
210
{
211
    gs_Version = ls_Version;
212
    setWindowTitle(QA_NAME + " " + QA_VERSION + " - " + ls_Version.Hardware + " " + ls_Version.Version);
213
 
214
    if (gs_Version.ID == ADDRESS_FC)
215
    {
216
        c_Data[0] = 0xff;
217
        wg_Connection->send_Data(HandlerMK::make_Frame('q', ADDRESS_FC, c_Data, 1).toLatin1().data(), DATA_READ_SETTINGS);
218
    }
219
}
220
 
221
void dlg_Main::slot_MK_ReadSettings(s_MK_Settings ps_MK_Settings)
222
{
223
    if (ps_MK_Settings.Version == MK_VERSION_SETTINGS)
224
    {
225
        show_MK_Settings(ps_MK_Settings);
226
    }
227
    else
228
    {
229
        QMessageBox::warning(this, QA_NAME, tr("Versionen inkompatibel. \nParameterbearbeitung nicht moeglich."), QMessageBox::Ok);
230
        ac_Read->setEnabled(false);
231
        ac_Write->setEnabled(false);
232
    }
233
}
234
 
235
void dlg_Main::slot_MK_WriteSettings(int pi_ID)
236
{
237
    if (pi_ID == 0)
238
    {
239
        QMessageBox::warning(this, QA_NAME, tr("Fehler beim Settings-Schreiben."), QMessageBox::Ok);
240
    }
241
    else
242
    {
243
        QMessageBox::information(this, QA_NAME, tr("Setting geschrieben."), QMessageBox::Ok);
244
    }
245
 
246
}
247
 
248
void dlg_Main::slot_MK_ReadMotorMixer(s_MK_Mixer ps_MK_MotorMixer)
249
{
250
    if (ps_MK_MotorMixer.Revision == MK_VERSION_MIXER)
251
    {
252
        f_MotorMixer->set_MotorConfig(ps_MK_MotorMixer);
253
    }
254
}
255
 
256
void dlg_Main::slot_MK_WriteMotorMixer(int pi_ID)
257
{
258
    if (pi_ID == 0)
259
    {
260
        QMessageBox::warning(this, QA_NAME, tr("Fehler beim MotorMixer-Schreiben."), QMessageBox::Ok);
261
    }
262
    else
263
    {
264
        QMessageBox::information(this, QA_NAME, tr("MotorMixer geschrieben."), QMessageBox::Ok);
265
    }
266
 
267
}
268
 
269
void dlg_Main::slot_MK_PPMData(s_MK_PPM_Data ps_PPMData)
270
{
271
        pb_K1->setValue(ps_PPMData[0]);
272
        pb_K2->setValue(ps_PPMData[1]);
273
        pb_K3->setValue(ps_PPMData[2]);
274
        pb_K4->setValue(ps_PPMData[3]);
275
        pb_K5->setValue(ps_PPMData[4]);
276
        pb_K6->setValue(ps_PPMData[5]);
277
        pb_K7->setValue(ps_PPMData[6]);
278
        pb_K8->setValue(ps_PPMData[7]);
279
        pb_K9->setValue(ps_PPMData[8]);
280
        pb_K10->setValue(ps_PPMData[9]);
281
        pb_K11->setValue(ps_PPMData[10]);
282
        pb_K12->setValue(ps_PPMData[11]);
283
        pb_K1_2->setValue(ps_PPMData[13]);
284
        pb_K2_2->setValue(ps_PPMData[14]);
285
        pb_K3_2->setValue(ps_PPMData[15]);
286
        pb_K4_2->setValue(ps_PPMData[16]);
287
        pb_K5_2->setValue(ps_PPMData[17]);
288
        pb_K6_2->setValue(ps_PPMData[18]);
289
        pb_K7_2->setValue(ps_PPMData[19]);
290
        pb_K8_2->setValue(ps_PPMData[20]);
291
        pb_K9_2->setValue(ps_PPMData[21]);
292
        pb_K10_2->setValue(ps_PPMData[22]);
293
        pb_K11_2->setValue(ps_PPMData[23]);
294
        pb_K12_2->setValue(ps_PPMData[24]);
295
}
296
 
297
///////////////////////////////////////////////////////////////////
298
// QMK-Settings                                                  //
299
///////////////////////////////////////////////////////////////////
300
 
301
 
302
void dlg_Main::slot_PageChange(int Page)
303
{
304
    if (Page == 1)
305
        o_Timer->start();
306
    else
307
        o_Timer->stop();
308
}
309
 
310
void dlg_Main::slot_Timer()
311
{
312
    wg_Connection->send_Data(HandlerMK::make_Frame('p', ADDRESS_FC, c_Data, 0).toLatin1().data(), 0);
313
}
314
 
315
void dlg_Main::slot_ac_MotorMixer()
316
{
317
    f_MotorMixer->set_Objects(wg_Connection->o_Input, o_Settings, s_Dir);
318
    f_MotorMixer->read_Mixer();
319
 
320
    if (f_MotorMixer->exec()==QDialog::Accepted)
321
    {
322
    }
323
}
324
 
325
// Settings-Funktionen
326
void dlg_Main::slot_ac_Write()
327
{
328
    s_MK_Settings t_Set;
329
 
330
    t_Set = get_MK_Settings();
331
 
332
    memcpy((unsigned char *)&c_Data, (unsigned char *)&t_Set, sizeof(t_Set));
333
 
334
    wg_Connection->send_Data(HandlerMK::make_Frame('s', ADDRESS_FC, c_Data, sizeof(t_Set)).toLatin1().data(), DATA_WRITE_SETTINGS);
335
}
336
 
337
void dlg_Main::slot_ac_Read()
338
{
339
    c_Data[0] = sb_Set->value();
340
    wg_Connection->send_Data(HandlerMK::make_Frame('q', ADDRESS_FC, c_Data, 1).toLatin1().data(), DATA_READ_SETTINGS);
341
}
342
 
343
void dlg_Main::slot_ac_Save()
344
{
345
    QString Filename = QFileDialog::getSaveFileName(this, "Mikrokopter Parameter speichern", s_Dir.Settings + "/" + gs_Version.VersionShort + "_" + le_SetName->text() + ".mkp", "Mikrokopter Parameter(*.mkp);;Alle Dateien (*)");
346
 
347
    if (!Filename.isEmpty())
348
    {
349
        if (!(Filename.endsWith(".mkp", Qt::CaseInsensitive)))
350
        {
351
            Filename = Filename + QString(".mkp");
352
        }
353
 
354
        s_MK_Settings t_Set = get_MK_Settings();
355
 
356
        QSettings Setting(Filename, QSettings::IniFormat);
357
 
358
        Setting.beginGroup("Setup");
359
            Setting.setValue("Name",         le_SetName->text());
360
            Setting.setValue("IniVersion",   3);
361
            Setting.setValue("GlobalConfig", t_Set.GlobalConfig);
362
            Setting.setValue("GlobalConfig2", t_Set.ExtraConfig);
363
        Setting.endGroup();
364
 
365
        Setting.beginGroup("Channels");
366
            Setting.setValue("Nick",   t_Set.Kanalbelegung[0]);
367
            Setting.setValue("Roll",   t_Set.Kanalbelegung[1]);
368
            Setting.setValue("Gas",    t_Set.Kanalbelegung[2]);
369
            Setting.setValue("Gier",   t_Set.Kanalbelegung[3]);
370
            Setting.setValue("Poti_1", t_Set.Kanalbelegung[4]);
371
            Setting.setValue("Poti_2", t_Set.Kanalbelegung[5]);
372
            Setting.setValue("Poti_3", t_Set.Kanalbelegung[6]);
373
            Setting.setValue("Poti_4", t_Set.Kanalbelegung[7]);
374
            Setting.setValue("Poti_5", t_Set.Kanalbelegung[8]);
375
            Setting.setValue("Poti_6", t_Set.Kanalbelegung[9]);
376
            Setting.setValue("Poti_7", t_Set.Kanalbelegung[10]);
377
            Setting.setValue("Poti_8", t_Set.Kanalbelegung[11]);
378
            Setting.setValue("Receiver", t_Set.Receiver);
379
        Setting.endGroup();
380
 
381
        Setting.beginGroup("Stick");
382
            Setting.setValue("Nick_Roll-P",     t_Set.Stick_P);
383
            Setting.setValue("Nick_Roll-D",     t_Set.Stick_D);
384
            Setting.setValue("Gier-P",          t_Set.Gier_P);
385
            Setting.setValue("ExternalControl", t_Set.ExternalControl);
386
        Setting.endGroup();
387
 
388
        Setting.beginGroup("Altitude");
389
            Setting.setValue("Setpoint",          t_Set.MaxHoehe);
390
            Setting.setValue("MinGas",            t_Set.Hoehe_MinGas);
391
            Setting.setValue("P",                 t_Set.Hoehe_P);
392
            Setting.setValue("Barometric-D",      t_Set.Luftdruck_D);
393
            Setting.setValue("Z-ACC-Effect",      t_Set.Hoehe_ACC_Wirkung);
394
            Setting.setValue("Gain",              t_Set.Hoehe_Verstaerkung);
395
            Setting.setValue("HoverVariation",    t_Set.Hoehe_HoverBand);
396
            Setting.setValue("GPS_Z",             t_Set.Hoehe_GPS_Z);
397
            Setting.setValue("StickNeutralPoint", t_Set.Hoehe_StickNeutralPoint);
398
        Setting.endGroup();
399
 
400
        Setting.beginGroup("Gyro");
401
            Setting.setValue("P",                     t_Set.Gyro_P);
402
            Setting.setValue("I",                     t_Set.Gyro_I);
403
            Setting.setValue("D",                     t_Set.Gyro_D);
404
            Setting.setValue("Gier_P",                t_Set.Gyro_Gier_P);
405
            Setting.setValue("Gier_I",                t_Set.Gyro_Gier_I);
406
            Setting.setValue("DynamicStability",      t_Set.DynamicStability);
407
            Setting.setValue("ACC_Gyro-Factor",       t_Set.GyroAccFaktor);
408
            Setting.setValue("ACC_Gyro-Compensation", t_Set.GyroAccAbgleich);
409
            Setting.setValue("DriftCompensation",     t_Set.Driftkomp);
410
            Setting.setValue("Main-I",                t_Set.I_Faktor);
411
        Setting.endGroup();
412
 
413
        Setting.beginGroup("Camera");
414
            Setting.setValue("ServoNickControl",      t_Set.ServoNickControl);
415
            Setting.setValue("ServoNickCompensation", t_Set.ServoNickComp);
416
            Setting.setValue("ServoNickMin",          t_Set.ServoNickMin);
417
            Setting.setValue("ServoNickMax",          t_Set.ServoNickMax);
418
 
419
            Setting.setValue("ServoRollControl",      t_Set.ServoRollControl);
420
            Setting.setValue("ServoRollCompensation", t_Set.ServoRollComp);
421
            Setting.setValue("ServoRollMin",          t_Set.ServoRollMin);
422
            Setting.setValue("ServoRollMax",          t_Set.ServoRollMax);
423
 
424
            Setting.setValue("ServoInvert",           t_Set.ServoCompInvert);
425
            Setting.setValue("ServoNickRefreshRate",  t_Set.ServoNickRefresh);
426
 
427
            Setting.setValue("Servo3",                t_Set.Servo3);
428
            Setting.setValue("Servo4",                t_Set.Servo4);
429
            Setting.setValue("Servo5",                t_Set.Servo5);
430
        Setting.endGroup();
431
 
432
        Setting.beginGroup("Others");
433
            Setting.setValue("MinGas",         t_Set.Gas_Min);
434
            Setting.setValue("MaxGas",         t_Set.Gas_Max);
435
            Setting.setValue("Compass-Effect", t_Set.KompassWirkung);
436
            Setting.setValue("UnderVoltage",   t_Set.UnterspannungsWarnung);
437
            Setting.setValue("NotGas",         t_Set.NotGas);
438
            Setting.setValue("NotGasTime",     t_Set.NotGasZeit);
439
        Setting.endGroup();
440
 
441
        Setting.beginGroup("Coupling");
442
            Setting.setValue("YawPosFeedback",   t_Set.AchsKopplung1);
443
            Setting.setValue("NickRollFeedback", t_Set.AchsKopplung2);
444
            Setting.setValue("YawCorrection",    t_Set.CouplingYawCorrection);
445
        Setting.endGroup();
446
 
447
        Setting.beginGroup("Loop");
448
            Setting.setValue("Config", t_Set.BitConfig);
449
            Setting.setValue("GasLimit", t_Set.LoopGasLimit);
450
            Setting.setValue("StickThreshold", t_Set.LoopThreshold);
451
            Setting.setValue("LoopHysteresis", t_Set.LoopHysterese);
452
            Setting.setValue("TurnOverNick", t_Set.WinkelUmschlagNick);
453
            Setting.setValue("TurnOverRoll", t_Set.WinkelUmschlagRoll);
454
        Setting.endGroup();
455
 
456
        Setting.beginGroup("User");
457
             Setting.setValue("Parameter_1", t_Set.UserParam1);
458
             Setting.setValue("Parameter_2", t_Set.UserParam2);
459
             Setting.setValue("Parameter_3", t_Set.UserParam3);
460
             Setting.setValue("Parameter_4", t_Set.UserParam4);
461
             Setting.setValue("Parameter_5", t_Set.UserParam5);
462
             Setting.setValue("Parameter_6", t_Set.UserParam6);
463
             Setting.setValue("Parameter_7", t_Set.UserParam7);
464
             Setting.setValue("Parameter_8", t_Set.UserParam8);
465
        Setting.endGroup();
466
 
467
        Setting.beginGroup("Output");
468
            Setting.setValue("J16_Bitmask",      t_Set.J16Bitmask);
469
            Setting.setValue("J16_Timing",       t_Set.J16Timing);
470
            Setting.setValue("J17_Bitmask",      t_Set.J17Bitmask);
471
            Setting.setValue("J17_Timing",       t_Set.J17Timing);
472
            Setting.setValue("WARN_J16_Bitmask", t_Set.WARN_J16_Bitmask);
473
            Setting.setValue("WARN_J17_Bitmask", t_Set.WARN_J17_Bitmask);
474
        Setting.endGroup();
475
 
476
        Setting.beginGroup("NaviCtrl");
477
            Setting.setValue("GPS_ModeControl",       t_Set.NaviGpsModeControl);
478
            Setting.setValue("GPS_Gain",              t_Set.NaviGpsGain);
479
            Setting.setValue("GPS_P",                 t_Set.NaviGpsP);
480
            Setting.setValue("GPS_I",                 t_Set.NaviGpsI);
481
            Setting.setValue("GPS_D",                 t_Set.NaviGpsD);
482
            Setting.setValue("GPS_P_Limit",           t_Set.NaviGpsPLimit);
483
            Setting.setValue("GPS_I_Limit",           t_Set.NaviGpsILimit);
484
            Setting.setValue("GPS_D_Limit",           t_Set.NaviGpsDLimit);
485
            Setting.setValue("GPS_Acc",               t_Set.NaviGpsACC);
486
            Setting.setValue("GPS_MinSat",            t_Set.NaviGpsMinSat);
487
            Setting.setValue("GPS_StickThreshold",    t_Set.NaviStickThreshold);
488
            Setting.setValue("GPS_WindCorrection",    t_Set.NaviWindCorrection);
489
            Setting.setValue("GPS_SpeedCompensation", t_Set.NaviSpeedCompensation);
490
            Setting.setValue("GPS_MaxRadius",         t_Set.NaviOperatingRadius);
491
            Setting.setValue("GPS_AngleLimit",        t_Set.NaviAngleLimitation);
492
            Setting.setValue("GPS_PH_Login_Time",     t_Set.NaviPH_LoginTime);
493
        Setting.endGroup();
494
    }
495
}
496
 
497
void dlg_Main::slot_ac_Load()
498
{
499
    QString Filename = QFileDialog::getOpenFileName(this, "Mikrokopter Parameter laden",  s_Dir.Settings + "", "Mikrokopter Parameter(*.mkp);;Alle Dateien (*)");
500
 
501
    if (!Filename.isEmpty())
502
    {
503
        s_MK_Settings t_Set = get_MK_Settings();
504
 
505
        t_Set.Index = sb_Set->value();
506
 
507
        QSettings Setting(Filename, QSettings::IniFormat);
508
 
509
        Setting.beginGroup("Setup");
510
            QString Name = Setting.value("Name", QString("--noname--")).toString();
511
 
512
            memcpy(t_Set.Name, Name.toLatin1().data(), 12);
513
 
514
            t_Set.GlobalConfig = Setting.value("GlobalConfig", 104).toInt();
515
            t_Set.ExtraConfig  = Setting.value("GlobalConfig2", 1).toInt();
516
        Setting.endGroup();
517
 
518
        Setting.beginGroup("Channels");
519
            t_Set.Kanalbelegung[0] = Setting.value("Nick", 1).toInt();
520
            t_Set.Kanalbelegung[1] = Setting.value("Roll", 2).toInt();
521
            t_Set.Kanalbelegung[2] = Setting.value("Gas", 3).toInt();
522
            t_Set.Kanalbelegung[3] = Setting.value("Gier", 4).toInt();
523
            t_Set.Kanalbelegung[4] = Setting.value("Poti_1", 5).toInt();
524
            t_Set.Kanalbelegung[5] = Setting.value("Poti_2", 6).toInt();
525
            t_Set.Kanalbelegung[6] = Setting.value("Poti_3", 7).toInt();
526
            t_Set.Kanalbelegung[7] = Setting.value("Poti_4", 8).toInt();
527
            t_Set.Kanalbelegung[8] = Setting.value("Poti_5", 9).toInt();
528
            t_Set.Kanalbelegung[9] = Setting.value("Poti_6", 10).toInt();
529
            t_Set.Kanalbelegung[10] = Setting.value("Poti_7", 11).toInt();
530
            t_Set.Kanalbelegung[11] = Setting.value("Poti_8", 12).toInt();
531
            t_Set.Receiver = Setting.value("Receiver", 0).toInt();
532
        Setting.endGroup();
533
 
534
        Setting.beginGroup("Stick");
535
            t_Set.Stick_P         = Setting.value("Nick_Roll-P", 10).toInt();
536
            t_Set.Stick_D         = Setting.value("Nick_Roll-D", 16).toInt();
537
            t_Set.Gier_P          = Setting.value("Gier-P", 6).toInt();
538
            t_Set.ExternalControl = Setting.value("ExternalControl", 0).toInt();
539
        Setting.endGroup();
540
 
541
        Setting.beginGroup("Altitude");
542
            t_Set.MaxHoehe                = Setting.value("Setpoint", 251).toInt();
543
            t_Set.Hoehe_MinGas            = Setting.value("MinGas", 30).toInt();
544
            t_Set.Hoehe_P                 = Setting.value("P", 10).toInt();
545
            t_Set.Luftdruck_D             = Setting.value("Barometric-D", 30).toInt();
546
            t_Set.Hoehe_ACC_Wirkung       = Setting.value("Z-ACC-Effect", 30).toInt();
547
            t_Set.Hoehe_Verstaerkung      = Setting.value("Gain", 15).toInt();
548
            t_Set.Hoehe_HoverBand         = Setting.value("HoverVariation", 5).toInt();
549
            t_Set.Hoehe_GPS_Z             = Setting.value("GPS_Z", 64).toInt();
550
            t_Set.Hoehe_StickNeutralPoint = Setting.value("StickNeutralPoint", 0).toInt();
551
        Setting.endGroup();
552
 
553
        Setting.beginGroup("Gyro");
554
            t_Set.Gyro_P           = Setting.value("P", 90).toInt();
555
            t_Set.Gyro_I           = Setting.value("I", 120).toInt();
556
            t_Set.Gyro_D           = Setting.value("D", 3).toInt();
557
            t_Set.Gyro_Gier_P      = Setting.value("Gier_P", 100).toInt();
558
            t_Set.Gyro_Gier_I      = Setting.value("Gier_I", 120).toInt();
559
            t_Set.DynamicStability = Setting.value("DynamicStability", 75).toInt();
560
            t_Set.GyroAccFaktor    = Setting.value("ACC_Gyro-Factor", 30).toInt();
561
            t_Set.GyroAccAbgleich  = Setting.value("ACC_Gyro-Compensation", 32).toInt();
562
            t_Set.Driftkomp        = Setting.value("DriftCompensation", 32).toInt();
563
            t_Set.I_Faktor         = Setting.value("Main-I", 32).toInt();
564
        Setting.endGroup();
565
 
566
        Setting.beginGroup("Camera");
567
            t_Set.ServoNickControl = Setting.value("ServoNickControl", 100).toInt();
568
            t_Set.ServoNickComp    = Setting.value("ServoNickCompensation", 40).toInt();
569
            t_Set.ServoNickMin     = Setting.value("ServoNickMin", 0).toInt();
570
            t_Set.ServoNickMax     = Setting.value("ServoNickMax", 250).toInt();
571
 
572
            t_Set.ServoRollControl = Setting.value("ServoRollControl", 100).toInt();
573
            t_Set.ServoRollComp    = Setting.value("ServoRollCompensation", 40).toInt();
574
            t_Set.ServoRollMin     = Setting.value("ServoRollMin", 0).toInt();
575
            t_Set.ServoRollMax     = Setting.value("ServoRollMax", 250).toInt();
576
 
577
            t_Set.ServoCompInvert  = Setting.value("ServoInvert", 0).toInt();
578
            t_Set.ServoNickRefresh = Setting.value("ServoNickRefreshRate", 3).toInt();
579
 
580
            t_Set.Servo3           = Setting.value("Servo3", 0).toInt();
581
            t_Set.Servo4           = Setting.value("Servo4", 0).toInt();
582
            t_Set.Servo5           = Setting.value("Servo5", 0).toInt();
583
        Setting.endGroup();
584
 
585
        Setting.beginGroup("Others");
586
            t_Set.Gas_Min               = Setting.value("MinGas", 8).toInt();
587
            t_Set.Gas_Max               = Setting.value("MaxGas", 230).toInt();
588
            t_Set.KompassWirkung        = Setting.value("Compass-Effect", 128).toInt();
589
            t_Set.UnterspannungsWarnung = Setting.value("UnderVoltage", 99).toInt();
590
            t_Set.NotGas                = Setting.value("NotGas", 35).toInt();
591
            t_Set.NotGasZeit            = Setting.value("NotGasTime", 30).toInt();
592
        Setting.endGroup();
593
 
594
        Setting.beginGroup("Coupling");
595
            t_Set.AchsKopplung1         = Setting.value("YawPosFeedback", 90).toInt();
596
            t_Set.AchsKopplung2         = Setting.value("NickRollFeedback", 80).toInt();
597
            t_Set.CouplingYawCorrection = Setting.value("YawCorrection", 60).toInt();
598
        Setting.endGroup();
599
 
600
        Setting.beginGroup("Loop");
601
            t_Set.BitConfig          = Setting.value("Config", 0).toInt();
602
            t_Set.LoopGasLimit       = Setting.value("GasLimit", 50).toInt();
603
            t_Set.LoopThreshold      = Setting.value("StickThreshold", 90).toInt();
604
            t_Set.LoopHysterese      = Setting.value("LoopHysteresis", 50).toInt();
605
            t_Set.WinkelUmschlagNick = Setting.value("TurnOverNick", 85).toInt();
606
            t_Set.WinkelUmschlagRoll = Setting.value("TurnOverRoll", 85).toInt();
607
        Setting.endGroup();
608
 
609
        Setting.beginGroup("User");
610
            t_Set.UserParam1 = Setting.value("Parameter_1", 0).toInt();
611
            t_Set.UserParam2 = Setting.value("Parameter_2", 0).toInt();
612
            t_Set.UserParam3 = Setting.value("Parameter_3", 0).toInt();
613
            t_Set.UserParam4 = Setting.value("Parameter_4", 0).toInt();
614
            t_Set.UserParam5 = Setting.value("Parameter_5", 0).toInt();
615
            t_Set.UserParam6 = Setting.value("Parameter_6", 0).toInt();
616
            t_Set.UserParam7 = Setting.value("Parameter_7", 0).toInt();
617
            t_Set.UserParam8 = Setting.value("Parameter_8", 0).toInt();
618
        Setting.endGroup();
619
 
620
        Setting.beginGroup("Output");
621
            t_Set.J16Bitmask       = Setting.value("J16_Bitmask", 255).toInt();
622
            t_Set.J16Timing        = Setting.value("J16_Timing", 15).toInt();
623
            t_Set.J17Bitmask       = Setting.value("J17_Bitmask", 255).toInt();
624
            t_Set.J17Timing        = Setting.value("J17_Timing", 15).toInt();
625
            t_Set.WARN_J16_Bitmask = Setting.value("WARN_J16_Bitmask", 0xaa).toInt();
626
            t_Set.WARN_J17_Bitmask = Setting.value("WARN_J17_Bitmask", 0xaa).toInt();
627
        Setting.endGroup();
628
 
629
        Setting.beginGroup("NaviCtrl");
630
            t_Set.NaviGpsModeControl    = Setting.value("GPS_ModeControl", 253).toInt();
631
            t_Set.NaviGpsGain           = Setting.value("GPS_Gain", 100).toInt();
632
            t_Set.NaviGpsP              = Setting.value("GPS_P", 90).toInt();
633
            t_Set.NaviGpsI              = Setting.value("GPS_I", 90).toInt();
634
            t_Set.NaviGpsD              = Setting.value("GPS_D", 90).toInt();
635
            t_Set.NaviGpsPLimit         = Setting.value("GPS_P_Limit", 75).toInt();
636
            t_Set.NaviGpsILimit         = Setting.value("GPS_I_Limit", 75).toInt();
637
            t_Set.NaviGpsDLimit         = Setting.value("GPS_D_Limit", 75).toInt();
638
            t_Set.NaviGpsACC            = Setting.value("GPS_Acc", 0).toInt();
639
            t_Set.NaviGpsMinSat         = Setting.value("GPS_MinSat", 6).toInt();
640
            t_Set.NaviStickThreshold    = Setting.value("GPS_StickThreshold", 8).toInt();
641
            t_Set.NaviWindCorrection    = Setting.value("GPS_WindCorrection", 90).toInt();
642
            t_Set.NaviSpeedCompensation = Setting.value("GPS_SpeedCompensation", 30).toInt();
643
            t_Set.NaviOperatingRadius   = Setting.value("GPS_MaxRadius", 100).toInt();
644
            t_Set.NaviAngleLimitation   = Setting.value("GPS_AngleLimit", 100).toInt();
645
            t_Set.NaviPH_LoginTime      = Setting.value("GPS_PH_Login_Time", 4).toInt();
646
        Setting.endGroup();
647
 
648
        show_MK_Settings(t_Set);
649
    }
650
}
651
 
652
void dlg_Main::show_MK_Settings(s_MK_Settings t_Set) // DONE 0.75i
653
{
654
    sb_Set->setValue(int(t_Set.Index));
655
 
656
    le_SetName->setText(QString(t_Set.Name));
657
    // Seite 1
658
{
659
    s_1_1_cb->setChecked(t_Set.GlobalConfig & CFG_HOEHENREGELUNG);
660
    s_1_2_cb->setChecked(t_Set.GlobalConfig & CFG_KOMPASS_AKTIV);
661
    s_1_3_cb->setChecked(t_Set.GlobalConfig & CFG_KOMPASS_FIX);
662
    s_1_4_cb->setChecked(t_Set.GlobalConfig & CFG_GPS_AKTIV);
663
    s_1_5_cb->setChecked(t_Set.ExtraConfig & CFG_SENSITIVE_RC);
664
    s_1_6_cb->setChecked(t_Set.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV);
665
    s_1_7_cb->setChecked(t_Set.GlobalConfig & CFG_DREHRATEN_BEGRENZER);
666
    s_1_8_cb->setChecked(t_Set.GlobalConfig & CFG_HEADING_HOLD);
667
}
668
    // Seite 2
669
{
670
    cb_2_1->setCurrentIndex(t_Set.Kanalbelegung[2] - 1);
671
    cb_2_2->setCurrentIndex(t_Set.Kanalbelegung[3] - 1);
672
    cb_2_3->setCurrentIndex(t_Set.Kanalbelegung[0] - 1);
673
    cb_2_4->setCurrentIndex(t_Set.Kanalbelegung[1] - 1);
674
    cb_2_5->setCurrentIndex(t_Set.Kanalbelegung[4] - 1);
675
    cb_2_6->setCurrentIndex(t_Set.Kanalbelegung[5] - 1);
676
    cb_2_7->setCurrentIndex(t_Set.Kanalbelegung[6] - 1);
677
    cb_2_8->setCurrentIndex(t_Set.Kanalbelegung[7] - 1);
678
    cb_2_9->setCurrentIndex(t_Set.Kanalbelegung[8] - 1);
679
    cb_2_10->setCurrentIndex(t_Set.Kanalbelegung[9] - 1);
680
    cb_2_11->setCurrentIndex(t_Set.Kanalbelegung[10] - 1);
681
    cb_2_12->setCurrentIndex(t_Set.Kanalbelegung[11] - 1);
682
    s_2_13_cb->setCurrentIndex(t_Set.Receiver);
683
}
684
    // Seite 3
685
{
686
    sb_3_1->setValue(t_Set.Stick_P);
687
    sb_3_2->setValue(t_Set.Stick_D);
688
    cb_3_3 = setCombo(cb_3_3, t_Set.Gier_P);
689
    cb_3_4 = setCombo(cb_3_4, t_Set.ExternalControl);
690
}
691
    // Seite 4
692
{
693
//    s_4_2_rb->setChecked(t_Set.ExtraConfig & CFG2_HEIGHT_LIMIT);
694
 
695
    if (t_Set.ExtraConfig & CFG2_HEIGHT_LIMIT)
696
    {
697
        s_4_2_rb->setChecked(true);
698
    }
699
    else
700
    {
701
        s_4_3_rb->setChecked(true);
702
    }  
703
 
704
    s_4_5_cb->setChecked(t_Set.ExtraConfig & CFG2_VARIO_BEEP);
705
    s_4_4_cb->setChecked(t_Set.GlobalConfig & CFG_HOEHEN_SCHALTER);
706
 
707
    cb_4_1 = setCombo(cb_4_1, t_Set.MaxHoehe);
708
    sb_4_2->setValue(t_Set.Hoehe_MinGas);
709
    cb_4_3 = setCombo(cb_4_3, t_Set.Hoehe_P);
710
    cb_4_4 = setCombo(cb_4_4, t_Set.Luftdruck_D);
711
    cb_4_5 = setCombo(cb_4_5, t_Set.Hoehe_ACC_Wirkung);
712
    sb_4_6->setValue(t_Set.Hoehe_Verstaerkung);
713
    sb_4_7->setValue(t_Set.Hoehe_HoverBand);
714
    cb_4_8 = setCombo(cb_4_8, t_Set.Hoehe_GPS_Z);
715
    sb_4_9->setValue(t_Set.Hoehe_StickNeutralPoint);
716
}
717
    // Seite 5
718
{
719
    cb_5_1 = setCombo(cb_5_1, t_Set.Gyro_P);
720
    cb_5_2 = setCombo(cb_5_2, t_Set.Gyro_I);
721
    cb_5_8 = setCombo(cb_5_8, t_Set.Gyro_D);
722
    cb_5_3 = setCombo(cb_5_3, t_Set.DynamicStability);
723
    sb_5_4->setValue(t_Set.GyroAccFaktor);
724
    sb_5_5->setValue(t_Set.GyroAccAbgleich);
725
    cb_5_6 = setCombo(cb_5_6, t_Set.I_Faktor);
726
    sb_5_7->setValue(t_Set.Driftkomp);
727
    cb_5_9 = setCombo(cb_5_9, t_Set.Gyro_Gier_P);
728
    cb_5_10 = setCombo(cb_5_10, t_Set.Gyro_Gier_I);
729
}
730
    // Seite 6
731
{
732
    cb_6_1 = setCombo(cb_6_1, t_Set.ServoNickControl);
733
    sb_6_2->setValue(t_Set.ServoNickComp);
734
    sb_6_3->setValue(t_Set.ServoNickMin);
735
    sb_6_4->setValue(t_Set.ServoNickMax);
736
 
737
    cb_6_7 = setCombo(cb_6_7, t_Set.ServoRollControl);
738
    sb_6_8->setValue(t_Set.ServoRollComp);
739
    sb_6_10->setValue(t_Set.ServoRollMin);
740
    sb_6_11->setValue(t_Set.ServoRollMax);
741
 
742
    cb_6_6->setChecked(t_Set.ServoCompInvert & 0x01);
743
    cb_6_9->setChecked(t_Set.ServoCompInvert & 0x02);
744
 
745
    sb_6_5->setValue(t_Set.ServoNickRefresh);
746
 
747
    cb_6_12 = setCombo(cb_6_12, t_Set.Servo3);
748
    cb_6_13 = setCombo(cb_6_13, t_Set.Servo4);
749
    cb_6_14 = setCombo(cb_6_14, t_Set.Servo5);
750
 
751
}
752
    // Seite 7
753
{
754
    sb_7_1->setValue(t_Set.Gas_Min);
755
    sb_7_2->setValue(t_Set.Gas_Max);
756
    cb_7_3 = setCombo(cb_7_3, t_Set.KompassWirkung);
757
    sb_7_4->setValue(t_Set.UnterspannungsWarnung);
758
    sb_7_5->setValue(t_Set.NotGasZeit);
759
    sb_7_6->setValue(t_Set.NotGas);
760
}
761
    // Seite 8
762
{
763
    cb_8_1 = setCombo(cb_8_1, t_Set.AchsKopplung1);
764
    cb_8_2 = setCombo(cb_8_2, t_Set.AchsKopplung2);
765
    cb_8_3 = setCombo(cb_8_3, t_Set.CouplingYawCorrection);
766
}
767
    // Seite 9  - Looping
768
{
769
    if (t_Set.BitConfig & 0x01)
770
    {
771
        tb_9_6->setText("1");
772
        tb_9_6->setChecked(true);
773
    }
774
    else
775
    {
776
        tb_9_6->setText("0");
777
        tb_9_6->setChecked(false);
778
    }
779
 
780
    if (t_Set.BitConfig & 0x02)
781
    {
782
        tb_9_7->setText("1");
783
        tb_9_7->setChecked(true);
784
    }
785
    else
786
    {
787
        tb_9_7->setText("0");
788
        tb_9_7->setChecked(false);
789
    }
790
 
791
    if (t_Set.BitConfig & 0x04)
792
    {
793
        tb_9_8->setText("1");
794
        tb_9_8->setChecked(true);
795
    }
796
    else
797
    {
798
        tb_9_8->setText("0");
799
        tb_9_8->setChecked(false);
800
    }
801
 
802
    if (t_Set.BitConfig & 0x08)
803
    {
804
        tb_9_9->setText("1");
805
        tb_9_9->setChecked(true);
806
    }
807
    else
808
    {
809
        tb_9_9->setText("0");
810
        tb_9_9->setChecked(false);
811
    }
812
 
813
    cb_9_1 = setCombo(cb_9_1, t_Set.LoopGasLimit);
814
    sb_9_2->setValue(t_Set.LoopThreshold);
815
    sb_9_3->setValue(t_Set.WinkelUmschlagNick);
816
    sb_9_4->setValue(t_Set.LoopHysterese);
817
    sb_9_5->setValue(t_Set.WinkelUmschlagRoll);
818
 
819
}
820
    // Seite 10 - Userparameter
821
{
822
    cb_10_1 = setCombo(cb_10_1, t_Set.UserParam1);
823
    cb_10_2 = setCombo(cb_10_2, t_Set.UserParam2);
824
    cb_10_3 = setCombo(cb_10_3, t_Set.UserParam3);
825
    cb_10_4 = setCombo(cb_10_4, t_Set.UserParam4);
826
    cb_10_5 = setCombo(cb_10_5, t_Set.UserParam5);
827
    cb_10_6 = setCombo(cb_10_6, t_Set.UserParam6);
828
    cb_10_7 = setCombo(cb_10_7, t_Set.UserParam7);
829
    cb_10_8 = setCombo(cb_10_8, t_Set.UserParam8);
830
}
831
    // Seite 11 - Output
832
{
833
    sb_11_1->setValue(t_Set.J16Bitmask);
834
    cb_11_2 = setCombo(cb_11_2, int(t_Set.J16Timing));
835
    sb_11_3->setValue(t_Set.J17Bitmask);
836
    cb_11_4 = setCombo(cb_11_4, int(t_Set.J17Timing));
837
    sb_11_5->setValue(t_Set.WARN_J16_Bitmask);
838
    sb_11_6->setValue(t_Set.WARN_J17_Bitmask);
839
    cb_11_7->setChecked(t_Set.BitConfig & CFG_MOTOR_BLINK);
840
 
841
    if (t_Set.WARN_J16_Bitmask != 0)
842
        s_11_7_cb->setChecked(true);
843
    else
844
        s_11_7_cb->setChecked(false);
845
 
846
    if (t_Set.WARN_J17_Bitmask != 0)
847
        s_11_8_cb->setChecked(true);
848
    else
849
        s_11_8_cb->setChecked(false);
850
}
851
    // Seite 12
852
{
853
    cb_12_1 = setCombo(cb_12_1, t_Set.NaviGpsModeControl);
854
    cb_12_2 = setCombo(cb_12_2, t_Set.NaviGpsGain);
855
    sb_12_3->setValue(t_Set.NaviStickThreshold);
856
    sb_12_4->setValue(t_Set.NaviGpsMinSat);
857
    cb_12_5 = setCombo(cb_12_5, t_Set.NaviGpsP);
858
    cb_12_6 = setCombo(cb_12_6, t_Set.NaviGpsI);
859
    cb_12_7 = setCombo(cb_12_7, t_Set.NaviGpsD);
860
    cb_12_8 = setCombo(cb_12_8, t_Set.NaviGpsACC);
861
    cb_12_9 = setCombo(cb_12_9, t_Set.NaviGpsPLimit);
862
    cb_12_10 = setCombo(cb_12_10, t_Set.NaviGpsILimit);
863
    cb_12_11 = setCombo(cb_12_11, t_Set.NaviGpsDLimit);
864
}
865
    // Seite 13
866
{
867
    cb_13_1 = setCombo(cb_13_1, t_Set.NaviWindCorrection);
868
    cb_13_2 = setCombo(cb_13_2, t_Set.NaviSpeedCompensation);
869
    cb_13_3 = setCombo(cb_13_3, t_Set.NaviOperatingRadius);
870
    cb_13_4 = setCombo(cb_13_4, t_Set.NaviAngleLimitation);
871
    sb_13_5->setValue(t_Set.NaviPH_LoginTime);
872
}
873
}
874
 
875
s_MK_Settings dlg_Main::get_MK_Settings() // DONE 0.75i
876
{
877
    s_MK_Settings t_Set;
878
 
879
    memcpy(t_Set.Name, le_SetName->text().toLatin1().data(), 12);
880
    t_Set.Index = sb_Set->value();
881
    t_Set.Version = MK_VERSION_SETTINGS;
882
 
883
    // Seite 1
884
    {
885
    t_Set.GlobalConfig = 0;
886
    t_Set.ExtraConfig = 0;
887
 
888
    if (s_1_1_cb->isChecked())
889
        t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_HOEHENREGELUNG;
890
    if (s_1_2_cb->isChecked())
891
        t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_KOMPASS_AKTIV;
892
    if (s_1_3_cb->isChecked())
893
        t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_KOMPASS_FIX;
894
    if (s_1_4_cb->isChecked())
895
        t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_GPS_AKTIV;
896
    if (s_1_5_cb->isChecked())
897
        t_Set.ExtraConfig = t_Set.ExtraConfig | CFG_SENSITIVE_RC;
898
    if (s_1_6_cb->isChecked())
899
        t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_ACHSENKOPPLUNG_AKTIV;
900
    if (s_1_7_cb->isChecked())
901
        t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_DREHRATEN_BEGRENZER;
902
    if (s_1_8_cb->isChecked())
903
        t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_HEADING_HOLD;
904
    }
905
    // Seite 2
906
    {
907
    t_Set.Kanalbelegung[2] = cb_2_1->currentIndex() + 1;
908
    t_Set.Kanalbelegung[3] = cb_2_2->currentIndex() + 1;
909
    t_Set.Kanalbelegung[0] = cb_2_3->currentIndex() + 1;
910
    t_Set.Kanalbelegung[1] = cb_2_4->currentIndex() + 1;
911
    t_Set.Kanalbelegung[4] = cb_2_5->currentIndex() + 1;
912
    t_Set.Kanalbelegung[5] = cb_2_6->currentIndex() + 1;
913
    t_Set.Kanalbelegung[6] = cb_2_7->currentIndex() + 1;
914
    t_Set.Kanalbelegung[7] = cb_2_8->currentIndex() + 1;
915
    t_Set.Kanalbelegung[8] = cb_2_9->currentIndex() + 1;
916
    t_Set.Kanalbelegung[9] = cb_2_10->currentIndex() + 1;
917
    t_Set.Kanalbelegung[10] = cb_2_11->currentIndex() + 1;
918
    t_Set.Kanalbelegung[11] = cb_2_12->currentIndex() + 1;
919
    t_Set.Receiver = s_2_13_cb->currentIndex();
920
    }
921
    // Seite 3
922
    {
923
    t_Set.Stick_P = sb_3_1->value();
924
    t_Set.Stick_D = sb_3_2->value();
925
    t_Set.Gier_P  = get_Value(cb_3_3);
926
    t_Set.ExternalControl = get_Value(cb_3_4);
927
    }
928
    // Seite 4
929
    {
930
    t_Set.MaxHoehe           = get_Value(cb_4_1);
931
    t_Set.Hoehe_MinGas       = sb_4_2->value();
932
    t_Set.Hoehe_P            = get_Value(cb_4_3);
933
    t_Set.Luftdruck_D        = get_Value(cb_4_4);
934
    t_Set.Hoehe_ACC_Wirkung  = get_Value(cb_4_5);
935
    t_Set.Hoehe_Verstaerkung = sb_4_6->value();
936
    t_Set.Hoehe_HoverBand    = sb_4_7->value();
937
    t_Set.Hoehe_GPS_Z        = get_Value(cb_4_8);
938
    t_Set.Hoehe_StickNeutralPoint = sb_4_9->value();
939
 
940
    if (s_4_2_rb->isChecked())
941
        t_Set.ExtraConfig = t_Set.ExtraConfig | CFG2_HEIGHT_LIMIT;
942
    if (s_4_4_cb->isChecked())
943
        t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_HOEHEN_SCHALTER;
944
    if (s_4_5_cb->isChecked())
945
        t_Set.ExtraConfig = t_Set.ExtraConfig | CFG2_VARIO_BEEP;
946
    }
947
    // Seite 5
948
    {
949
    t_Set.Gyro_P           = get_Value(cb_5_1);
950
    t_Set.Gyro_I           = get_Value(cb_5_2);
951
    t_Set.Gyro_D           = get_Value(cb_5_8);
952
    t_Set.DynamicStability = get_Value(cb_5_3);
953
    t_Set.GyroAccFaktor    = sb_5_4->value();
954
    t_Set.GyroAccAbgleich  = sb_5_5->value();
955
    t_Set.I_Faktor         = get_Value(cb_5_6);
956
    t_Set.Driftkomp        = sb_5_7->value();
957
    t_Set.Gyro_Gier_P      = get_Value(cb_5_9);
958
    t_Set.Gyro_Gier_I      = get_Value(cb_5_10);
959
    }
960
    // Seite 6
961
    {
962
    t_Set.ServoNickControl = get_Value(cb_6_1);
963
    t_Set.ServoNickComp    = sb_6_2->value();
964
    t_Set.ServoNickMin     = sb_6_3->value();
965
    t_Set.ServoNickMax     = sb_6_4->value();
966
 
967
    t_Set.ServoRollControl = get_Value(cb_6_7);
968
    t_Set.ServoRollComp    = sb_6_8->value();
969
    t_Set.ServoRollMin     = sb_6_10->value();
970
    t_Set.ServoRollMax     = sb_6_11->value();
971
 
972
    t_Set.ServoNickRefresh = sb_6_5->value();
973
 
974
    t_Set.Servo3 = get_Value(cb_6_12);
975
    t_Set.Servo4 = get_Value(cb_6_13);
976
    t_Set.Servo5 = get_Value(cb_6_14);
977
 
978
    if (cb_6_6->isChecked())
979
        t_Set.ServoCompInvert = t_Set.ServoCompInvert | 0x01;
980
    if (cb_6_9->isChecked())
981
        t_Set.ServoCompInvert = t_Set.ServoCompInvert | 0x02;
982
    }
983
    // Seite 7
984
    {
985
    t_Set.Gas_Min               = sb_7_1->value();
986
    t_Set.Gas_Max               = sb_7_2->value();
987
    t_Set.KompassWirkung        = get_Value(cb_7_3);
988
    t_Set.UnterspannungsWarnung = sb_7_4->value();
989
    t_Set.NotGasZeit            = sb_7_5->value();
990
    t_Set.NotGas                = sb_7_6->value();
991
    }
992
    // Seite 8
993
    {
994
    t_Set.AchsKopplung1         = get_Value(cb_8_1);
995
    t_Set.AchsKopplung2         = get_Value(cb_8_2);
996
    t_Set.CouplingYawCorrection = get_Value(cb_8_3);
997
    }
998
    // Seite 9
999
    {
1000
    t_Set.BitConfig = 0;
1001
    if (tb_9_6->text() == QString("1"))
1002
        t_Set.BitConfig = t_Set.BitConfig | 0x01;
1003
    if (tb_9_7->text() == QString("1"))
1004
        t_Set.BitConfig = t_Set.BitConfig | 0x02;
1005
    if (tb_9_8->text() == QString("1"))
1006
        t_Set.BitConfig = t_Set.BitConfig | 0x04;
1007
    if (tb_9_9->text() == QString("1"))
1008
        t_Set.BitConfig = t_Set.BitConfig | 0x08;
1009
 
1010
 
1011
    t_Set.LoopGasLimit       = get_Value(cb_9_1);
1012
    t_Set.LoopThreshold      = sb_9_2->value();
1013
    t_Set.WinkelUmschlagNick = sb_9_3->value();
1014
    t_Set.LoopHysterese      = sb_9_4->value();
1015
    t_Set.WinkelUmschlagRoll = sb_9_5->value();
1016
    }
1017
    // Seite 10
1018
    {
1019
    t_Set.UserParam1 = get_Value(cb_10_1);
1020
    t_Set.UserParam2 = get_Value(cb_10_2);
1021
    t_Set.UserParam3 = get_Value(cb_10_3);
1022
    t_Set.UserParam4 = get_Value(cb_10_4);
1023
    t_Set.UserParam5 = get_Value(cb_10_5);
1024
    t_Set.UserParam6 = get_Value(cb_10_6);
1025
    t_Set.UserParam7 = get_Value(cb_10_7);
1026
    t_Set.UserParam8 = get_Value(cb_10_8);
1027
    }
1028
    // Seite 11
1029
    {
1030
    t_Set.J16Bitmask = sb_11_1->value();
1031
    t_Set.J16Timing  = get_Value(cb_11_2);
1032
    t_Set.J17Bitmask = sb_11_3->value();
1033
    t_Set.J17Timing  = get_Value(cb_11_4);
1034
    t_Set.WARN_J16_Bitmask = sb_11_5->value();
1035
    t_Set.WARN_J17_Bitmask = sb_11_6->value();
1036
 
1037
    if (cb_11_7->isChecked())
1038
        t_Set.BitConfig = t_Set.BitConfig | CFG_MOTOR_BLINK;
1039
 
1040
    if (!s_11_7_cb->isChecked())
1041
        t_Set.WARN_J16_Bitmask = 0;
1042
    if (!s_11_8_cb->isChecked())
1043
        t_Set.WARN_J17_Bitmask = 0;
1044
 
1045
    }
1046
    // Seite 12
1047
    {
1048
    t_Set.NaviGpsModeControl = get_Value(cb_12_1);
1049
    t_Set.NaviGpsGain        = get_Value(cb_12_2);
1050
    t_Set.NaviStickThreshold = sb_12_3->value();
1051
    t_Set.NaviGpsMinSat      = sb_12_4->value();
1052
    t_Set.NaviGpsP           = get_Value(cb_12_5);
1053
    t_Set.NaviGpsI           = get_Value(cb_12_6);
1054
    t_Set.NaviGpsD           = get_Value(cb_12_7);
1055
    t_Set.NaviGpsACC         = get_Value(cb_12_8);
1056
    t_Set.NaviGpsPLimit      = get_Value(cb_12_9);
1057
    t_Set.NaviGpsILimit      = get_Value(cb_12_10);
1058
    t_Set.NaviGpsDLimit      = get_Value(cb_12_11);
1059
    }
1060
    // Seite 13
1061
    {
1062
    t_Set.NaviWindCorrection    = get_Value(cb_13_1);
1063
    t_Set.NaviSpeedCompensation = get_Value(cb_13_2);
1064
    t_Set.NaviOperatingRadius   = get_Value(cb_13_3);
1065
    t_Set.NaviAngleLimitation   = get_Value(cb_13_4);
1066
    t_Set.NaviPH_LoginTime      = sb_13_5->value();
1067
    }
1068
 
1069
    return t_Set;
1070
}
1071
 
1072
int dlg_Main::get_Value(QComboBox *Combo)
1073
{
1074
    if (Combo->currentText() == QString("Poti 1"))
1075
        return 255;
1076
    if (Combo->currentText() == QString("Poti 2"))
1077
        return 254;
1078
    if (Combo->currentText() == QString("Poti 3"))
1079
        return 253;
1080
    if (Combo->currentText() == QString("Poti 4"))
1081
        return 252;
1082
    if (Combo->currentText() == QString("Poti 5"))
1083
        return 251;
1084
    if (Combo->currentText() == QString("Poti 6"))
1085
        return 250;
1086
    if (Combo->currentText() == QString("Poti 7"))
1087
        return 249;
1088
    if (Combo->currentText() == QString("Poti 8"))
1089
        return 248;
1090
    return Combo->currentText().toInt();
1091
}
1092
 
1093
QComboBox *dlg_Main::setCombo(QComboBox *Combo, int Wert)
1094
{
1095
    if (Wert <= 245)
1096
    {
1097
        Combo->setItemText(8, QString("%1").arg(Wert));
1098
        Combo->setCurrentIndex(8);
1099
    }
1100
    else
1101
    {
1102
        Combo->setCurrentIndex(255 - Wert);
1103
    }
1104
    return Combo;
1105
}
1106
 
1107
void dlg_Main::set_LED(QToolButton *ToolButton, bool On)
1108
{
1109
    QIcon Icons[2] ;
1110
    Icons[0].addPixmap(QPixmap(QString::fromUtf8(":/Flags/Global/Images/Actions/LED_Off.png")), QIcon::Normal, QIcon::Off);
1111
    Icons[1].addPixmap(QPixmap(QString::fromUtf8(":/Flags/Global/Images/Actions/LED_Red.png")), QIcon::Normal, QIcon::Off);
1112
 
1113
    if (ToolButton->text() == QString("0") && On)
1114
    {
1115
        ToolButton->setIcon(Icons[1]);
1116
        ToolButton->setText("1");
1117
    }
1118
    else if (ToolButton->text() == QString("1") && !On)
1119
    {
1120
        ToolButton->setIcon(Icons[0]);
1121
        ToolButton->setText("0");
1122
    }
1123
    else if (ToolButton->text() == QString("00") && On)
1124
    {
1125
        ToolButton->setIcon(Icons[1]);
1126
        ToolButton->setText("11");
1127
    }
1128
    else if (ToolButton->text() == QString("11") && !On)
1129
    {
1130
        ToolButton->setIcon(Icons[0]);
1131
        ToolButton->setText("00");
1132
    }
1133
    else if (ToolButton->text() == QString("000") && On)
1134
    {
1135
        ToolButton->setIcon(Icons[1]);
1136
        ToolButton->setText("111");
1137
    }
1138
    else if (ToolButton->text() == QString("111") && !On)
1139
    {
1140
        ToolButton->setIcon(Icons[0]);
1141
        ToolButton->setText("000");
1142
    }
1143
    else if (ToolButton->text() == QString("0000") && On)
1144
    {
1145
        ToolButton->setIcon(Icons[1]);
1146
        ToolButton->setText("1111");
1147
    }
1148
    else if (ToolButton->text() == QString("1111") && !On)
1149
    {
1150
        ToolButton->setIcon(Icons[0]);
1151
        ToolButton->setText("0000");
1152
    }
1153
}
1154
 
1155
void dlg_Main::slot_LEDtoValue()
1156
{
1157
    QToolButton *ToolButton = (QToolButton*)sender();
1158
 
1159
         if (ToolButton->text() == QString("0"))
1160
    {
1161
        set_LED(ToolButton, true);
1162
        sb_11_1->setValue(sb_11_1->value() + ToolButton->toolTip().toInt());
1163
    }
1164
    else if (ToolButton->text() == QString("1"))
1165
    {
1166
        set_LED(ToolButton);
1167
        sb_11_1->setValue(sb_11_1->value() - ToolButton->toolTip().toInt());
1168
    }
1169
 
1170
    else if (ToolButton->text() == QString("00"))
1171
    {
1172
        set_LED(ToolButton, true);
1173
        sb_11_3->setValue(sb_11_3->value() + ToolButton->toolTip().toInt());
1174
    }
1175
    else if (ToolButton->text() == QString("11"))
1176
    {
1177
        set_LED(ToolButton);
1178
        sb_11_3->setValue(sb_11_3->value() - ToolButton->toolTip().toInt());
1179
    }
1180
 
1181
    else if (ToolButton->text() == QString("000"))
1182
    {
1183
        set_LED(ToolButton, true);
1184
        sb_11_5->setValue(sb_11_5->value() + ToolButton->toolTip().toInt());
1185
    }
1186
    else if (ToolButton->text() == QString("111"))
1187
    {
1188
        set_LED(ToolButton);
1189
        sb_11_5->setValue(sb_11_5->value() - ToolButton->toolTip().toInt());
1190
    }
1191
 
1192
    else if (ToolButton->text() == QString("0000"))
1193
    {
1194
        set_LED(ToolButton, true);
1195
        sb_11_6->setValue(sb_11_6->value() + ToolButton->toolTip().toInt());
1196
    }
1197
    else if (ToolButton->text() == QString("1111"))
1198
    {
1199
        set_LED(ToolButton);
1200
        sb_11_6->setValue(sb_11_6->value() - ToolButton->toolTip().toInt());
1201
    }
1202
 
1203
 
1204
}
1205
 
1206
void dlg_Main::slot_ValuetoLED16(int Wert)
1207
{
1208
    set_LED(J16_0, Wert & 0x80);
1209
    set_LED(J16_1, Wert & 0x40);
1210
    set_LED(J16_2, Wert & 0x20);
1211
    set_LED(J16_3, Wert & 0x10);
1212
    set_LED(J16_4, Wert & 0x08);
1213
    set_LED(J16_5, Wert & 0x04);
1214
    set_LED(J16_6, Wert & 0x02);
1215
    set_LED(J16_7, Wert & 0x01);
1216
}
1217
 
1218
void dlg_Main::slot_ValuetoLED17(int Wert)
1219
{
1220
    set_LED(J17_0, Wert & 0x80);
1221
    set_LED(J17_1, Wert & 0x40);
1222
    set_LED(J17_2, Wert & 0x20);
1223
    set_LED(J17_3, Wert & 0x10);
1224
    set_LED(J17_4, Wert & 0x08);
1225
    set_LED(J17_5, Wert & 0x04);
1226
    set_LED(J17_6, Wert & 0x02);
1227
    set_LED(J17_7, Wert & 0x01);
1228
}
1229
 
1230
void dlg_Main::slot_ValuetoLED16A(int Wert)
1231
{
1232
    set_LED(J16_A_0, Wert & 0x80);
1233
    set_LED(J16_A_1, Wert & 0x40);
1234
    set_LED(J16_A_2, Wert & 0x20);
1235
    set_LED(J16_A_3, Wert & 0x10);
1236
    set_LED(J16_A_4, Wert & 0x08);
1237
    set_LED(J16_A_5, Wert & 0x04);
1238
    set_LED(J16_A_6, Wert & 0x02);
1239
    set_LED(J16_A_7, Wert & 0x01);
1240
}
1241
 
1242
void dlg_Main::slot_ValuetoLED17A(int Wert)
1243
{
1244
    set_LED(J17_A_0, Wert & 0x80);
1245
    set_LED(J17_A_1, Wert & 0x40);
1246
    set_LED(J17_A_2, Wert & 0x20);
1247
    set_LED(J17_A_3, Wert & 0x10);
1248
    set_LED(J17_A_4, Wert & 0x08);
1249
    set_LED(J17_A_5, Wert & 0x04);
1250
    set_LED(J17_A_6, Wert & 0x02);
1251
    set_LED(J17_A_7, Wert & 0x01);
1252
}
1253
 
1254
void dlg_Main::slot_tbUp()
1255
{
1256
    if (tb_9_6->text() == QString("0"))
1257
    {
1258
        tb_9_6->setText("1");
1259
    }
1260
    else
1261
    {
1262
        tb_9_6->setText("0");
1263
    }
1264
}
1265
 
1266
void dlg_Main::slot_tbDown()
1267
{
1268
    if (tb_9_7->text() == QString("0"))
1269
    {
1270
        tb_9_7->setText("1");
1271
    }
1272
    else
1273
    {
1274
        tb_9_7->setText("0");
1275
    }
1276
}
1277
 
1278
void dlg_Main::slot_tbLeft()
1279
{
1280
    if (tb_9_8->text() == QString("0"))
1281
    {
1282
        tb_9_8->setText("1");
1283
    }
1284
    else
1285
    {
1286
        tb_9_8->setText("0");
1287
    }
1288
}
1289
 
1290
void dlg_Main::slot_tbRight()
1291
{
1292
    if (tb_9_9->text() == QString("0"))
1293
    {
1294
        tb_9_9->setText("1");
1295
    }
1296
    else
1297
    {
1298
        tb_9_9->setText("0");
1299
    }
1300
}
1301
 
1302
// Programm Ende
1303
dlg_Main::~dlg_Main()
1304
{
1305
    o_Settings->GUI.isMax       = isMaximized();
1306
    o_Settings->GUI.Size        = size();
1307
    o_Settings->GUI.Point       = pos();
1308
    o_Settings->GUI.Toolbar     = ac_Toolbar->isChecked();
1309
 
1310
    o_Settings->write_Settings();
1311
//    qDebug("Ende.");
1312
}