Navigation Menu

Skip to content

Commit

Permalink
GCS: plugin for sparky bgc
Browse files Browse the repository at this point in the history
This lets the GCS know about SparkyBGC.
  • Loading branch information
peabody124 committed Sep 10, 2013
1 parent b45fbf6 commit 765c813
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ground/gcs/src/plugins/boards_taulabs/boards_taulabs.pro
Expand Up @@ -10,12 +10,14 @@ OTHER_FILES += TauLabs.pluginspec \
HEADERS += \
taulabsplugin.h \
freedom.h \
sparky.h
sparky.h \
sparkybgc.h

SOURCES += \
taulabsplugin.cpp \
freedom.cpp \
sparky.cpp
sparky.cpp \
sparkybgc.cpp

RESOURCES += \
taulabs.qrc
197 changes: 197 additions & 0 deletions ground/gcs/src/plugins/boards_taulabs/sparkybgc.cpp
@@ -0,0 +1,197 @@
/**
******************************************************************************
* @file sparkybgc.cpp
* @author Tau Labs, http://taulabs.org, Copyright (C) 2013
*
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup Boards_TauLabsPlugin Tau Labs boards support Plugin
* @{
* @brief Plugin to support boards by the Tau Labs project
*****************************************************************************/
/*
* 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 "sparkybgc.h"

#include <uavobjectmanager.h>
#include "uavobjectutil/uavobjectutilmanager.h"
#include <extensionsystem/pluginmanager.h>

#include "hwsparky.h"

/**
* @brief Sparky::Sparky
* This is the Sparky board definition
*/
SparkyBGC::SparkyBGC(void)
{
// Initialize our USB Structure definition here:
USBInfo board;
board.vendorID = 0x20A0;
board.productID = 0x415b;

setUSBInfo(board);

boardType = 0x89;
}

SparkyBGC::~SparkyBGC()
{

}


QString SparkyBGC::shortName()
{
return QString("SparkyBGC");
}

QString SparkyBGC::boardDescription()
{
return QString("The Tau Labs project Sparky BGC boards");
}

//! Return which capabilities this board has
bool SparkyBGC::queryCapabilities(BoardCapabilities capability)
{
switch(capability) {
case BOARD_CAPABILITIES_GYROS:
return true;
case BOARD_CAPABILITIES_ACCELS:
return true;
case BOARD_CAPABILITIES_MAGS:
return true;
case BOARD_CAPABILITIES_BAROS:
return true;
case BOARD_CAPABILITIES_RADIO:
return false;
}
return false;
}

QStringList SparkyBGC::queryChannelBanks()
{
return QStringList(QStringList() << "1-2" << "3" << "4,7,9" << "5" << "6,10" << "8");
}

/**
* @brief SparkyBGC::getSupportedProtocols
* TODO: this is just a stub, we'll need to extend this a lot with multi protocol support
* @return
*/
QStringList SparkyBGC::getSupportedProtocols()
{

return QStringList("uavtalk");
}

QPixmap SparkyBGC::getBoardPicture()
{
return QPixmap(":/taulabs/images/sparky.png");
}

QString SparkyBGC::getHwUAVO()
{
return "HwSparky";
}

//! Determine if this board supports configuring the receiver
bool SparkyBGC::isInputConfigurationSupported()
{
return true;
}

/**
* Configure the board to use a receiver input type on a port number
* @param type the type of receiver to use
* @param port_num which input port to configure (board specific numbering)
* @return true if successfully configured or false otherwise
*/
bool SparkyBGC::setInputOnPort(enum InputType type, int port_num)
{
if (port_num != 0)
return false;

ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
HwSparky *hwSparky = HwSparky::GetInstance(uavoManager);
Q_ASSERT(hwSparky);
if (!hwSparky)
return false;

HwSparky::DataFields settings = hwSparky->getData();

switch(type) {
case INPUT_TYPE_PPM:
settings.RcvrPort = HwSparky::RCVRPORT_PPM;
break;
case INPUT_TYPE_SBUS:
settings.RcvrPort = HwSparky::RCVRPORT_SBUS;
break;
case INPUT_TYPE_DSM2:
settings.RcvrPort = HwSparky::RCVRPORT_DSM2;
break;
case INPUT_TYPE_DSMX10BIT:
settings.RcvrPort = HwSparky::RCVRPORT_DSMX10BIT;
break;
case INPUT_TYPE_DSMX11BIT:
settings.RcvrPort = HwSparky::RCVRPORT_DSMX11BIT;
break;
default:
return false;
}

// Apply these changes
hwSparky->setData(settings);

return true;
}

