Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 399 → Rev 398

/QMK-Groundstation/TODO.TXT
7,7 → 7,6
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).
14,5 → 13,4
* Software-Update ohne AVRDUDE.
* Software-Update für NaviCtrl.
 
* Eigene Mikrokopter-Bibliothek (siehe branches/own_com_lib)
* Lösen der Tabs als einzelne Fenster ermöglichen.
* Lösen der Tabs als einzelne Fenster ermöglichen.
/QMK-Groundstation/branches/own_com_lib/Forms/dlg_MotorMixer.cpp
292,7 → 292,8
 
void dlg_MotorMixer::read_Mixer()
{
//See Handler::read_mixer in com/Handler.cpp
TX_Data[0] = 0;
o_Connection->send_Cmd('n', ADDRESS_FC, TX_Data, 1, true);
}*/
 
// read motor values
307,8 → 308,8
 
void dlg_MotorMixer::slot_pb_WRITE()
{
/* int Length = handler->get_motor_config();
handler->write_mixer(TX_Data, Length);*/
/* int Length = get_MotorConfig();
o_Connection->send_Cmd('m', ADDRESS_FC, TX_Data, Length, true);*/
}
 
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,7 → 462,8
abs((double)(Navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius &&
abs((double)(Navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius)
{
handler->send_waypoint(desired_pos);
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
}
else
{
497,35 → 498,49
// 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."));
handler->switch_navictrl();
//FIXME: remove wait?
ToolBox::wait(SLEEP);
/*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);*/
}
 
if (rb_SelFC->isChecked())
{
lb_Status->setText(tr("Schalte um auf FlightCtrl."));
handler->switch_flightctrl();
/*TX_Data[0] = 0;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);*/
}
else
if (rb_SelMag->isChecked())
{
lb_Status->setText(tr("Schalte um auf MK3MAG."));
handler->switch_mk3mag();
/*TX_Data[0] = 1;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);*/
}
else
if (rb_SelNC->isChecked())
{
lb_Status->setText(tr("Schalte um auf NaviCtrl."));
handler->switch_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);
 
// qDebug("Select RB Hardware");
handler->get_version();
//o_Connection->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
}
 
// Ticker-Event
696,7 → 711,16
 
void MKTool::slot_Motortest(sMotor p_Motor)
{
handler->motor_test(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);
*/
}
 
// Motormixer-Einstellungen anzeigen
723,7 → 747,10
connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN()));
//FIXME: put this in com/Handler.cpp
f_LCD->show();
handler->show_lcd();
/*TX_Data[0] = 0;
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
*/
//FIXME: replace ticker with something else
Ticker->setInterval(500);
TickerEvent[2] = true;
741,12 → 768,14
 
void MKTool::slot_MAP_SetWayPoints(QList<sWayPoint> l_WayPoints)
{
//FIXME: Put this in com/Handler.cpp or com/NaviCtrl.cpp
 
//FIXME: Put this in com/Handler.cpp or com/NaviCtrlHandler.cpp
/*
Waypoint_t WayPoint;
double Longitude, Latitude;
 
// delete waypoint-list
handler->delete_waypoints();
// Waypoint-Liste löschen
WayPoint.Position.Status = INVALID;
o_Connection->send_Cmd('w', ADDRESS_NC, (char *)&WayPoint, sizeof(WayPoint), false);
ToolBox::wait(SLEEP);
 
for (int z = 0; z < l_WayPoints.count(); z++)
760,7 → 789,6
if (Latitude < 100)
Latitude *= 10000000+0.5;
 
Waypoint_t WayPoint;
//fülle Wegpunkt-Daten
WayPoint.Position.Altitude = 0;
WayPoint.Position.Longitude = int32_t(Longitude);
775,9 → 803,10
WayPoint.reserve[2] = 0; // reserve
WayPoint.reserve[3] = 0; // reserve
 
handler->add_waypoint(WayPoint);
o_Connection->send_Cmd('w', ADDRESS_NC, (char *)&WayPoint, sizeof(WayPoint), false);
// ToolBox::Wait(SLEEP);
}
*/
}
 
void MKTool::slot_MAP_SetTarget(sWayPoint Target)
934,13 → 963,15
if (ac_FastNavi->isChecked())
{
lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
handler->set_navictrl_debug(Settings->Data.Navi_Fast / 10);
//TX_Data[0] = Settings->Data.Navi_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame NaviDaten an."));
handler->set_navictrl_debug(Settings->Data.Navi_Slow / 10);
//TX_Data[0] = 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);
}
}
 
