Rev 722 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/***************************************************************************
* 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 <QCryptographicHash>
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include "dlg_Main.h"
// Konstruktor Main-Form
dlg_Main::dlg_Main()
{
setupUi(this);
o_Settings = new cSettings();
wg_Connection->set_Client(ID_SETTINGS, QA_NAME + " " + QA_VERSION, DataFields);
o_Timer = new QTimer();
o_Timer->setInterval(500);
f_MotorMixer = new dlg_MotorMixer(this);
f_MotorTest = new dlg_MotorTest(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();
}
wg_Connection->set_SelectVisible(false);
wg_Connection->set_IntervalVisible(false);
ac_Toolbar->setChecked(o_Settings->GUI.Toolbar);
if (ac_Toolbar->isChecked())
{
wg_Connection->set_ButtonVisible(false);
}
else
{
ToolBar->setVisible(false);
}
}
// Signale mit Slots verbinden
void dlg_Main::init_Connections()
{
connect(o_Timer, SIGNAL(timeout()), this, SLOT(slot_Timer()));
connect(ac_Connect, SIGNAL(triggered()), wg_Connection, SLOT(slot_btn_Connect()));
connect(ac_Toolbar, SIGNAL(triggered()), this, SLOT(slot_ac_Toolbar()));
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()));
connect(ac_MotorTest, SIGNAL(triggered()), this, SLOT(slot_ac_MotorTest()));
connect(f_MotorMixer, SIGNAL(sig_SendData(QString,int)), wg_Connection, SLOT(slot_send_Data(QString,int)));
connect(f_MotorTest, SIGNAL(sig_SendData(QString,int)), wg_Connection, SLOT(slot_send_Data(QString,int)));
// 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(wg_Connection, SIGNAL(sig_Status(int)), this, SLOT(slot_ConnectionStatus(int)));
connect(wg_Connection, SIGNAL(sig_MK_Version(s_Hardware)), this, SLOT(slot_MK_Version(s_Hardware)));
connect(wg_Connection, SIGNAL(sig_MK_ReadSettings(s_MK_Settings)), this, SLOT(slot_MK_ReadSettings(s_MK_Settings)));
connect(wg_Connection, SIGNAL(sig_MK_WriteSettings(int)), this, SLOT(slot_MK_WriteSettings(int)));
connect(wg_Connection, SIGNAL(sig_MK_ReadMotorMixer(s_MK_Mixer)), this, SLOT(slot_MK_ReadMotorMixer(s_MK_Mixer)));
connect(wg_Connection, SIGNAL(sig_MK_WriteMotorMixer(int)), this, SLOT(slot_MK_WriteMotorMixer(int)));
connect(wg_Connection, SIGNAL(sig_MK_PPMData(s_MK_PPM_Data)), this, SLOT(slot_MK_PPMData(s_MK_PPM_Data)));
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);
}
}
///////////
// Slots //
///////////
// About-Dialog
void dlg_Main::slot_ac_About()
{
QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT);
}
void dlg_Main::slot_ac_Toolbar()
{
if (ac_Toolbar->isChecked())
{
wg_Connection->set_ButtonVisible(false);
ToolBar->setVisible(true);
}
else
{
wg_Connection->set_ButtonVisible(true);
ToolBar->setVisible(false);
}
}
void dlg_Main::slot_ConnectionStatus(int li_Status)
{
if (li_Status)
{
ac_Connect->setChecked(true);
ac_Connect->setText(tr("Trennen"));
}
else
{
ac_Connect->setChecked(false);
ac_Connect->setText(tr("Verbinden"));
}
}
void dlg_Main::slot_MK_Version(s_Hardware ls_Version)
{
gs_Version = ls_Version;
setWindowTitle(QA_NAME + " " + QA_VERSION + " - " + ls_Version.Hardware + " " + ls_Version.Version);
if (gs_Version.ID == ADDRESS_FC)
{
c_Data[0] = 0xff;
wg_Connection->send_Data(HandlerMK::make_Frame('q', ADDRESS_FC, c_Data, 1).toLatin1().data(), DATA_READ_SETTINGS);
}
}
void dlg_Main::slot_MK_ReadSettings(s_MK_Settings ps_MK_Settings)
{
if (ps_MK_Settings.Version == MK_VERSION_SETTINGS)
{
show_MK_Settings(ps_MK_Settings);
}
else
{
QMessageBox::warning(this, QA_NAME, tr("Versionen inkompatibel. \nParameterbearbeitung nicht moeglich."), QMessageBox::Ok);
ac_Read->setEnabled(false);
ac_Write->setEnabled(false);
}
}
void dlg_Main::slot_MK_WriteSettings(int pi_ID)
{
if (pi_ID == 0)
{
QMessageBox::warning(this, QA_NAME, tr("Fehler beim Settings-Schreiben."), QMessageBox::Ok);
}
else
{
QMessageBox::information(this, QA_NAME, tr("Setting geschrieben."), QMessageBox::Ok);
}
}
void dlg_Main::slot_MK_ReadMotorMixer(s_MK_Mixer ps_MK_MotorMixer)
{
if (ps_MK_MotorMixer.Revision == MK_VERSION_MIXER)
{
f_MotorMixer->set_MotorConfig(ps_MK_MotorMixer);
}
}
void dlg_Main::slot_MK_WriteMotorMixer(int pi_ID)
{
if (pi_ID == 0)
{
QMessageBox::warning(this, QA_NAME, tr("Fehler beim MotorMixer-Schreiben."), QMessageBox::Ok);
}
else
{
QMessageBox::information(this, QA_NAME, tr("MotorMixer geschrieben."), QMessageBox::Ok);
}
}
void dlg_Main::slot_MK_PPMData(s_MK_PPM_Data ps_PPMData)
{
qDebug("PPM-Data");
// qDebug() << ps_PPMData.Data[1] << ", " << ps_PPMData.Data[2] << ", " << ps_PPMData.Data[3] << ", " << ps_PPMData.Data[4];
pb_K1->setValue(ps_PPMData.Data[1]);
pb_K2->setValue(ps_PPMData.Data[2]);
pb_K3->setValue(ps_PPMData.Data[3]);
pb_K4->setValue(ps_PPMData.Data[4]);
pb_K5->setValue(ps_PPMData.Data[5]);
pb_K6->setValue(ps_PPMData.Data[6]);
pb_K7->setValue(ps_PPMData.Data[7]);
pb_K8->setValue(ps_PPMData.Data[8]);
pb_K9->setValue(ps_PPMData.Data[9]);
pb_K10->setValue(ps_PPMData.Data[10]);
pb_K11->setValue(ps_PPMData.Data[11]);
pb_K12->setValue(ps_PPMData.Data[12]);
pb_K1_2->setValue(ps_PPMData.Data[13]);
pb_K2_2->setValue(ps_PPMData.Data[14]);
pb_K3_2->setValue(ps_PPMData.Data[15]);
pb_K4_2->setValue(ps_PPMData.Data[16]);
pb_K5_2->setValue(ps_PPMData.Data[17]);
pb_K6_2->setValue(ps_PPMData.Data[18]);
pb_K7_2->setValue(ps_PPMData.Data[19]);
pb_K8_2->setValue(ps_PPMData.Data[20]);
pb_K9_2->setValue(ps_PPMData.Data[21]);
pb_K10_2->setValue(ps_PPMData.Data[22]);
pb_K11_2->setValue(ps_PPMData.Data[23]);
pb_K12_2->setValue(ps_PPMData.Data[24]);
}
///////////////////////////////////////////////////////////////////
// QMK-Settings //
///////////////////////////////////////////////////////////////////
void dlg_Main::slot_PageChange(int Page)
{
if (Page == 1)
o_Timer->start();
else
o_Timer->stop();
}
void dlg_Main::slot_Timer()
{
wg_Connection->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_Settings, s_Dir);
f_MotorMixer->read_Mixer();
if (f_MotorMixer->exec()==QDialog::Accepted)
{
}
}
void dlg_Main::slot_ac_MotorTest()
{
// f_MotorMixer->set_Objects(wg_Connection->o_Input, o_Settings, s_Dir);
// f_MotorMixer->read_Mixer();
if (f_MotorTest->exec()==QDialog::Accepted)
{
}
f_MotorTest->Stop();
}
// 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));
wg_Connection->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();
wg_Connection->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 + "/" + gs_Version.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.setValue("Poti_5", t_Set.Kanalbelegung[8]);
Setting.setValue("Poti_6", t_Set.Kanalbelegung[9]);
Setting.setValue("Poti_7", t_Set.Kanalbelegung[10]);
Setting.setValue("Poti_8", t_Set.Kanalbelegung[11]);
Setting.setValue("Receiver", t_Set.Receiver);
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.setValue("Servo3", t_Set.Servo3);
Setting.setValue("Servo4", t_Set.Servo4);
Setting.setValue("Servo5", t_Set.Servo5);
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.endGroup();
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();
t_Set.Kanalbelegung[8] = Setting.value("Poti_5", 9).toInt();
t_Set.Kanalbelegung[9] = Setting.value("Poti_6", 10).toInt();
t_Set.Kanalbelegung[10] = Setting.value("Poti_7", 11).toInt();
t_Set.Kanalbelegung[11] = Setting.value("Poti_8", 12).toInt();
t_Set.Receiver = Setting.value("Receiver", 0).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();
t_Set.Servo3 = Setting.value("Servo3", 0).toInt();
t_Set.Servo4 = Setting.value("Servo4", 0).toInt();
t_Set.Servo5 = Setting.value("Servo5", 0).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
{
cb_2_1->setCurrentIndex(t_Set.Kanalbelegung[2] - 1);
cb_2_2->setCurrentIndex(t_Set.Kanalbelegung[3] - 1);
cb_2_3->setCurrentIndex(t_Set.Kanalbelegung[0] - 1);
cb_2_4->setCurrentIndex(t_Set.Kanalbelegung[1] - 1);
cb_2_5->setCurrentIndex(t_Set.Kanalbelegung[4] - 1);
cb_2_6->setCurrentIndex(t_Set.Kanalbelegung[5] - 1);
cb_2_7->setCurrentIndex(t_Set.Kanalbelegung[6] - 1);
cb_2_8->setCurrentIndex(t_Set.Kanalbelegung[7] - 1);
cb_2_9->setCurrentIndex(t_Set.Kanalbelegung[8] - 1);
cb_2_10->setCurrentIndex(t_Set.Kanalbelegung[9] - 1);
cb_2_11->setCurrentIndex(t_Set.Kanalbelegung[10] - 1);
cb_2_12->setCurrentIndex(t_Set.Kanalbelegung[11] - 1);
s_2_13_cb->setCurrentIndex(t_Set.Receiver);
}
// 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);
if (t_Set.ExtraConfig & CFG2_HEIGHT_LIMIT)
{
s_4_2_rb->setChecked(true);
}
else
{
s_4_3_rb->setChecked(true);
}
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);
cb_6_12 = setCombo(cb_6_12, t_Set.Servo3);
cb_6_13 = setCombo(cb_6_13, t_Set.Servo4);
cb_6_14 = setCombo(cb_6_14, t_Set.Servo5);
}
// 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);
if (t_Set.WARN_J16_Bitmask != 0)
s_11_7_cb->setChecked(true);
else
s_11_7_cb->setChecked(false);
if (t_Set.WARN_J17_Bitmask != 0)
s_11_8_cb->setChecked(true);
else
s_11_8_cb->setChecked(false);
}
// 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] = cb_2_1->currentIndex() + 1;
t_Set.Kanalbelegung[3] = cb_2_2->currentIndex() + 1;
t_Set.Kanalbelegung[0] = cb_2_3->currentIndex() + 1;
t_Set.Kanalbelegung[1] = cb_2_4->currentIndex() + 1;
t_Set.Kanalbelegung[4] = cb_2_5->currentIndex() + 1;
t_Set.Kanalbelegung[5] = cb_2_6->currentIndex() + 1;
t_Set.Kanalbelegung[6] = cb_2_7->currentIndex() + 1;
t_Set.Kanalbelegung[7] = cb_2_8->currentIndex() + 1;
t_Set.Kanalbelegung[8] = cb_2_9->currentIndex() + 1;
t_Set.Kanalbelegung[9] = cb_2_10->currentIndex() + 1;
t_Set.Kanalbelegung[10] = cb_2_11->currentIndex() + 1;
t_Set.Kanalbelegung[11] = cb_2_12->currentIndex() + 1;
t_Set.Receiver = s_2_13_cb->currentIndex();
}
// 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();
t_Set.Servo3 = get_Value(cb_6_12);
t_Set.Servo4 = get_Value(cb_6_13);
t_Set.Servo5 = get_Value(cb_6_14);
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 (!s_11_7_cb->isChecked())
t_Set.WARN_J16_Bitmask = 0;
if (!s_11_8_cb->isChecked())
t_Set.WARN_J17_Bitmask = 0;
}
// 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 255;
if (Combo->currentText() == QString("Poti 2"))
return 254;
if (Combo->currentText() == QString("Poti 3"))
return 253;
if (Combo->currentText() == QString("Poti 4"))
return 252;
if (Combo->currentText() == QString("Poti 5"))
return 251;
if (Combo->currentText() == QString("Poti 6"))
return 250;
if (Combo->currentText() == QString("Poti 7"))
return 249;
if (Combo->currentText() == QString("Poti 8"))
return 248;
return Combo->currentText().toInt();
}
QComboBox *dlg_Main::setCombo(QComboBox *Combo, int Wert)
{
if (Wert <= 245)
{
Combo->setItemText(8, QString("%1").arg(Wert));
Combo->setCurrentIndex(8);
}
else
{
Combo->setCurrentIndex(255 - Wert);
}
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->GUI.Toolbar = ac_Toolbar->isChecked();
o_Settings->write_Settings();
// qDebug("Ende.");
}