/**
* @brief SparkyBGC::getInputOnPort fetch the currently selected input type
* @param port_num the port number to query (must be zero)
* @return the selected input type
*/
enum Core::IBoardType::InputType SparkyBGC::getInputOnPort(int port_num)
{
if (port_num != 0)
return INPUT_TYPE_UNKNOWN;

ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
HwSparky *hwSparky = HwSparky::GetInstance(uavoManager);
Q_ASSERT(hwSparky);
if (!hwSparky)
return INPUT_TYPE_UNKNOWN;

HwSparky::DataFields settings = hwSparky->getData();

switch(settings.RcvrPort) {
case HwSparky::RCVRPORT_PPM:
return INPUT_TYPE_PPM;
case HwSparky::RCVRPORT_SBUS:
return INPUT_TYPE_SBUS;
case HwSparky::RCVRPORT_DSM2:
return INPUT_TYPE_DSM2;
case HwSparky::RCVRPORT_DSMX10BIT:
return INPUT_TYPE_DSMX10BIT;
case HwSparky::RCVRPORT_DSMX11BIT:
return INPUT_TYPE_DSMX11BIT;
default:
return INPUT_TYPE_UNKNOWN;
}
}
73 changes: 73 additions & 0 deletions ground/gcs/src/plugins/boards_taulabs/sparkybgc.h
@@ -0,0 +1,73 @@
/**
******************************************************************************
* @file sparkybgc.h
* @author Tau Labs, http://taulabs.org, Copyright (C) 2013
*
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup Boards_TauLabsPlugin Tau Labs boards support Plugin
* @{
* @brief Plugin to support boards by the Tau Labs project
*****************************************************************************/
/*
* 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
*/
#ifndef SPARKYBGC_H
#define SPARKYBGC_H

#include <coreplugin/iboardtype.h>

class IBoardType;

class SparkyBGC : public Core::IBoardType
{
public:
SparkyBGC();
virtual ~SparkyBGC();

virtual QString shortName();
virtual QString boardDescription();
virtual bool queryCapabilities(BoardCapabilities capability);
virtual QStringList queryChannelBanks();
virtual QStringList getSupportedProtocols();
virtual QPixmap getBoardPicture();
virtual QString getHwUAVO();

//! Determine if this board supports configuring the receiver
virtual bool isInputConfigurationSupported();

/**
* Configure the board to use an receiver input type on a port number
* @param type the type of receiver to use
* @param port_num which input port to configure (board specific numbering)
*/
virtual bool setInputOnPort(enum InputType type, int port_num = 0);

/**
* @brief getInputOnPort get the current input type
* @param port_num which input port to query (board specific numbering)
* @return the currently selected input type
*/
virtual enum InputType getInputOnPort(int port_num = 0);

/**
* @brief getConnectionDiagram get the connection diagram for this board
* @return a string with the name of the resource for this board diagram
*/
virtual QString getConnectionDiagram() { return ":/taulabs/images/sparky-connection-diagram.svg"; }
};


#endif // SPARKYBGC_H
4 changes: 4 additions & 0 deletions ground/gcs/src/plugins/boards_taulabs/taulabsplugin.cpp
Expand Up @@ -28,6 +28,7 @@
#include "taulabsplugin.h"
#include "freedom.h"
#include "sparky.h"
#include "sparkybgc.h"
#include <QtPlugin>


Expand Down Expand Up @@ -57,6 +58,9 @@ void TauLabsPlugin::extensionsInitialized()
Sparky* sparky = new Sparky();
addAutoReleasedObject(sparky);

SparkyBGC* sparkybgc = new SparkyBGC();
addAutoReleasedObject(sparkybgc);

Freedom* freedom = new Freedom();
addAutoReleasedObject(freedom);
}
Expand Down

0 comments on commit 765c813

Please sign in to comment.