Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 398 → Rev 399

/QMK-Groundstation/branches/own_com_lib/Forms/dlg_MotorMixer.cpp
292,8 → 292,7
 
void dlg_MotorMixer::read_Mixer()
{
TX_Data[0] = 0;
o_Connection->send_Cmd('n', ADDRESS_FC, TX_Data, 1, true);
//See Handler::read_mixer in com/Handler.cpp
}*/
 
// read motor values
308,8 → 307,8
 
void dlg_MotorMixer::slot_pb_WRITE()
{
/* int Length = get_MotorConfig();
o_Connection->send_Cmd('m', ADDRESS_FC, TX_Data, Length, true);*/
/* int Length = handler->get_motor_config();
handler->write_mixer(TX_Data, Length);*/
}
 
void dlg_MotorMixer::slot_pb_LOAD()
/QMK-Groundstation/branches/own_com_lib/Forms/mktool.cpp
414,7 → 414,7
}
 
// Waypoint zur NC Senden.
//FIXME: put this in cpp/NaviCtrl.cpp
//FIXME: put this in cpp/NaviCtrl.cpp?
void MKTool::slot_pb_SendTarget()
{
if ((Navi.Current.Longitude == 0) && (Navi.Current.Latitude == 0))
462,8 → 462,7
abs((double)(Navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius &&
abs((double)(Navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius)
{
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
handler->send_waypoint(desired_pos);
}
else
{
498,49 → 497,35
// Hardware Auswahl und umschalten
void MKTool::slot_rb_Hardware()
{
//FIXME:put this in Handler.cpp
if ((rb_SelNC->isChecked() == false) && (Mode.ID != ADDRESS_NC))
{
lb_Status->setText(tr("Schalte um auf NaviCtrl."));
/*TX_Data[0] = 0x1B;
TX_Data[1] = 0x1B;
TX_Data[2] = 0x55;
TX_Data[3] = 0xAA;
TX_Data[4] = 0x00;
TX_Data[5] = '\r';
o_Connection->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);
ToolBox::wait(SLEEP);*/
handler->switch_navictrl();
//FIXME: remove wait?
ToolBox::wait(SLEEP);
}
 
if (rb_SelFC->isChecked())
{
lb_Status->setText(tr("Schalte um auf FlightCtrl."));
/*TX_Data[0] = 0;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);*/
handler->switch_flightctrl();
}
else
if (rb_SelMag->isChecked())
{
lb_Status->setText(tr("Schalte um auf MK3MAG."));
/*TX_Data[0] = 1;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);*/
handler->switch_mk3mag();
}
else
if (rb_SelNC->isChecked())
{
lb_Status->setText(tr("Schalte um auf NaviCtrl."));
/*TX_Data[0] = 0x1B;
TX_Data[1] = 0x1B;
TX_Data[2] = 0x55;
TX_Data[3] = 0xAA;
TX_Data[4] = 0x00;
TX_Data[5] = '\r';
o_Connection->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);*/
handler->switch_navictrl();
}
ToolBox::wait(SLEEP);
 
// qDebug("Select RB Hardware");
//o_Connection->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
handler->get_version();
}
 
// Ticker-Event
711,16 → 696,7
 
void MKTool::slot_Motortest(sMotor p_Motor)
{
//FIXME: put this in com/Handler.cpp
/*
Motor = p_Motor;
 
for (int z = 0; z<12; z++)
{
TX_Data[z] = Motor.Speed[z];
}
o_Connection->send_Cmd('t', ADDRESS_FC, TX_Data, 12, false);
*/
handler->motor_test(p_Motor);
}
 
// Motormixer-Einstellungen anzeigen
747,10 → 723,7
connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN()));
//FIXME: put this in com/Handler.cpp
f_LCD->show();
/*TX_Data[0] = 0;
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
*/
handler->show_lcd();
//FIXME: replace ticker with something else
Ticker->setInterval(500);
TickerEvent[2] = true;
768,14 → 741,12
 
void MKTool::slot_MAP_SetWayPoints(QList<sWayPoint> l_WayPoints)
{
//FIXME: Put this in com/Handler.cpp or com/NaviCtrlHandler.cpp
/*
Waypoint_t WayPoint;
//FIXME: Put this in com/Handler.cpp or com/NaviCtrl.cpp
 
double Longitude, Latitude;
 
// Waypoint-Liste löschen
WayPoint.Position.Status = INVALID;
o_Connection->send_Cmd('w', ADDRESS_NC, (char *)&WayPoint, sizeof(WayPoint), false);
// delete waypoint-list
handler->delete_waypoints();
ToolBox::wait(SLEEP);
 
for (int z = 0; z < l_WayPoints.count(); z++)
789,6 → 760,7
if (Latitude < 100)
Latitude *= 10000000+0.5;
 
Waypoint_t WayPoint;
//fülle Wegpunkt-Daten
WayPoint.Position.Altitude = 0;
WayPoint.Position.Longitude = int32_t(Longitude);
803,10 → 775,9
WayPoint.reserve[2] = 0; // reserve
WayPoint.reserve[3] = 0; // reserve
 
o_Connection->send_Cmd('w', ADDRESS_NC, (char *)&WayPoint, sizeof(WayPoint), false);
handler->add_waypoint(WayPoint);
// ToolBox::Wait(SLEEP);
}
*/
}
 
void MKTool::slot_MAP_SetTarget(sWayPoint Target)
963,15 → 934,13
if (ac_FastNavi->isChecked())
{
lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
//TX_Data[0] = Settings->Data.Navi_Fast / 10;
handler->set_navictrl_debug(Settings->Data.Navi_Fast / 10);
}
else
{
lb_Status->setText(tr("Fordere langsame NaviDaten an."));
//TX_Data[0] = Settings->Data.Navi_Slow / 10;
handler->set_navictrl_debug(Settings->Data.Navi_Slow / 10);
}
//FIXME: put this in com/Handler.cpp / com/NaviCtrl.cpp
//o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
}
}
 
980,7 → 949,7
if (ac_NoNavi->isChecked())
{
lb_Status->setText(tr("NaviDaten abstellen."));
// TX_Data[0] = 0;
handler->stop_navictrl_debug();
}
else
{
987,16 → 956,14
if (ac_FastNavi->isChecked())
{
lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
// TX_Data[0] = Settings->Data.Navi_Fast / 10;
handler->set_navictrl_debug(Settings->Data.Navi_Fast / 10);
}
else
{
lb_Status->setText(tr("Fordere langsame NaviDaten an."));
// TX_Data[0] = Settings->Data.Navi_Slow / 10;
handler->set_navictrl_debug(Settings->Data.Navi_Slow / 10);
}
}
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
}
 
