Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 673 → Rev 674

/QMK-Groundstation/trunk/QMK-Settings/Dialogs/dlg_Main.cpp
0,0 → 1,1399
/***************************************************************************
* Copyright (C) 2009 by Manuel Schrape *
* manuel.schrape@gmx.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
 
#include "dlg_Main.h"
 
// Konstruktor Main-Form
dlg_Main::dlg_Main()
{
setupUi(this);
 
o_Settings = new cSettings();
 
o_Input = new Input();
 
o_Timer = new QTimer();
o_Timer->setInterval(500);
 
f_MotorMixer = new dlg_MotorMixer(this);
 
init_Directorys();
init_GUI();
init_Connections();
}
 
// Grafische Oberfläche initialisieren
void dlg_Main::init_GUI()
{
setWindowTitle(QA_NAME + " " + QA_VERSION);
 
resize(o_Settings->GUI.Size);
move(o_Settings->GUI.Point);
 
if (o_Settings->GUI.isMax)
{
showMaximized();
}
 
for(int z = 0; z < o_Settings->SERVER.IP_MAX; z++)
{
if (cb_Server->findText(o_Settings->SERVER.IP[z]) == -1)
{
cb_Server->addItem(o_Settings->SERVER.IP[z]);
}
}
 
cb_Server->setCurrentIndex(o_Settings->SERVER.IP_ID);
 
le_Password->setText(o_Settings->SERVER.Password);
}
 
// Signale mit Slots verbinden
void dlg_Main::init_Connections()
{
connect(o_Timer, SIGNAL(timeout()), this, SLOT(slot_Timer()));
 
connect(ac_Connect, SIGNAL(triggered()), this, SLOT(slot_ac_Connect()));
 
connect(ac_Write, SIGNAL(triggered()), this, SLOT(slot_ac_Write()));
connect(ac_Read, SIGNAL(triggered()), this, SLOT(slot_ac_Read()));
connect(ac_Save, SIGNAL(triggered()), this, SLOT(slot_ac_Save()));
connect(ac_Load, SIGNAL(triggered()), this, SLOT(slot_ac_Load()));
 
connect(ac_MotorMixer, SIGNAL(triggered()), this, SLOT(slot_ac_MotorMixer()));
 
// About QMK-Settings & About-QT Dialog einfügen
connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About()));
menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt()));
 
connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(slot_PageChange(int)));
 
// Settings - LED's J16
connect(J16_0, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_1, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_2, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_3, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_4, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_5, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_6, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_7, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
 
// Settings - LED's J17
connect(J17_0, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_1, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_2, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_3, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_4, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_5, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_6, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_7, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
 
// Settings - LED's J16
connect(J16_A_0, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_A_1, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_A_2, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_A_3, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_A_4, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_A_5, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_A_6, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J16_A_7, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
 
// Settings - LED's J17
connect(J17_A_0, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_A_1, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_A_2, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_A_3, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_A_4, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_A_5, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_A_6, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
connect(J17_A_7, SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
 
connect(sb_11_1, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED16(int)));
connect(sb_11_3, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED17(int)));
connect(sb_11_5, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED16A(int)));
connect(sb_11_6, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED17A(int)));
 
connect(tb_9_6, SIGNAL(clicked()), this, SLOT(slot_tbUp()));
connect(tb_9_7, SIGNAL(clicked()), this, SLOT(slot_tbDown()));
connect(tb_9_8, SIGNAL(clicked()), this, SLOT(slot_tbLeft()));
connect(tb_9_9, SIGNAL(clicked()), this, SLOT(slot_tbRight()));
}
 
void dlg_Main::init_Directorys()
{
QDir *t_Dir = new QDir();
 
s_Dir.MainData = QDir::homePath() + "/QMK-Data";
if (!t_Dir->exists(s_Dir.MainData))
{
t_Dir->mkdir(s_Dir.MainData);
}
 
s_Dir.Settings = s_Dir.MainData + "/Settings";
if (!t_Dir->exists(s_Dir.Settings))
{
t_Dir->mkdir(s_Dir.Settings);
}
}
 
void dlg_Main::parse_IP_Data(QString t_Data)
{
QStringList Data;
Data = t_Data.split(":");
 
if (Data.count() > 1)
{
int CMD = Data[2].toInt();
 
switch(CMD)
{
case 501 :
{
o_Input->send_Data(HandlerIP::make_Frame(ID_SETTINGS, 105, le_Password->text()));
}
break;
case 505 :
{
if (Data[3] == "OK")
{
}
else
{
QMessageBox::warning(this, QA_NAME, trUtf8("Authentifizierung fehlgeschlagen. <br />Daten senden zum Mikrokopter nicht möglich."), QMessageBox::Ok);
}
}
break;
}
}
}
 
// Eingangsdaten verarbeiten
void dlg_Main::parse_MK_Data(QString t_Data)
{
unsigned char OutData[150];
char *InData = t_Data.toLatin1().data();
 
if (HandlerMK::Decode_64(InData, t_Data.length(), OutData) != 0)
{
switch(InData[2])
{
case 'V' : // Versions-Info
{
o_Input->stop_Resend(DATA_VERSION);
VersionInfo = HandlerMK::parse_Version(OutData, InData[1] - 'a');
setWindowTitle(QA_NAME + " " + QA_VERSION + " - " + VersionInfo.Hardware + " " + VersionInfo.Version);
 
if (VersionInfo.ID == ADDRESS_FC)
{
// qDebug("get FC-Settings");
c_Data[0] = 0xff;
o_Input->send_Data(HandlerMK::make_Frame('q', ADDRESS_FC, c_Data, 1).toLatin1().data(), DATA_READ_SETTINGS);
}
}
break;
case 'Q' : // Settings lesen
{
o_Input->stop_Resend(DATA_READ_SETTINGS);
if (OutData[1] == MK_VERSION_SETTINGS)
{
s_MK_Settings MK_Set;
 
memcpy((unsigned char *)&MK_Set, (unsigned char *)&OutData, sizeof(MK_Set));
// qDebug(MK_Set.Name);
show_MK_Settings(MK_Set);
}
else
{
QMessageBox::warning(this, QA_NAME, tr("Versionen inkompatibel. \nParameterbearbeitung nicht moeglich."), QMessageBox::Ok);
ac_Read->setEnabled(false);
ac_Write->setEnabled(false);
}
}
break;
case 'S' : // Settings geschrieben
{
o_Input->stop_Resend(DATA_WRITE_SETTINGS);
if (OutData[0] == 0)
{
QMessageBox::warning(this, QA_NAME, tr("Fehler beim Settings-Schreiben."), QMessageBox::Ok);
}
}
break;
case 'P' : // RC-Kanäle
{
int PPM_in[11];
 
memcpy((unsigned char *)&PPM_in, (unsigned char *)&OutData, sizeof(PPM_in));
pb_K1->setValue(PPM_in[0]);
pb_K2->setValue(PPM_in[1]);
pb_K3->setValue(PPM_in[2]);
pb_K4->setValue(PPM_in[3]);
pb_K5->setValue(PPM_in[4]);
pb_K6->setValue(PPM_in[5]);
pb_K7->setValue(PPM_in[6]);
pb_K8->setValue(PPM_in[7]);
}
break;
case 'N' : // MotorMixer lesen
{
o_Input->stop_Resend(DATA_READ_MIXER);
 
s_MK_Mixer MK_Mixer;
 
memcpy((unsigned char *)&MK_Mixer, (unsigned char *)&OutData, sizeof(MK_Mixer));
 
if (MK_Mixer.Revision == MK_VERSION_MIXER)
{
f_MotorMixer->set_MotorConfig(MK_Mixer);
}
}
break;
case 'M' : // MotorMixer geschrieben
{
o_Input->stop_Resend(DATA_WRITE_MIXER);
 
if (OutData[0] == 0)
{
QMessageBox::warning(this, QA_NAME, tr("Fehler beim MotorMixer-Schreiben."), QMessageBox::Ok);
}
}
break;
 
}
}
}
 
///////////
// Slots //
///////////
 
// About-Dialog
void dlg_Main::slot_ac_About()
{
QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT);
}
 
// Verbindung zum Server aufbauen
void dlg_Main::slot_ac_Connect()
{
if (!o_Input->IsOpen())
{
if (cb_Server->findText(cb_Server->currentText()) == -1)
{
cb_Server->addItem(cb_Server->currentText());
cb_Server->setCurrentIndex(cb_Server->findText(cb_Server->currentText()));
}
 
cb_Server->setEnabled(false);
le_Password->setEnabled(false);
 
if (cb_Server->currentText().startsWith('/'))
{
o_Input = new Input_TTY();
o_Input->Init();
 
set_Input s_Input;
s_Input.Main = cb_Server->currentText();
 
if (o_Input->Open(s_Input) == true)
{
ac_Connect->setText(tr("Trennen"));
connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString)));
 
o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION);
}
else
{
cb_Server->setEnabled(true);
le_Password->setEnabled(true);
}
 
}
else
{
o_Input = new Input_TCP();
o_Input->Init();
 
set_Input s_Input;
 
QStringList Server = cb_Server->currentText().split(":");
 
s_Input.Main = Server[0];
s_Input.Sub = Server[1];
 
if (o_Input->Open(s_Input) == true)
{
connect(o_Input, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_Input_Disconnected(int)));
connect(o_Input, SIGNAL(sig_Connected()), this, SLOT(slot_Input_Connected()));
}
}
}
else
{
cb_Server->setEnabled(true);
le_Password->setEnabled(true);
 
ac_Connect->setText(tr("Verbinden"));
o_Input->Close();
disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0);
if (o_Input->Mode() == TCP)
{
disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0);
disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0);
}
}
}
 
// Neue Daten empfangen.
void dlg_Main::slot_Input_Data(QString t_Data)
{
if ((t_Data[0] == '#'))
{
if ((HandlerMK::Check_CRC(t_Data.toLatin1().data(), t_Data.length() - 1)) || ((o_Input->Mode() == TTY) && (HandlerMK::Check_CRC(t_Data.toLatin1().data(), t_Data.length()))))
{
parse_MK_Data(t_Data);
}
else
{
// qDebug(QString("CRC-Error - " + t_Data).toLatin1().data());
}
}
else if (o_Input->Mode() == TCP)
{
parse_IP_Data(t_Data);
}
}
 
void dlg_Main::slot_Input_Disconnected(int Error)
{
cb_Server->setEnabled(true);
le_Password->setEnabled(true);
 
// qDebug("Close");
disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0);
if (o_Input->Mode() == TCP)
{
disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0);
disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0);
}
ac_Connect->setChecked(false);
ac_Connect->setText(tr("Verbinden"));
 
switch (Error)
{
case REMOTECLOSED :
{
// lb_Status->setText(tr("Verbindung vom Server beendet."));
QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Verbindung wurde vom Server beendet."), QMessageBox::Ok);
}
break;
case REFUSED :
{
// lb_Status->setText(tr("Server nicht gefunden."));
QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Kann nicht zum Server verbinden."), QMessageBox::Ok);
}
break;
case 3 :
{
// lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch."));
QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Loginname oder Password falsch."), QMessageBox::Ok);
}
break;
default :
{
// lb_Status->setText(tr("Getrennt vom QMK-Datenserver."));
}
break;
}
 
}
 
void dlg_Main::slot_Input_Connected()
{
connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString)));
 
o_Input->send_Data(HandlerIP::make_Frame(ID_SETTINGS, 101, QA_NAME + " " + QA_VERSION));
o_Input->send_Data(HandlerMK::make_Frame('v', ADDRESS_ALL, c_Data, 0).toLatin1().data(), DATA_VERSION);
ac_Connect->setText(tr("Trennen"));
}
 
///////////////////////////////////////////////////////////////////
// QMK-Settings //
///////////////////////////////////////////////////////////////////
 
void dlg_Main::slot_PageChange(int Page)
{
if (Page == 1)
o_Timer->start();
else
o_Timer->stop();
}
 
void dlg_Main::slot_Timer()
{
o_Input->send_Data(HandlerMK::make_Frame('p', ADDRESS_FC, c_Data, 0).toLatin1().data(), 0);
}
 
void dlg_Main::slot_ac_MotorMixer()
{
f_MotorMixer->set_Objects(o_Input, o_Settings, s_Dir);
f_MotorMixer->read_Mixer();
 
if (f_MotorMixer->exec()==QDialog::Accepted)
{
}
}
 
// Settings-Funktionen
void dlg_Main::slot_ac_Write()
{
s_MK_Settings t_Set;
 
t_Set = get_MK_Settings();
 
memcpy((unsigned char *)&c_Data, (unsigned char *)&t_Set, sizeof(t_Set));
 
o_Input->send_Data(HandlerMK::make_Frame('s', ADDRESS_FC, c_Data, sizeof(t_Set)).toLatin1().data(), DATA_WRITE_SETTINGS);
}
 
void dlg_Main::slot_ac_Read()
{
c_Data[0] = sb_Set->value();
o_Input->send_Data(HandlerMK::make_Frame('q', ADDRESS_FC, c_Data, 1).toLatin1().data(), DATA_READ_SETTINGS);
}
 
void dlg_Main::slot_ac_Save()
{
QString Filename = QFileDialog::getSaveFileName(this, "Mikrokopter Parameter speichern", s_Dir.Settings + "/" + VersionInfo.VersionShort + "_" + le_SetName->text() + ".mkp", "Mikrokopter Parameter(*.mkp);;Alle Dateien (*)");
 
if (!Filename.isEmpty())
{
if (!(Filename.endsWith(".mkp", Qt::CaseInsensitive)))
{
Filename = Filename + QString(".mkp");
}
 
s_MK_Settings t_Set = get_MK_Settings();
 
QSettings Setting(Filename, QSettings::IniFormat);
 
Setting.beginGroup("Setup");
Setting.setValue("Name", le_SetName->text());
Setting.setValue("IniVersion", 3);
Setting.setValue("GlobalConfig", t_Set.GlobalConfig);
Setting.setValue("GlobalConfig2", t_Set.ExtraConfig);
Setting.endGroup();
 
Setting.beginGroup("Channels");
Setting.setValue("Nick", t_Set.Kanalbelegung[0]);
Setting.setValue("Roll", t_Set.Kanalbelegung[1]);
Setting.setValue("Gas", t_Set.Kanalbelegung[2]);
Setting.setValue("Gier", t_Set.Kanalbelegung[3]);
Setting.setValue("Poti_1", t_Set.Kanalbelegung[4]);
Setting.setValue("Poti_2", t_Set.Kanalbelegung[5]);
Setting.setValue("Poti_3", t_Set.Kanalbelegung[6]);
Setting.setValue("Poti_4", t_Set.Kanalbelegung[7]);
Setting.endGroup();
 
Setting.beginGroup("Stick");
Setting.setValue("Nick_Roll-P", t_Set.Stick_P);
Setting.setValue("Nick_Roll-D", t_Set.Stick_D);
Setting.setValue("Gier-P", t_Set.Gier_P);
Setting.setValue("ExternalControl", t_Set.ExternalControl);
Setting.endGroup();
 
Setting.beginGroup("Altitude");
Setting.setValue("Setpoint", t_Set.MaxHoehe);
Setting.setValue("MinGas", t_Set.Hoehe_MinGas);
Setting.setValue("P", t_Set.Hoehe_P);
Setting.setValue("Barometric-D", t_Set.Luftdruck_D);
Setting.setValue("Z-ACC-Effect", t_Set.Hoehe_ACC_Wirkung);
Setting.setValue("Gain", t_Set.Hoehe_Verstaerkung);
Setting.setValue("HoverVariation", t_Set.Hoehe_HoverBand);
Setting.setValue("GPS_Z", t_Set.Hoehe_GPS_Z);
Setting.setValue("StickNeutralPoint", t_Set.Hoehe_StickNeutralPoint);
Setting.endGroup();
 
Setting.beginGroup("Gyro");
Setting.setValue("P", t_Set.Gyro_P);
Setting.setValue("I", t_Set.Gyro_I);
Setting.setValue("D", t_Set.Gyro_D);
Setting.setValue("Gier_P", t_Set.Gyro_Gier_P);
Setting.setValue("Gier_I", t_Set.Gyro_Gier_I);
Setting.setValue("DynamicStability", t_Set.DynamicStability);
Setting.setValue("ACC_Gyro-Factor", t_Set.GyroAccFaktor);
Setting.setValue("ACC_Gyro-Compensation", t_Set.GyroAccAbgleich);
Setting.setValue("DriftCompensation", t_Set.Driftkomp);
Setting.setValue("Main-I", t_Set.I_Faktor);
Setting.endGroup();
 
Setting.beginGroup("Camera");
Setting.setValue("ServoNickControl", t_Set.ServoNickControl);
Setting.setValue("ServoNickCompensation", t_Set.ServoNickComp);
Setting.setValue("ServoNickMin", t_Set.ServoNickMin);
Setting.setValue("ServoNickMax", t_Set.ServoNickMax);
 
Setting.setValue("ServoRollControl", t_Set.ServoRollControl);
Setting.setValue("ServoRollCompensation", t_Set.ServoRollComp);
Setting.setValue("ServoRollMin", t_Set.ServoRollMin);
Setting.setValue("ServoRollMax", t_Set.ServoRollMax);
 
Setting.setValue("ServoInvert", t_Set.ServoCompInvert);
Setting.setValue("ServoNickRefreshRate", t_Set.ServoNickRefresh);
Setting.endGroup();
 
Setting.beginGroup("Others");
Setting.setValue("MinGas", t_Set.Gas_Min);
Setting.setValue("MaxGas", t_Set.Gas_Max);
Setting.setValue("Compass-Effect", t_Set.KompassWirkung);
Setting.setValue("UnderVoltage", t_Set.UnterspannungsWarnung);
Setting.setValue("NotGas", t_Set.NotGas);
Setting.setValue("NotGasTime", t_Set.NotGasZeit);
Setting.endGroup();
 
Setting.beginGroup("Coupling");
Setting.setValue("YawPosFeedback", t_Set.AchsKopplung1);
Setting.setValue("NickRollFeedback", t_Set.AchsKopplung2);
Setting.setValue("YawCorrection", t_Set.CouplingYawCorrection);
Setting.endGroup();
 
Setting.beginGroup("Loop");
Setting.setValue("Config", t_Set.BitConfig);
Setting.setValue("GasLimit", t_Set.LoopGasLimit);
Setting.setValue("StickThreshold", t_Set.LoopThreshold);
Setting.setValue("LoopHysteresis", t_Set.LoopHysterese);
Setting.setValue("TurnOverNick", t_Set.WinkelUmschlagNick);
Setting.setValue("TurnOverRoll", t_Set.WinkelUmschlagRoll);
 
Setting.beginGroup("User");
Setting.setValue("Parameter_1", t_Set.UserParam1);
Setting.setValue("Parameter_2", t_Set.UserParam2);
Setting.setValue("Parameter_3", t_Set.UserParam3);
Setting.setValue("Parameter_4", t_Set.UserParam4);
Setting.setValue("Parameter_5", t_Set.UserParam5);
Setting.setValue("Parameter_6", t_Set.UserParam6);
Setting.setValue("Parameter_7", t_Set.UserParam7);
Setting.setValue("Parameter_8", t_Set.UserParam8);
Setting.endGroup();
 
Setting.beginGroup("Output");
Setting.setValue("J16_Bitmask", t_Set.J16Bitmask);
Setting.setValue("J16_Timing", t_Set.J16Timing);
Setting.setValue("J17_Bitmask", t_Set.J17Bitmask);
Setting.setValue("J17_Timing", t_Set.J17Timing);
Setting.setValue("WARN_J16_Bitmask", t_Set.WARN_J16_Bitmask);
Setting.setValue("WARN_J17_Bitmask", t_Set.WARN_J17_Bitmask);
Setting.endGroup();
 
Setting.beginGroup("NaviCtrl");
Setting.setValue("GPS_ModeControl", t_Set.NaviGpsModeControl);
Setting.setValue("GPS_Gain", t_Set.NaviGpsGain);
Setting.setValue("GPS_P", t_Set.NaviGpsP);
Setting.setValue("GPS_I", t_Set.NaviGpsI);
Setting.setValue("GPS_D", t_Set.NaviGpsD);
Setting.setValue("GPS_P_Limit", t_Set.NaviGpsPLimit);
Setting.setValue("GPS_I_Limit", t_Set.NaviGpsILimit);
Setting.setValue("GPS_D_Limit", t_Set.NaviGpsDLimit);
Setting.setValue("GPS_Acc", t_Set.NaviGpsACC);
Setting.setValue("GPS_MinSat", t_Set.NaviGpsMinSat);
Setting.setValue("GPS_StickThreshold", t_Set.NaviStickThreshold);
Setting.setValue("GPS_WindCorrection", t_Set.NaviWindCorrection);
Setting.setValue("GPS_SpeedCompensation", t_Set.NaviSpeedCompensation);
Setting.setValue("GPS_MaxRadius", t_Set.NaviOperatingRadius);
Setting.setValue("GPS_AngleLimit", t_Set.NaviAngleLimitation);
Setting.setValue("GPS_PH_Login_Time", t_Set.NaviPH_LoginTime);
Setting.endGroup();
}
}
 
void dlg_Main::slot_ac_Load()
{
QString Filename = QFileDialog::getOpenFileName(this, "Mikrokopter Parameter laden", s_Dir.Settings + "", "Mikrokopter Parameter(*.mkp);;Alle Dateien (*)");
 
if (!Filename.isEmpty())
{
s_MK_Settings t_Set = get_MK_Settings();
 
t_Set.Index = sb_Set->value();
 
QSettings Setting(Filename, QSettings::IniFormat);
 
Setting.beginGroup("Setup");
QString Name = Setting.value("Name", QString("--noname--")).toString();
 
memcpy(t_Set.Name, Name.toLatin1().data(), 12);
 
t_Set.GlobalConfig = Setting.value("GlobalConfig", 104).toInt();
t_Set.ExtraConfig = Setting.value("GlobalConfig2", 1).toInt();
Setting.endGroup();
 
Setting.beginGroup("Channels");
t_Set.Kanalbelegung[0] = Setting.value("Nick", 1).toInt();
t_Set.Kanalbelegung[1] = Setting.value("Roll", 2).toInt();
t_Set.Kanalbelegung[2] = Setting.value("Gas", 3).toInt();
t_Set.Kanalbelegung[3] = Setting.value("Gier", 4).toInt();
t_Set.Kanalbelegung[4] = Setting.value("Poti_1", 5).toInt();
t_Set.Kanalbelegung[5] = Setting.value("Poti_2", 6).toInt();
t_Set.Kanalbelegung[6] = Setting.value("Poti_3", 7).toInt();
t_Set.Kanalbelegung[7] = Setting.value("Poti_4", 8).toInt();
Setting.endGroup();
 
Setting.beginGroup("Stick");
t_Set.Stick_P = Setting.value("Nick_Roll-P", 10).toInt();
t_Set.Stick_D = Setting.value("Nick_Roll-D", 16).toInt();
t_Set.Gier_P = Setting.value("Gier-P", 6).toInt();
t_Set.ExternalControl = Setting.value("ExternalControl", 0).toInt();
Setting.endGroup();
 
Setting.beginGroup("Altitude");
t_Set.MaxHoehe = Setting.value("Setpoint", 251).toInt();
t_Set.Hoehe_MinGas = Setting.value("MinGas", 30).toInt();
t_Set.Hoehe_P = Setting.value("P", 10).toInt();
t_Set.Luftdruck_D = Setting.value("Barometric-D", 30).toInt();
t_Set.Hoehe_ACC_Wirkung = Setting.value("Z-ACC-Effect", 30).toInt();
t_Set.Hoehe_Verstaerkung = Setting.value("Gain", 15).toInt();
t_Set.Hoehe_HoverBand = Setting.value("HoverVariation", 5).toInt();
t_Set.Hoehe_GPS_Z = Setting.value("GPS_Z", 64).toInt();
t_Set.Hoehe_StickNeutralPoint = Setting.value("StickNeutralPoint", 0).toInt();
Setting.endGroup();
 
Setting.beginGroup("Gyro");
t_Set.Gyro_P = Setting.value("P", 90).toInt();
t_Set.Gyro_I = Setting.value("I", 120).toInt();
t_Set.Gyro_D = Setting.value("D", 3).toInt();
t_Set.Gyro_Gier_P = Setting.value("Gier_P", 100).toInt();
t_Set.Gyro_Gier_I = Setting.value("Gier_I", 120).toInt();
t_Set.DynamicStability = Setting.value("DynamicStability", 75).toInt();
t_Set.GyroAccFaktor = Setting.value("ACC_Gyro-Factor", 30).toInt();
t_Set.GyroAccAbgleich = Setting.value("ACC_Gyro-Compensation", 32).toInt();
t_Set.Driftkomp = Setting.value("DriftCompensation", 32).toInt();
t_Set.I_Faktor = Setting.value("Main-I", 32).toInt();
Setting.endGroup();
 
Setting.beginGroup("Camera");
t_Set.ServoNickControl = Setting.value("ServoNickControl", 100).toInt();
t_Set.ServoNickComp = Setting.value("ServoNickCompensation", 40).toInt();
t_Set.ServoNickMin = Setting.value("ServoNickMin", 0).toInt();
t_Set.ServoNickMax = Setting.value("ServoNickMax", 250).toInt();
 
t_Set.ServoRollControl = Setting.value("ServoRollControl", 100).toInt();
t_Set.ServoRollComp = Setting.value("ServoRollCompensation", 40).toInt();
t_Set.ServoRollMin = Setting.value("ServoRollMin", 0).toInt();
t_Set.ServoRollMax = Setting.value("ServoRollMax", 250).toInt();
 
t_Set.ServoCompInvert = Setting.value("ServoInvert", 0).toInt();
t_Set.ServoNickRefresh = Setting.value("ServoNickRefreshRate", 3).toInt();
Setting.endGroup();
 
Setting.beginGroup("Others");
t_Set.Gas_Min = Setting.value("MinGas", 8).toInt();
t_Set.Gas_Max = Setting.value("MaxGas", 230).toInt();
t_Set.KompassWirkung = Setting.value("Compass-Effect", 128).toInt();
t_Set.UnterspannungsWarnung = Setting.value("UnderVoltage", 99).toInt();
t_Set.NotGas = Setting.value("NotGas", 35).toInt();
t_Set.NotGasZeit = Setting.value("NotGasTime", 30).toInt();
Setting.endGroup();
 
Setting.beginGroup("Coupling");
t_Set.AchsKopplung1 = Setting.value("YawPosFeedback", 90).toInt();
t_Set.AchsKopplung2 = Setting.value("NickRollFeedback", 80).toInt();
t_Set.CouplingYawCorrection = Setting.value("YawCorrection", 60).toInt();
Setting.endGroup();
 
Setting.beginGroup("Loop");
t_Set.BitConfig = Setting.value("Config", 0).toInt();
t_Set.LoopGasLimit = Setting.value("GasLimit", 50).toInt();
t_Set.LoopThreshold = Setting.value("StickThreshold", 90).toInt();
t_Set.LoopHysterese = Setting.value("LoopHysteresis", 50).toInt();
t_Set.WinkelUmschlagNick = Setting.value("TurnOverNick", 85).toInt();
t_Set.WinkelUmschlagRoll = Setting.value("TurnOverRoll", 85).toInt();
Setting.endGroup();
 
Setting.beginGroup("User");
t_Set.UserParam1 = Setting.value("Parameter_1", 0).toInt();
t_Set.UserParam2 = Setting.value("Parameter_2", 0).toInt();
t_Set.UserParam3 = Setting.value("Parameter_3", 0).toInt();
t_Set.UserParam4 = Setting.value("Parameter_4", 0).toInt();
t_Set.UserParam5 = Setting.value("Parameter_5", 0).toInt();
t_Set.UserParam6 = Setting.value("Parameter_6", 0).toInt();
t_Set.UserParam7 = Setting.value("Parameter_7", 0).toInt();
t_Set.UserParam8 = Setting.value("Parameter_8", 0).toInt();
Setting.endGroup();
 
Setting.beginGroup("Output");
t_Set.J16Bitmask = Setting.value("J16_Bitmask", 255).toInt();
t_Set.J16Timing = Setting.value("J16_Timing", 15).toInt();
t_Set.J17Bitmask = Setting.value("J17_Bitmask", 255).toInt();
t_Set.J17Timing = Setting.value("J17_Timing", 15).toInt();
t_Set.WARN_J16_Bitmask = Setting.value("WARN_J16_Bitmask", 0xaa).toInt();
t_Set.WARN_J17_Bitmask = Setting.value("WARN_J17_Bitmask", 0xaa).toInt();
Setting.endGroup();
 
Setting.beginGroup("NaviCtrl");
t_Set.NaviGpsModeControl = Setting.value("GPS_ModeControl", 253).toInt();
t_Set.NaviGpsGain = Setting.value("GPS_Gain", 100).toInt();
t_Set.NaviGpsP = Setting.value("GPS_P", 90).toInt();
t_Set.NaviGpsI = Setting.value("GPS_I", 90).toInt();
t_Set.NaviGpsD = Setting.value("GPS_D", 90).toInt();
t_Set.NaviGpsPLimit = Setting.value("GPS_P_Limit", 75).toInt();
t_Set.NaviGpsILimit = Setting.value("GPS_I_Limit", 75).toInt();
t_Set.NaviGpsDLimit = Setting.value("GPS_D_Limit", 75).toInt();
t_Set.NaviGpsACC = Setting.value("GPS_Acc", 0).toInt();
t_Set.NaviGpsMinSat = Setting.value("GPS_MinSat", 6).toInt();
t_Set.NaviStickThreshold = Setting.value("GPS_StickThreshold", 8).toInt();
t_Set.NaviWindCorrection = Setting.value("GPS_WindCorrection", 90).toInt();
t_Set.NaviSpeedCompensation = Setting.value("GPS_SpeedCompensation", 30).toInt();
t_Set.NaviOperatingRadius = Setting.value("GPS_MaxRadius", 100).toInt();
t_Set.NaviAngleLimitation = Setting.value("GPS_AngleLimit", 100).toInt();
t_Set.NaviPH_LoginTime = Setting.value("GPS_PH_Login_Time", 4).toInt();
Setting.endGroup();
 
show_MK_Settings(t_Set);
}
}
 
void dlg_Main::show_MK_Settings(s_MK_Settings t_Set) // DONE 0.75i
{
sb_Set->setValue(int(t_Set.Index));
 
le_SetName->setText(QString(t_Set.Name));
// Seite 1
{
s_1_1_cb->setChecked(t_Set.GlobalConfig & CFG_HOEHENREGELUNG);
s_1_2_cb->setChecked(t_Set.GlobalConfig & CFG_KOMPASS_AKTIV);
s_1_3_cb->setChecked(t_Set.GlobalConfig & CFG_KOMPASS_FIX);
s_1_4_cb->setChecked(t_Set.GlobalConfig & CFG_GPS_AKTIV);
s_1_5_cb->setChecked(t_Set.ExtraConfig & CFG_SENSITIVE_RC);
s_1_6_cb->setChecked(t_Set.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV);
s_1_7_cb->setChecked(t_Set.GlobalConfig & CFG_DREHRATEN_BEGRENZER);
s_1_8_cb->setChecked(t_Set.GlobalConfig & CFG_HEADING_HOLD);
}
// Seite 2
{
sb_2_1->setValue(t_Set.Kanalbelegung[2]);
sb_2_2->setValue(t_Set.Kanalbelegung[3]);
sb_2_3->setValue(t_Set.Kanalbelegung[0]);
sb_2_4->setValue(t_Set.Kanalbelegung[1]);
sb_2_5->setValue(t_Set.Kanalbelegung[4]);
sb_2_6->setValue(t_Set.Kanalbelegung[5]);
sb_2_7->setValue(t_Set.Kanalbelegung[6]);
sb_2_8->setValue(t_Set.Kanalbelegung[7]);
}
// Seite 3
{
sb_3_1->setValue(t_Set.Stick_P);
sb_3_2->setValue(t_Set.Stick_D);
cb_3_3 = setCombo(cb_3_3, t_Set.Gier_P);
cb_3_4 = setCombo(cb_3_4, t_Set.ExternalControl);
}
// Seite 4
{
s_4_2_rb->setChecked(t_Set.ExtraConfig & CFG2_HEIGHT_LIMIT);
s_4_5_cb->setChecked(t_Set.ExtraConfig & CFG2_VARIO_BEEP);
s_4_4_cb->setChecked(t_Set.GlobalConfig & CFG_HOEHEN_SCHALTER);
 
cb_4_1 = setCombo(cb_4_1, t_Set.MaxHoehe);
sb_4_2->setValue(t_Set.Hoehe_MinGas);
cb_4_3 = setCombo(cb_4_3, t_Set.Hoehe_P);
cb_4_4 = setCombo(cb_4_4, t_Set.Luftdruck_D);
cb_4_5 = setCombo(cb_4_5, t_Set.Hoehe_ACC_Wirkung);
sb_4_6->setValue(t_Set.Hoehe_Verstaerkung);
sb_4_7->setValue(t_Set.Hoehe_HoverBand);
cb_4_8 = setCombo(cb_4_8, t_Set.Hoehe_GPS_Z);
sb_4_9->setValue(t_Set.Hoehe_StickNeutralPoint);
}
// Seite 5
{
cb_5_1 = setCombo(cb_5_1, t_Set.Gyro_P);
cb_5_2 = setCombo(cb_5_2, t_Set.Gyro_I);
cb_5_8 = setCombo(cb_5_8, t_Set.Gyro_D);
cb_5_3 = setCombo(cb_5_3, t_Set.DynamicStability);
sb_5_4->setValue(t_Set.GyroAccFaktor);
sb_5_5->setValue(t_Set.GyroAccAbgleich);
cb_5_6 = setCombo(cb_5_6, t_Set.I_Faktor);
sb_5_7->setValue(t_Set.Driftkomp);
cb_5_9 = setCombo(cb_5_9, t_Set.Gyro_Gier_P);
cb_5_10 = setCombo(cb_5_10, t_Set.Gyro_Gier_I);
}
// Seite 6
{
cb_6_1 = setCombo(cb_6_1, t_Set.ServoNickControl);
sb_6_2->setValue(t_Set.ServoNickComp);
sb_6_3->setValue(t_Set.ServoNickMin);
sb_6_4->setValue(t_Set.ServoNickMax);
 
cb_6_7 = setCombo(cb_6_7, t_Set.ServoRollControl);
sb_6_8->setValue(t_Set.ServoRollComp);
sb_6_10->setValue(t_Set.ServoRollMin);
sb_6_11->setValue(t_Set.ServoRollMax);
 
cb_6_6->setChecked(t_Set.ServoCompInvert & 0x01);
cb_6_9->setChecked(t_Set.ServoCompInvert & 0x02);
 
sb_6_5->setValue(t_Set.ServoNickRefresh);
}
// Seite 7
{
sb_7_1->setValue(t_Set.Gas_Min);
sb_7_2->setValue(t_Set.Gas_Max);
cb_7_3 = setCombo(cb_7_3, t_Set.KompassWirkung);
sb_7_4->setValue(t_Set.UnterspannungsWarnung);
sb_7_5->setValue(t_Set.NotGasZeit);
sb_7_6->setValue(t_Set.NotGas);
}
// Seite 8
{
cb_8_1 = setCombo(cb_8_1, t_Set.AchsKopplung1);
cb_8_2 = setCombo(cb_8_2, t_Set.AchsKopplung2);
cb_8_3 = setCombo(cb_8_3, t_Set.CouplingYawCorrection);
}
// Seite 9 - Looping
{
if (t_Set.BitConfig & 0x01)
{
tb_9_6->setText("1");
tb_9_6->setChecked(true);
}
else
{
tb_9_6->setText("0");
tb_9_6->setChecked(false);
}
 
if (t_Set.BitConfig & 0x02)
{
tb_9_7->setText("1");
tb_9_7->setChecked(true);
}
else
{
tb_9_7->setText("0");
tb_9_7->setChecked(false);
}
 
if (t_Set.BitConfig & 0x04)
{
tb_9_8->setText("1");
tb_9_8->setChecked(true);
}
else
{
tb_9_8->setText("0");
tb_9_8->setChecked(false);
}
 
if (t_Set.BitConfig & 0x08)
{
tb_9_9->setText("1");
tb_9_9->setChecked(true);
}
else
{
tb_9_9->setText("0");
tb_9_9->setChecked(false);
}
 
cb_9_1 = setCombo(cb_9_1, t_Set.LoopGasLimit);
sb_9_2->setValue(t_Set.LoopThreshold);
sb_9_3->setValue(t_Set.WinkelUmschlagNick);
sb_9_4->setValue(t_Set.LoopHysterese);
sb_9_5->setValue(t_Set.WinkelUmschlagRoll);
 
}
// Seite 10 - Userparameter
{
cb_10_1 = setCombo(cb_10_1, t_Set.UserParam1);
cb_10_2 = setCombo(cb_10_2, t_Set.UserParam2);
cb_10_3 = setCombo(cb_10_3, t_Set.UserParam3);
cb_10_4 = setCombo(cb_10_4, t_Set.UserParam4);
cb_10_5 = setCombo(cb_10_5, t_Set.UserParam5);
cb_10_6 = setCombo(cb_10_6, t_Set.UserParam6);
cb_10_7 = setCombo(cb_10_7, t_Set.UserParam7);
cb_10_8 = setCombo(cb_10_8, t_Set.UserParam8);
}
// Seite 11 - Output
{
sb_11_1->setValue(t_Set.J16Bitmask);
cb_11_2 = setCombo(cb_11_2, int(t_Set.J16Timing));
sb_11_3->setValue(t_Set.J17Bitmask);
cb_11_4 = setCombo(cb_11_4, int(t_Set.J17Timing));
sb_11_5->setValue(t_Set.WARN_J16_Bitmask);
sb_11_6->setValue(t_Set.WARN_J17_Bitmask);
cb_11_7->setChecked(t_Set.BitConfig & CFG_MOTOR_BLINK);
J16_8->setChecked(t_Set.BitConfig & CFG_MOTOR_OFF_LED1);
J17_8->setChecked(t_Set.BitConfig & CFG_MOTOR_OFF_LED2);
}
// Seite 12
{
cb_12_1 = setCombo(cb_12_1, t_Set.NaviGpsModeControl);
cb_12_2 = setCombo(cb_12_2, t_Set.NaviGpsGain);
sb_12_3->setValue(t_Set.NaviStickThreshold);
sb_12_4->setValue(t_Set.NaviGpsMinSat);
cb_12_5 = setCombo(cb_12_5, t_Set.NaviGpsP);
cb_12_6 = setCombo(cb_12_6, t_Set.NaviGpsI);
cb_12_7 = setCombo(cb_12_7, t_Set.NaviGpsD);
cb_12_8 = setCombo(cb_12_8, t_Set.NaviGpsACC);
cb_12_9 = setCombo(cb_12_9, t_Set.NaviGpsPLimit);
cb_12_10 = setCombo(cb_12_10, t_Set.NaviGpsILimit);
cb_12_11 = setCombo(cb_12_11, t_Set.NaviGpsDLimit);
}
// Seite 13
{
cb_13_1 = setCombo(cb_13_1, t_Set.NaviWindCorrection);
cb_13_2 = setCombo(cb_13_2, t_Set.NaviSpeedCompensation);
cb_13_3 = setCombo(cb_13_3, t_Set.NaviOperatingRadius);
cb_13_4 = setCombo(cb_13_4, t_Set.NaviAngleLimitation);
sb_13_5->setValue(t_Set.NaviPH_LoginTime);
}
}
 
s_MK_Settings dlg_Main::get_MK_Settings() // DONE 0.75i
{
s_MK_Settings t_Set;
 
memcpy(t_Set.Name, le_SetName->text().toLatin1().data(), 12);
t_Set.Index = sb_Set->value();
t_Set.Version = MK_VERSION_SETTINGS;
 
// Seite 1
{
t_Set.GlobalConfig = 0;
t_Set.ExtraConfig = 0;
 
if (s_1_1_cb->isChecked())
t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_HOEHENREGELUNG;
if (s_1_2_cb->isChecked())
t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_KOMPASS_AKTIV;
if (s_1_3_cb->isChecked())
t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_KOMPASS_FIX;
if (s_1_4_cb->isChecked())
t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_GPS_AKTIV;
if (s_1_5_cb->isChecked())
t_Set.ExtraConfig = t_Set.ExtraConfig | CFG_SENSITIVE_RC;
if (s_1_6_cb->isChecked())
t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_ACHSENKOPPLUNG_AKTIV;
if (s_1_7_cb->isChecked())
t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_DREHRATEN_BEGRENZER;
if (s_1_8_cb->isChecked())
t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_HEADING_HOLD;
}
// Seite 2
{
t_Set.Kanalbelegung[2] = sb_2_1->value();
t_Set.Kanalbelegung[3] = sb_2_2->value();
t_Set.Kanalbelegung[0] = sb_2_3->value();
t_Set.Kanalbelegung[1] = sb_2_4->value();
t_Set.Kanalbelegung[4] = sb_2_5->value();
t_Set.Kanalbelegung[5] = sb_2_6->value();
t_Set.Kanalbelegung[6] = sb_2_7->value();
t_Set.Kanalbelegung[7] = sb_2_8->value();
}
// Seite 3
{
t_Set.Stick_P = sb_3_1->value();
t_Set.Stick_D = sb_3_2->value();
t_Set.Gier_P = get_Value(cb_3_3);
t_Set.ExternalControl = get_Value(cb_3_4);
}
// Seite 4
{
t_Set.MaxHoehe = get_Value(cb_4_1);
t_Set.Hoehe_MinGas = sb_4_2->value();
t_Set.Hoehe_P = get_Value(cb_4_3);
t_Set.Luftdruck_D = get_Value(cb_4_4);
t_Set.Hoehe_ACC_Wirkung = get_Value(cb_4_5);
t_Set.Hoehe_Verstaerkung = sb_4_6->value();
t_Set.Hoehe_HoverBand = sb_4_7->value();
t_Set.Hoehe_GPS_Z = get_Value(cb_4_8);
t_Set.Hoehe_StickNeutralPoint = sb_4_9->value();
 
if (s_4_2_rb->isChecked())
t_Set.ExtraConfig = t_Set.ExtraConfig | CFG2_HEIGHT_LIMIT;
if (s_4_4_cb->isChecked())
t_Set.GlobalConfig = t_Set.GlobalConfig | CFG_HOEHEN_SCHALTER;
if (s_4_5_cb->isChecked())
t_Set.ExtraConfig = t_Set.ExtraConfig | CFG2_VARIO_BEEP;
}
// Seite 5
{
t_Set.Gyro_P = get_Value(cb_5_1);
t_Set.Gyro_I = get_Value(cb_5_2);
t_Set.Gyro_D = get_Value(cb_5_8);
t_Set.DynamicStability = get_Value(cb_5_3);
t_Set.GyroAccFaktor = sb_5_4->value();
t_Set.GyroAccAbgleich = sb_5_5->value();
t_Set.I_Faktor = get_Value(cb_5_6);
t_Set.Driftkomp = sb_5_7->value();
t_Set.Gyro_Gier_P = get_Value(cb_5_9);
t_Set.Gyro_Gier_I = get_Value(cb_5_10);
}
// Seite 6
{
t_Set.ServoNickControl = get_Value(cb_6_1);
t_Set.ServoNickComp = sb_6_2->value();
t_Set.ServoNickMin = sb_6_3->value();
t_Set.ServoNickMax = sb_6_4->value();
 
t_Set.ServoRollControl = get_Value(cb_6_7);
t_Set.ServoRollComp = sb_6_8->value();
t_Set.ServoRollMin = sb_6_10->value();
t_Set.ServoRollMax = sb_6_11->value();
 
t_Set.ServoNickRefresh = sb_6_5->value();
 
if (cb_6_6->isChecked())
t_Set.ServoCompInvert = t_Set.ServoCompInvert | 0x01;
if (cb_6_9->isChecked())
t_Set.ServoCompInvert = t_Set.ServoCompInvert | 0x02;
}
// Seite 7
{
t_Set.Gas_Min = sb_7_1->value();
t_Set.Gas_Max = sb_7_2->value();
t_Set.KompassWirkung = get_Value(cb_7_3);
t_Set.UnterspannungsWarnung = sb_7_4->value();
t_Set.NotGasZeit = sb_7_5->value();
t_Set.NotGas = sb_7_6->value();
}
// Seite 8
{
t_Set.AchsKopplung1 = get_Value(cb_8_1);
t_Set.AchsKopplung2 = get_Value(cb_8_2);
t_Set.CouplingYawCorrection = get_Value(cb_8_3);
}
// Seite 9
{
t_Set.BitConfig = 0;
if (tb_9_6->text() == QString("1"))
t_Set.BitConfig = t_Set.BitConfig | 0x01;
if (tb_9_7->text() == QString("1"))
t_Set.BitConfig = t_Set.BitConfig | 0x02;
if (tb_9_8->text() == QString("1"))
t_Set.BitConfig = t_Set.BitConfig | 0x04;
if (tb_9_9->text() == QString("1"))
t_Set.BitConfig = t_Set.BitConfig | 0x08;
 
 
t_Set.LoopGasLimit = get_Value(cb_9_1);
t_Set.LoopThreshold = sb_9_2->value();
t_Set.WinkelUmschlagNick = sb_9_3->value();
t_Set.LoopHysterese = sb_9_4->value();
t_Set.WinkelUmschlagRoll = sb_9_5->value();
}
// Seite 10
{
t_Set.UserParam1 = get_Value(cb_10_1);
t_Set.UserParam2 = get_Value(cb_10_2);
t_Set.UserParam3 = get_Value(cb_10_3);
t_Set.UserParam4 = get_Value(cb_10_4);
t_Set.UserParam5 = get_Value(cb_10_5);
t_Set.UserParam6 = get_Value(cb_10_6);
t_Set.UserParam7 = get_Value(cb_10_7);
t_Set.UserParam8 = get_Value(cb_10_8);
}
// Seite 11
{
t_Set.J16Bitmask = sb_11_1->value();
t_Set.J16Timing = get_Value(cb_11_2);
t_Set.J17Bitmask = sb_11_3->value();
t_Set.J17Timing = get_Value(cb_11_4);
t_Set.WARN_J16_Bitmask = sb_11_5->value();
t_Set.WARN_J17_Bitmask = sb_11_6->value();
 
if (cb_11_7->isChecked())
t_Set.BitConfig = t_Set.BitConfig | CFG_MOTOR_BLINK;
if (J16_8->isChecked())
t_Set.BitConfig = t_Set.BitConfig | CFG_MOTOR_OFF_LED1;
if (J17_8->isChecked())
t_Set.BitConfig = t_Set.BitConfig | CFG_MOTOR_OFF_LED2;
}
// Seite 12
{
t_Set.NaviGpsModeControl = get_Value(cb_12_1);
t_Set.NaviGpsGain = get_Value(cb_12_2);
t_Set.NaviStickThreshold = sb_12_3->value();
t_Set.NaviGpsMinSat = sb_12_4->value();
t_Set.NaviGpsP = get_Value(cb_12_5);
t_Set.NaviGpsI = get_Value(cb_12_6);
t_Set.NaviGpsD = get_Value(cb_12_7);
t_Set.NaviGpsACC = get_Value(cb_12_8);
t_Set.NaviGpsPLimit = get_Value(cb_12_9);
t_Set.NaviGpsILimit = get_Value(cb_12_10);
t_Set.NaviGpsDLimit = get_Value(cb_12_11);
}
// Seite 13
{
t_Set.NaviWindCorrection = get_Value(cb_13_1);
t_Set.NaviSpeedCompensation = get_Value(cb_13_2);
t_Set.NaviOperatingRadius = get_Value(cb_13_3);
t_Set.NaviAngleLimitation = get_Value(cb_13_4);
t_Set.NaviPH_LoginTime = sb_13_5->value();
}
 
return t_Set;
}
 
int dlg_Main::get_Value(QComboBox *Combo)
{
if (Combo->currentText() == QString("Poti 1"))
return 251;
if (Combo->currentText() == QString("Poti 2"))
return 252;
if (Combo->currentText() == QString("Poti 3"))
return 253;
if (Combo->currentText() == QString("Poti 4"))
return 254;
return Combo->currentText().toInt();
}
 
QComboBox *dlg_Main::setCombo(QComboBox *Combo, int Wert)
{
if (Wert <= 250)
{
Combo->setItemText(4, QString("%1").arg(Wert));
Combo->setCurrentIndex(4);
}
else
{
Combo->setCurrentIndex(Wert - 251);
}
return Combo;
}
 
void dlg_Main::set_LED(QToolButton *ToolButton, bool On)
{
QIcon Icons[2] ;
Icons[0].addPixmap(QPixmap(QString::fromUtf8(":/Flags/Global/Images/Actions/LED_Off.png")), QIcon::Normal, QIcon::Off);
Icons[1].addPixmap(QPixmap(QString::fromUtf8(":/Flags/Global/Images/Actions/LED_Red.png")), QIcon::Normal, QIcon::Off);
 
if (ToolButton->text() == QString("0") && On)
{
ToolButton->setIcon(Icons[1]);
ToolButton->setText("1");
}
else if (ToolButton->text() == QString("1") && !On)
{
ToolButton->setIcon(Icons[0]);
ToolButton->setText("0");
}
else if (ToolButton->text() == QString("00") && On)
{
ToolButton->setIcon(Icons[1]);
ToolButton->setText("11");
}
else if (ToolButton->text() == QString("11") && !On)
{
ToolButton->setIcon(Icons[0]);
ToolButton->setText("00");
}
else if (ToolButton->text() == QString("000") && On)
{
ToolButton->setIcon(Icons[1]);
ToolButton->setText("111");
}
else if (ToolButton->text() == QString("111") && !On)
{
ToolButton->setIcon(Icons[0]);
ToolButton->setText("000");
}
else if (ToolButton->text() == QString("0000") && On)
{
ToolButton->setIcon(Icons[1]);
ToolButton->setText("1111");
}
else if (ToolButton->text() == QString("1111") && !On)
{
ToolButton->setIcon(Icons[0]);
ToolButton->setText("0000");
}
}
 
void dlg_Main::slot_LEDtoValue()
{
QToolButton *ToolButton = (QToolButton*)sender();
 
if (ToolButton->text() == QString("0"))
{
set_LED(ToolButton, true);
sb_11_1->setValue(sb_11_1->value() + ToolButton->toolTip().toInt());
}
else if (ToolButton->text() == QString("1"))
{
set_LED(ToolButton);
sb_11_1->setValue(sb_11_1->value() - ToolButton->toolTip().toInt());
}
 
else if (ToolButton->text() == QString("00"))
{
set_LED(ToolButton, true);
sb_11_3->setValue(sb_11_3->value() + ToolButton->toolTip().toInt());
}
else if (ToolButton->text() == QString("11"))
{
set_LED(ToolButton);
sb_11_3->setValue(sb_11_3->value() - ToolButton->toolTip().toInt());
}
 
else if (ToolButton->text() == QString("000"))
{
set_LED(ToolButton, true);
sb_11_5->setValue(sb_11_5->value() + ToolButton->toolTip().toInt());
}
else if (ToolButton->text() == QString("111"))
{
set_LED(ToolButton);
sb_11_5->setValue(sb_11_5->value() - ToolButton->toolTip().toInt());
}
 
else if (ToolButton->text() == QString("0000"))
{
set_LED(ToolButton, true);
sb_11_6->setValue(sb_11_6->value() + ToolButton->toolTip().toInt());
}
else if (ToolButton->text() == QString("1111"))
{
set_LED(ToolButton);
sb_11_6->setValue(sb_11_6->value() - ToolButton->toolTip().toInt());
}
 
 
}
 
void dlg_Main::slot_ValuetoLED16(int Wert)
{
set_LED(J16_0, Wert & 0x80);
set_LED(J16_1, Wert & 0x40);
set_LED(J16_2, Wert & 0x20);
set_LED(J16_3, Wert & 0x10);
set_LED(J16_4, Wert & 0x08);
set_LED(J16_5, Wert & 0x04);
set_LED(J16_6, Wert & 0x02);
set_LED(J16_7, Wert & 0x01);
}
 
void dlg_Main::slot_ValuetoLED17(int Wert)
{
set_LED(J17_0, Wert & 0x80);
set_LED(J17_1, Wert & 0x40);
set_LED(J17_2, Wert & 0x20);
set_LED(J17_3, Wert & 0x10);
set_LED(J17_4, Wert & 0x08);
set_LED(J17_5, Wert & 0x04);
set_LED(J17_6, Wert & 0x02);
set_LED(J17_7, Wert & 0x01);
}
 
void dlg_Main::slot_ValuetoLED16A(int Wert)
{
set_LED(J16_A_0, Wert & 0x80);
set_LED(J16_A_1, Wert & 0x40);
set_LED(J16_A_2, Wert & 0x20);
set_LED(J16_A_3, Wert & 0x10);
set_LED(J16_A_4, Wert & 0x08);
set_LED(J16_A_5, Wert & 0x04);
set_LED(J16_A_6, Wert & 0x02);
set_LED(J16_A_7, Wert & 0x01);
}
 
void dlg_Main::slot_ValuetoLED17A(int Wert)
{
set_LED(J17_A_0, Wert & 0x80);
set_LED(J17_A_1, Wert & 0x40);
set_LED(J17_A_2, Wert & 0x20);
set_LED(J17_A_3, Wert & 0x10);
set_LED(J17_A_4, Wert & 0x08);
set_LED(J17_A_5, Wert & 0x04);
set_LED(J17_A_6, Wert & 0x02);
set_LED(J17_A_7, Wert & 0x01);
}
 
void dlg_Main::slot_tbUp()
{
if (tb_9_6->text() == QString("0"))
{
tb_9_6->setText("1");
}
else
{
tb_9_6->setText("0");
}
}
 
void dlg_Main::slot_tbDown()
{
if (tb_9_7->text() == QString("0"))
{
tb_9_7->setText("1");
}
else
{
tb_9_7->setText("0");
}
}
 
void dlg_Main::slot_tbLeft()
{
if (tb_9_8->text() == QString("0"))
{
tb_9_8->setText("1");
}
else
{
tb_9_8->setText("0");
}
}
 
void dlg_Main::slot_tbRight()
{
if (tb_9_9->text() == QString("0"))
{
tb_9_9->setText("1");
}
else
{
tb_9_9->setText("0");
}
}
 
// Programm Ende
dlg_Main::~dlg_Main()
{
o_Settings->GUI.isMax = isMaximized();
o_Settings->GUI.Size = size();
o_Settings->GUI.Point = pos();
 
o_Settings->SERVER.Password = le_Password->text();
o_Settings->SERVER.IP_MAX = cb_Server->count();
o_Settings->SERVER.IP_ID = cb_Server->currentIndex();
 
for (int z = 0; z < cb_Server->count(); z++)
{
if (z < 10)
{
o_Settings->SERVER.IP[z] = cb_Server->itemText(z);
}
}
 
o_Settings->write_Settings();
// qDebug("Ende.");
}