949,7 → 980,7
if (ac_NoNavi->isChecked())
{
lb_Status->setText(tr("NaviDaten abstellen."));
handler->stop_navictrl_debug();
// TX_Data[0] = 0;
}
else
{
956,14 → 987,16
if (ac_FastNavi->isChecked())
{
lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
handler->set_navictrl_debug(Settings->Data.Navi_Fast / 10);
// TX_Data[0] = Settings->Data.Navi_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame NaviDaten an."));
handler->set_navictrl_debug(Settings->Data.Navi_Slow / 10);
// TX_Data[0] = 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
973,13 → 1006,15
if (ac_FastDebug->isChecked())
{
lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
handler->set_all_debug(Settings->Data.Debug_Fast / 10);
//TX_Data[0] = Settings->Data.Debug_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame DebugDaten an."));
handler->set_all_debug(Settings->Data.Debug_Slow / 10);
//TX_Data[0] = Settings->Data.Debug_Slow / 10;
}
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
}
}
 
989,7 → 1024,7
{
lb_Status->setText(tr("DebugDaten abstellen."));
TickerEvent[3] = false;
handler->stop_all_debug();
//TX_Data[0] = 0;
}
else
{
1000,14 → 1035,16
if (ac_FastDebug->isChecked())
{
lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
handler->set_all_debug(Settings->Data.Debug_Fast / 10);
//TX_Data[0] = Settings->Data.Debug_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame DebugDaten an."));
handler->set_all_debug(Settings->Data.Debug_Slow / 10);
//TX_Data[0] = 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()
1018,7 → 1055,9
void MKTool::slot_ac_GetLabels() // DONE 0.71g
{
lb_Status->setText(tr("Analoglabels auslesen."));
handler->get_analog();
//FIXME: Put this in com/Handler.cpp
// TX_Data[0] = 0;
// o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
}
 
void MKTool::slot_ac_StartServer()
1184,11 → 1223,9
{
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->listWidget->currentRow() == 1))
{
//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();
// TX_Data[0] = 0;
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false);
 
Ticker->setInterval(500);
TickerEvent[1] = true;
1204,12 → 1241,29
// LCD-Seiten weiterschalten
void MKTool::slot_LCD_UP() // DONE 0.71g
{
handler->lcd_up();
//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);
*/
}
 
void MKTool::slot_LCD_DOWN() // DONE 0.71g
{
handler->lcd_down();
//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);
*/
}
 
// Settings aus MK lesen / in MK schreiben
1216,13 → 1270,24
void MKTool::slot_GetFCSettings() // DONE 0.71g
{
lb_Status->setText(tr("Lese FlightCtrl-Settings aus."));
handler->get_flightctrl_settings(f_Settings->sb_Set->value());
//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);
*/
}
 
void MKTool::slot_SetFCSettings() // DONE 0.71g
{
handler->set_flightctrl_settings(f_Settings->GetFCSettings());
//FIXME: Put this in com/Handler.cpp
/*
char *TX_Data2 = 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,6 → 126,10
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/README
1,2 → 1,2
QMK-Groundstation with seperated communication and Mikrokopter-Library that can be used in other programs.
Based on SVN trunk version r395
Based on SVN version r390
/QMK-Groundstation/branches/own_com_lib/com/Communication.cpp
File deleted
\ No newline at end of file
/QMK-Groundstation/branches/own_com_lib/com/Communication.h
9,8 → 9,6
using namespace std;
 
class Communication{
protected:
bool connected;
public:
//connect to MK
virtual void connect_MK(string) {};
17,7 → 15,5
//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,35 → 7,7
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() {
44,140 → 16,9
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,7 → 5,6
#include "Communication.h"
#include "Kopter.h"
#include "../Parameter_Positions.h"
#include "../typedefs.h"
 
/**
* The Handler handels commands that are send from/to the Mikrokopter
16,48 → 15,13
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 receive_data(sRxData rx);
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);
};
 
#endif
/QMK-Groundstation/branches/own_com_lib/com/QTCommunication.cpp
14,10 → 14,6
return true;
};
 
/**
* stop sending commands to Mikrokopter
* stop timer
*/
void QTCommunication::stop_resend() {
};
/QMK-Groundstation/branches/own_com_lib/com.pri
9,8 → 9,7
Kopter.h \
Parser.h \
QTCommunication.h
SOURCES += Communication.cpp \
Handler.cpp \
SOURCES += Handler.cpp \
Parser.cpp \
QTCommunication.cpp
QT += network