void MKTool::slot_ac_FastDebug() // DONE 0.71g
1006,15 → 973,13
if (ac_FastDebug->isChecked())
{
lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
//TX_Data[0] = Settings->Data.Debug_Fast / 10;
handler->set_all_debug(Settings->Data.Debug_Fast / 10);
}
else
{
lb_Status->setText(tr("Fordere langsame DebugDaten an."));
//TX_Data[0] = Settings->Data.Debug_Slow / 10;
handler->set_all_debug(Settings->Data.Debug_Slow / 10);
}
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
}
}
 
1024,7 → 989,7
{
lb_Status->setText(tr("DebugDaten abstellen."));
TickerEvent[3] = false;
//TX_Data[0] = 0;
handler->stop_all_debug();
}
else
{
1035,16 → 1000,14
if (ac_FastDebug->isChecked())
{
lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
//TX_Data[0] = Settings->Data.Debug_Fast / 10;
handler->set_all_debug(Settings->Data.Debug_Fast / 10);
}
else
{
lb_Status->setText(tr("Fordere langsame DebugDaten an."));
//TX_Data[0] = Settings->Data.Debug_Slow / 10;
handler->set_all_debug(Settings->Data.Debug_Slow / 10);
}
}
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
}
 
void MKTool::slot_ac_About()
1055,9 → 1018,7
void MKTool::slot_ac_GetLabels() // DONE 0.71g
{
lb_Status->setText(tr("Analoglabels auslesen."));
//FIXME: Put this in com/Handler.cpp
// TX_Data[0] = 0;
// o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
handler->get_analog();
}
 
void MKTool::slot_ac_StartServer()
1223,9 → 1184,11
{
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->listWidget->currentRow() == 1))
{
// TX_Data[0] = 0;
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false);
//FIXME: Do we really need the ppm-channels if we change the page?
// maybe this is a bug or the description on
// http://www.mikrokopter.com/ucwiki/en/SerialCommands
// is WRONG!
handler->get_ppm_channels();
 
Ticker->setInterval(500);
TickerEvent[1] = true;
1241,29 → 1204,12
// LCD-Seiten weiterschalten
void MKTool::slot_LCD_UP() // DONE 0.71g
{
//FIXME: Put this in com/Handler.cpp
/* if (LCD_Page == LCD_MAX_Page)
TX_Data[0] = 0;
else
TX_Data[0] = LCD_Page + 1;
 
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
*/
handler->lcd_up();
}
 
void MKTool::slot_LCD_DOWN() // DONE 0.71g
{
//FIXME: Put this in com/Handler.cpp
/*
if (LCD_Page == 0)
TX_Data[0] = LCD_MAX_Page;
else
TX_Data[0] = LCD_Page - 1;
 
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
*/
handler->lcd_down();
}
 
