2011-11-11 23:09:44 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
2011-11-11 23:42:36 +00:00
|
|
|
* @file serialpluginoptionspage.cpp
|
2011-11-11 23:09:44 +00:00
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
* @addtogroup GCSPlugins GCS Plugins
|
|
|
|
* @{
|
2011-11-11 23:42:36 +00:00
|
|
|
* @addtogroup SerialPlugin Serial Connection Plugin
|
2011-11-11 23:09:44 +00:00
|
|
|
* @{
|
2011-11-11 23:42:36 +00:00
|
|
|
* @brief Impliments serial connection to the flight hardware for Telemetry
|
2011-11-11 23:09:44 +00:00
|
|
|
*****************************************************************************/
|
2011-11-11 23:42:36 +00:00
|
|
|
/*
|
2011-11-11 23:09:44 +00:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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 "serialpluginoptionspage.h"
|
|
|
|
#include "serialpluginconfiguration.h"
|
|
|
|
#include "ui_serialpluginoptions.h"
|
|
|
|
#include "extensionsystem/pluginmanager.h"
|
|
|
|
|
|
|
|
SerialPluginOptionsPage::SerialPluginOptionsPage(SerialPluginConfiguration *config, QObject *parent) :
|
|
|
|
IOptionsPage(parent),
|
|
|
|
m_config(config)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//creates options page widget (uses the UI file)
|
|
|
|
QWidget *SerialPluginOptionsPage::createPage(QWidget *parent)
|
|
|
|
{
|
|
|
|
|
|
|
|
Q_UNUSED(parent);
|
|
|
|
options_page = new Ui::SerialPluginOptionsPage();
|
|
|
|
//main widget
|
|
|
|
QWidget *optionsPageWidget = new QWidget;
|
|
|
|
//main layout
|
|
|
|
options_page->setupUi(optionsPageWidget);
|
2012-02-12 16:26:31 +00:00
|
|
|
QStringList allowedSpeeds;
|
|
|
|
allowedSpeeds<<"1200"
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
<<"1800" //POSIX ONLY
|
|
|
|
#endif
|
|
|
|
<<"2400"
|
|
|
|
<<"4800"
|
|
|
|
<<"9600"
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
<<"14400" //WINDOWS ONLY
|
|
|
|
#endif
|
|
|
|
<<"19200"
|
|
|
|
<<"38400"
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
<<"56000" //WINDOWS ONLY
|
|
|
|
#endif
|
|
|
|
<<"57600"
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
<<"76800" //POSIX ONLY
|
|
|
|
#endif
|
|
|
|
<<"115200"
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
<<"128000" //WINDOWS ONLY
|
|
|
|
<<"230400" //WINDOWS ONLY
|
|
|
|
<<"256000" //WINDOWS ONLY
|
|
|
|
<<"460800" //WINDOWS ONLY
|
|
|
|
<<"921600" //WINDOWS ONLY
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
options_page->cb_speed->addItems(allowedSpeeds);
|
2011-11-11 23:09:44 +00:00
|
|
|
options_page->cb_speed->setCurrentIndex(options_page->cb_speed->findText(m_config->speed()));
|
|
|
|
return optionsPageWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the user presses apply or OK.
|
|
|
|
*
|
|
|
|
* Saves the current values
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void SerialPluginOptionsPage::apply()
|
|
|
|
{
|
|
|
|
m_config->setSpeed(options_page->cb_speed->currentText());
|
|
|
|
m_config->savesettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SerialPluginOptionsPage::finish()
|
|
|
|
{
|
2011-11-11 23:42:36 +00:00
|
|
|
delete options_page;
|
2011-11-11 23:09:44 +00:00
|
|
|
}
|