// Settings aus MK lesen / in MK schreiben
1270,24 → 1216,13
void MKTool::slot_GetFCSettings() // DONE 0.71g
{
lb_Status->setText(tr("Lese FlightCtrl-Settings aus."));
//FIXME: Put this in com/Handler.cpp
/*
TX_Data[0] = f_Settings->sb_Set->value();
TX_Data[1] = 0;
o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true);
*/
handler->get_flightctrl_settings(f_Settings->sb_Set->value());
}
 
void MKTool::slot_SetFCSettings() // DONE 0.71g
{
//FIXME: Put this in com/Handler.cpp
/*
char *TX_Data2 = f_Settings->GetFCSettings();
 
handler->set_flightctrl_settings(f_Settings->GetFCSettings());
lb_Status->setText(tr("Schreibe FlightCtrl-Settings."));
 
o_Connection->send_Cmd('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, true);
*/
}
 
 
/QMK-Groundstation/branches/own_com_lib/Forms/mktool.h
126,10 → 126,6
bool TickerEvent[MaxTickerEvents];
bool TickerDiv;
 
// Aktuelle und Max-Anzahl der LCD-Seiten
int LCD_Page;
int LCD_MAX_Page;
 
//Logger für CVS und andere
Logger * logger;
 
/QMK-Groundstation/branches/own_com_lib/com/Communication.cpp
0,0 → 1,5
#include "Communication.h"
 
bool Communication::is_connected() {
return connected;
}
/QMK-Groundstation/branches/own_com_lib/com/Communication.h
9,6 → 9,8
using namespace std;
 
class Communication{
protected:
bool connected;
public:
//connect to MK
virtual void connect_MK(string) {};
15,5 → 17,7
//send command to MK
virtual bool send_cmd(char, int, char[150],unsigned int, bool) { return false; };
virtual void stop_resend() {};
bool is_connected();
};
#endif
/QMK-Groundstation/branches/own_com_lib/com/Handler.cpp
7,7 → 7,35
this->com = com;
}
 
//-------------FlightCtrl commands--------------------
/**
* read settings from FlightCtrl (settings index 0x00-0x05)
*/
void Handler::get_flightctrl_settings(int index) {
char tx_data[2] = {index, 0};
com->send_cmd('q', ADDRESS_FC, tx_data, 1, true);
}
 
/**
* write settings to FlightCtrl
*/
void Handler::set_flightctrl_settings(char * tx_data) {
com->send_cmd('s', ADDRESS_FC, tx_data, MaxParameter+2, true);
}
 
/**
* test one or more motors
*/
void Handler::motor_test(sMotor motor) {
char tx_data[12];
for (int z = 0; z<12; z++)
{
tx_data[z] = motor.Speed[z];
}
com->send_cmd('t', ADDRESS_FC, tx_data, 12, false);
}
 
/**
* read mixer values from FlightCtrl
*/
void Handler::read_mixer() {
16,9 → 44,140
com->send_cmd('n', ADDRESS_FC, tx_data, 1, true);
}
 
/**
* write motor mixer values to FlightCtrl
*/
void Handler::write_mixer(char * tx_data, int length) {
com->send_cmd('m', ADDRESS_FC, tx_data, length, true);
}
 
void Handler::get_motor_config() {
}
 
//-------------NaviCtrl commands--------------------
/**
* set debug values for NaviCtrl
*/
void Handler::set_navictrl_debug(int speed) {
char tx_data[1] = { speed };
com->send_cmd('o', ADDRESS_NC, tx_data, 1, false);
}
 
/**
* stop debug for NaviCtrl
*/
void Handler::stop_navictrl_debug() {
set_navictrl_debug(0);
}
 
/**
* send a waypoint to the NaviCtrl (the copter will fly to the position emidiately)
*/
void Handler::send_waypoint(Waypoint_t desired_pos) {
com->send_cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
}
 
/**
* add waypoint to waypoint list
*/
void Handler::add_waypoint(Waypoint_t wp) {
com->send_cmd('w', ADDRESS_NC, (char *)&wp, sizeof(wp), false);
}
 
/**
* clear waypoint list on MK
*/
void Handler::delete_waypoints() {
Waypoint_t wp;
wp.Position.Status = INVALID;
send_waypoint(wp);
}
//-------------switch between Hardware--------------------
void Handler::switch_navictrl() {
char tx_data[6] = { 0x1B, 0x1B, 0x55, 0xAA, 0x00, '\r'};
com->send_cmd('#', ADDRESS_NC, tx_data, 6, false);
}
 
void Handler::switch_flightctrl() {
char tx_data[1] = { 0 };
com->send_cmd('u', ADDRESS_NC, tx_data, 1, false);
}
 
void Handler::switch_mk3mag() {
char tx_data[1] = { 1 };
com->send_cmd('u', ADDRESS_NC, tx_data, 1, false);
}
 
//-------------commands for MK3MAG-----------------
 
 
//-------------commands for all--------------------
 
/**
* set debug values for all components
*/
void Handler::set_all_debug(int speed) {
char tx_data[1] = { speed };
com->send_cmd('d', ADDRESS_ALL, tx_data, 1, false);
}
 
/**
* stop debug for all components
*/
void Handler::stop_all_debug() {
set_all_debug(0);
}
 
/**
* get all analog labels
*/
void Handler::get_analog() {
char tx_data[1] = { 0 };
com->send_cmd('a', ADDRESS_ALL, tx_data, 1, true);
}
 
/**
* get values from LCD / show LCD
*/
void Handler::show_lcd() {
char tx_data[1] = {0};
com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true);
}
 
/**
* got to next LCD Page
*/
void Handler::lcd_up() {
char tx_data[2] = { 0, 0 };
if (lcd_cur != lcd_max)
tx_data[0] = lcd_cur+1;
com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true);
}
 
/**
* got to previous LCD Page
*/
void Handler::lcd_down() {
char tx_data[2] = { 0, 0 };
if (lcd_cur != 0)
tx_data[0] = lcd_cur-1;
com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true);
}
 
void Handler::get_version() {
//TODO: Check if is this correct or do we need data from switch_...
char tx_data[1] = { 0 };
com->send_cmd('v', ADDRESS_ALL, tx_data, 0, true);
}
 
void Handler::get_ppm_channels() {
char tx_data[1] = { 0 };
com->send_cmd('p', ADDRESS_ALL, tx_data, 0, false);
}
 
/**
* receive data
*/
void Handler::receive_data(sRxData RX) {
//extract hardware ID from received Data
int hardwareID = RX.input[1] - 'a';
/QMK-Groundstation/branches/own_com_lib/com/Handler.h
5,6 → 5,7
#include "Communication.h"
#include "Kopter.h"
#include "../Parameter_Positions.h"
#include "../typedefs.h"
 
/**
* The Handler handels commands that are send from/to the Mikrokopter
15,13 → 16,48
private:
Communication * com;
 
// current LCD page
int lcd_cur;
//max count of LCD pages
int lcd_max;
//buffer to send data
//char tx_data[150];
public:
Handler(Communication * com);
//FlightCtrl commands
void get_flightctrl_settings(int index);
void set_flightctrl_settings(char * tx_data);
void motor_test(sMotor motor);
void read_mixer();
void write_mixer(char * tx_data, int length);
void get_motor_config();
 
//NaviCtrl commands
void set_navictrl_debug(int speed);
void stop_navictrl_debug();
void send_waypoint(Waypoint_t desired_pos);
void add_waypoint(Waypoint_t wp);
void delete_waypoints();
 
//switch between MK modules/components
void switch_navictrl();
void switch_flightctrl();
void switch_mk3mag();
 
//commands for MK3MAG
 
//commands for all modules/components
void set_all_debug(int speed);
void stop_all_debug();
void get_analog();
void show_lcd();
void lcd_up();
void lcd_down();
void get_version();
void get_ppm_channels();
 
void receive_data(sRxData rx);
void get_motor_config();
};
 
#endif
/QMK-Groundstation/branches/own_com_lib/com/QTCommunication.cpp
14,6 → 14,10
return true;
};
 
/**
* stop sending commands to Mikrokopter
* stop timer
*/
void QTCommunication::stop_resend() {
};
/QMK-Groundstation/branches/own_com_lib/README
1,2 → 1,2
QMK-Groundstation with seperated communication and Mikrokopter-Library that can be used in other programs.
Based on SVN version r390
Based on SVN trunk version r395
/QMK-Groundstation/branches/own_com_lib/com.pri
9,7 → 9,8
Kopter.h \
Parser.h \
QTCommunication.h
SOURCES += Handler.cpp \
SOURCES += Communication.cpp \
Handler.cpp \
Parser.cpp \
QTCommunication.cpp
QT += network
/QMK-Groundstation/TODO.TXT
7,6 → 7,7
DONE ** Übertragen von Targets und Waypoints.
DONE ** Icons und Iconhandling überarbeiten.
** Help-Texte bei den Settings aus Datei laden.
** Englische Übersetzung / allgemeine i18n Anbindung.
 
* Settings-Vergleich
* Flashen der AVR's (Bootloader).
13,4 → 14,5
* Software-Update ohne AVRDUDE.
* Software-Update für NaviCtrl.
 
* Lösen der Tabs als einzelne Fenster ermöglichen.
* Eigene Mikrokopter-Bibliothek (siehe branches/own_com_lib)
* Lösen der Tabs als einzelne Fenster ermöglichen.