/QMK-Groundstation/trunk/Global/Class_HandlerMK/HandlerMK.cpp |
---|
23,7 → 23,7 |
} |
// Datensatz nach 16bit Integer |
int HandlerMK::Data2Int(unsigned char Data[150] , int Start, bool is_signed) |
int HandlerMK::Data2Int(unsigned char Data[160] , int Start, bool is_signed) |
{ |
int Out = (Data[Start+1]<<8) | (Data[Start+0]); |
139,13 → 139,13 |
} |
// Base64 Encoder |
QString HandlerMK::Encode64(char Data[150],unsigned int Length) |
QString HandlerMK::Encode64(char Data[160],unsigned int Length) |
{ |
unsigned int pt = 0; |
unsigned char a,b,c; |
unsigned char ptr = 0; |
char TX_Buff[150]; |
char TX_Buff[160]; |
while(Length > 0) |
{ |
163,7 → 163,7 |
return QString(TX_Buff); |
} |
QString HandlerMK::make_Frame(char t_CMD, int t_Adress, char t_Data[150], unsigned int t_Length) |
QString HandlerMK::make_Frame(char t_CMD, int t_Adress, char t_Data[160], unsigned int t_Length) |
{ |
QString tx_Data = Encode64(t_Data, t_Length); |
/QMK-Groundstation/trunk/Global/Class_HandlerMK/HandlerMK.h |
---|
44,14 → 44,14 |
HandlerMK(); |
static int Data2Int(unsigned char Data[150], int Start, bool is_signed = true); |
static QString Data2QString(unsigned char Data[150], int Start, int End); |
static QString Data2QString(unsigned char Data[160], int Start, int End); |
static QString add_CRC(QString TXString); |
static bool Check_CRC(char *t_InData, int Length); |
static int Decode_64(char *t_InData, int Length, unsigned char *t_OutData); |
static QString Encode64(char Data[150],unsigned int Length); |
static QString make_Frame(char t_CMD, int t_Adress, char t_Data[150], unsigned int t_Length); |
static QString Encode64(char Data[160],unsigned int Length); |
static QString make_Frame(char t_CMD, int t_Adress, char t_Data[160], unsigned int t_Length); |
static QString get_SelectFC(); |
static QString get_SelectNC(); |
/QMK-Groundstation/trunk/Global/Class_Input/Input_TCP.cpp |
---|
141,10 → 141,12 |
void Input_TCP::slot_TCP_ReadLine() |
{ |
// QString t_Data = QString(TCP_Socket->readLine(TCP_Socket->bytesAvailable())).remove(QChar('\n')); |
QString t_Data = s_Buffer + QString(TCP_Socket->readAll()); |
QString t_Data = s_Buffer + QString(TCP_Socket->readAll()).remove(QChar('\n')); |
s_Buffer = ""; |
t_Data = t_Data.replace('\r', "\r\n"); |
QStringList l_Data; |
l_Data = t_Data.split('\n'); |
/QMK-Groundstation/trunk/Global/Class_QMapControl/googlemapadapter.cpp |
---|
27,8 → 27,9 |
namespace qmapcontrol |
{ |
GoogleMapAdapter::GoogleMapAdapter() |
: TileMapAdapter("mt2.google.com", "/mt?n=404&x=%2&y=%3&zoom=%1", 256, 17, 0) |
//: TileMapAdapter("tile.openstreetmap.org", "/%1/%2/%3.png", 256, 0, 17) |
: TileMapAdapter("mt1.google.com", "/vt/lyrs=m@120&hl=de&x=%2&y=%3&z=%1&s=", 256, 0, 17) |
// : TileMapAdapter("mt1.google.com", "/mt?n=404&x=%2&y=%3&zoom=%1", 256, 17, 0) |
// : TileMapAdapter("server.arcgisonline.com", "/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/%1/%3/%2", 512, 0, 17) |
{ |
} |
/QMK-Groundstation/trunk/Global/Class_QMapControl/googlesatmapadapter.cpp |
---|
24,158 → 24,14 |
*/ |
#include "googlesatmapadapter.h" |
#include <math.h> |
namespace qmapcontrol |
{ |
GoogleSatMapAdapter::GoogleSatMapAdapter() |
: TileMapAdapter("kh.google.com", "/kh?n=404&v=8&t=trtqtt", 256, 0, 19) |
: TileMapAdapter("khm1.google.com", "/kh/v=57&hl=de&x=%2&y=%3&z=%1&s=", 256, 0, 20) |
{ |
// name = "googlesat"; |
numberOfTiles = pow(2, current_zoom+0.0); |
coord_per_x_tile = 360. / numberOfTiles; |
coord_per_y_tile = 180. / numberOfTiles; |
} |
GoogleSatMapAdapter::~GoogleSatMapAdapter() |
{ |
} |
QString GoogleSatMapAdapter::getHost() const |
{ |
int random = qrand() % 4; |
return QString("kh%1.google.com").arg(random); |
} |
QPoint GoogleSatMapAdapter::coordinateToDisplay(const QPointF& coordinate) const |
{ |
//double x = ((coordinate.x()+180)*(tilesize*numberOfTiles/360)); |
//double y = (((coordinate.y()*-1)+90)*(tilesize*numberOfTiles/180)); |
qreal x = (coordinate.x()+180.) * (numberOfTiles*mytilesize)/360.; // coord to pixel! |
//double y = -1*(coordinate.y()-90) * (numberOfTiles*tilesize)/180.; // coord to pixel! |
qreal y = (getMercatorYCoord(coordinate.y())-M_PI) * -1 * (numberOfTiles*mytilesize)/(2*M_PI); // coord to pixel! |
return QPoint(int(x), int(y)); |
} |
QPointF GoogleSatMapAdapter::displayToCoordinate(const QPoint& point) const |
{ |
//double lon = ((point.x()/tilesize*numberOfTiles)*360)-180; |
//double lat = (((point.y()/tilesize*numberOfTiles)*180)-90)*-1; |
qreal lon = (point.x()*(360./(numberOfTiles*mytilesize)))-180.; |
//double lat = -(point.y()*(180./(numberOfTiles*tilesize)))+90; |
//qreal lat = getMercatorLatitude(point.y()*-1*(2*M_PI/(numberOfTiles*tilesize)) + M_PI); |
qreal lat = lat *180./M_PI; |
return QPointF(lon, lat); |
} |
qreal GoogleSatMapAdapter::getMercatorLatitude(qreal YCoord) const |
{ |
//http://welcome.warnercnr.colostate.edu/class_info/nr502/lg4/projection_mathematics/converting.html |
if (YCoord > M_PI) return 9999.; |
if (YCoord < -M_PI) return -9999.; |
qreal t = atan(exp(YCoord)); |
qreal res = (2.*(t))-(M_PI/2.); |
return res; |
} |
qreal GoogleSatMapAdapter::getMercatorYCoord(qreal lati) const |
{ |
qreal lat = lati; |
// conversion degre=>radians |
qreal phi = M_PI * lat / 180; |
qreal res; |
//double temp = Math.Tan(Math.PI / 4 - phi / 2); |
//res = Math.Log(temp); |
res = 0.5 * log((1 + sin(phi)) / (1 - sin(phi))); |
return res; |
} |
void GoogleSatMapAdapter::zoom_in() |
{ |
current_zoom+=1; |
numberOfTiles = pow(2, current_zoom+0.0); |
coord_per_x_tile = 360. / numberOfTiles; |
coord_per_y_tile = 180. / numberOfTiles; |
} |
void GoogleSatMapAdapter::zoom_out() |
{ |
current_zoom-=1; |
numberOfTiles = pow(2, current_zoom+0.0); |
coord_per_x_tile = 360. / numberOfTiles; |
coord_per_y_tile = 180. / numberOfTiles; |
} |
bool GoogleSatMapAdapter::isValid(int x, int y, int z) const |
{ |
if ((x>=0 && x < numberOfTiles) && (y>=0 && y < numberOfTiles) && z>=0) |
{ |
return true; |
} |
return false; |
} |
QString GoogleSatMapAdapter::query(int i, int j, int z) const |
{ |
return getQ(-180+i*coord_per_x_tile, |
90-(j+1)*coord_per_y_tile, z); |
} |
QString GoogleSatMapAdapter::getQ(qreal longitude, qreal latitude, int zoom) const |
{ |
qreal xmin=-180; |
qreal xmax=180; |
qreal ymin=-90; |
qreal ymax=90; |
qreal xmoy=0; |
qreal ymoy=0; |
QString location="t"; |
//Google uses a latitude divided by 2; |
qreal halflat = latitude; |
for (int i = 0; i < zoom; i++) |
{ |
xmoy = (xmax + xmin) / 2; |
ymoy = (ymax + ymin) / 2; |
if (halflat >= ymoy) //upper part (q or r) |
{ |
ymin = ymoy; |
if (longitude < xmoy) |
{ /*q*/ |
location+= "q"; |
xmax = xmoy; |
} |
else |
{/*r*/ |
location+= "r"; |
xmin = xmoy; |
} |
} |
else //lower part (t or s) |
{ |
ymax = ymoy; |
if (longitude < xmoy) |
{ /*t*/ |
location+= "t"; |
xmax = xmoy; |
} |
else |
{/*s*/ |
location+= "s"; |
xmin = xmoy; |
} |
} |
} |
return QString("/kh?n=404&v=24&t=%1").arg(location); |
} |
} |
/QMK-Groundstation/trunk/Global/Class_QMapControl/googlesatmapadapter.h |
---|
27,6 → 27,7 |
#define GOOGLESATMAPADAPTER_H |
#include "tilemapadapter.h" |
namespace qmapcontrol |
{ |
//! MapAdapter for Google |
37,6 → 38,7 |
class GoogleSatMapAdapter : public TileMapAdapter |
{ |
Q_OBJECT |
public: |
//! constructor |
/*! |
44,31 → 46,6 |
*/ |
GoogleSatMapAdapter(); |
virtual ~GoogleSatMapAdapter(); |
virtual QPoint coordinateToDisplay(const QPointF&) const; |
virtual QPointF displayToCoordinate(const QPoint&) const; |
//! returns the host of this MapAdapter |
/*! |
* @return the host of this MapAdapter |
*/ |
QString getHost () const; |
protected: |
virtual void zoom_in(); |
virtual void zoom_out(); |
virtual QString query(int x, int y, int z) const; |
virtual bool isValid(int x, int y, int z) const; |
private: |
virtual QString getQ(qreal longitude, qreal latitude, int zoom) const; |
qreal getMercatorLatitude(qreal YCoord) const; |
qreal getMercatorYCoord(qreal lati) const; |
qreal coord_per_x_tile; |
qreal coord_per_y_tile; |
int srvNum; |
}; |
} |
#endif |
/QMK-Groundstation/trunk/Global/Class_SerialPort.pri |
---|
1,3 → 1,6 |
win32:DEFINES += _TTY_WIN_ WIN32 |
unix:DEFINES += _TTY_POSIX_ |
DEPENDPATH += ../Global/Class_SerialPort |
INCLUDEPATH += ../Global/Class_SerialPort |
/QMK-Groundstation/trunk/Global/Kopter.h |
---|
24,9 → 24,9 |
#include <stdint.h> |
#ifdef _BETA_ |
static const QString QA_HWVERSION = "FlightCtrl v0.78f & NaviCtrl v0.18c"; |
static const QString QA_HWVERSION = "FlightCtrl v0.80g & NaviCtrl v0.20c"; |
#else |
static const QString QA_HWVERSION = "FlightCtrl v0.78f & NaviCtrl v0.18c"; |
static const QString QA_HWVERSION = "FlightCtrl v0.80g & NaviCtrl v0.20c"; |
#endif |
// Datenfeld-ID's |
/QMK-Groundstation/trunk/Global/MK_Datatypes.h |
---|
22,12 → 22,12 |
#include <stdint.h> |
#ifdef _BETA_ |
static const int MK_VERSION_SETTINGS = 82; // wird angepasst, wenn sich die EEPROM-Daten ge�ndert haben |
static const int MK_VERSION_SETTINGS = 84; // wird angepasst, wenn sich die EEPROM-Daten ge�ndert haben |
#else |
static const int MK_VERSION_SETTINGS = 82; // wird angepasst, wenn sich die EEPROM-Daten ge�ndert haben |
static const int MK_VERSION_SETTINGS = 84; // wird angepasst, wenn sich die EEPROM-Daten ge�ndert haben |
#endif |
static const int MK_VERSION_NAVI = 3; // wird angepasst, wenn sich die Navi-Daten ge�ndert haben |
static const int MK_VERSION_NAVI = 4; // wird angepasst, wenn sich die Navi-Daten ge�ndert haben |
static const int MK_VERSION_MIXER = 1; // wird angepasst, wenn sich die Mixer-Daten ge�ndert haben |
static const int MK_MAX_MOTOR = 16; // Maximale Anzahl der Motoren im Mixer |
41,14 → 41,32 |
static const int ADDRESS_FC = 1; |
static const int ADDRESS_NC = 2; |
static const int ADDRESS_MK3MAG = 3; |
static const int ADDRESS_BLC = 5; |
#define FLAG_MOTOR_RUN 1 |
#define FLAG_FLY 2 |
#define FLAG_CALIBRATE 4 |
#define FLAG_START 8 |
#define FLAG_NOTLANDUNG 16 |
#define FLAG_LOWBAT 32 |
#define FCFLAG_MOTOR_RUN 0x01 |
#define FCFLAG_FLY 0x02 |
#define FCFLAG_CALIBRATE 0x04 |
#define FCFLAG_START 0x08 |
#define FCFLAG_NOTLANDUNG 0x10 |
#define FCFLAG_LOWBAT 0x20 |
#define FCFLAG_SPI_RX_ERR 0x40 |
#define FCFLAG_I2CERR 0x80 |
#define DEFEKT_G_NICK 0x01 |
#define DEFEKT_G_ROLL 0x02 |
#define DEFEKT_G_GIER 0x04 |
#define DEFEKT_A_NICK 0x08 |
#define DEFEKT_A_ROLL 0x10 |
#define DEFEKT_A_Z 0x20 |
#define DEFEKT_PRESSURE 0x40 |
#define DEFEKT_CAREFREE_ERR 0x80 |
#define DEFEKT_I2C 0x01 |
#define DEFEKT_BL_MISSING 0x02 |
#define DEFEKT_SPI_RX_ERR 0x04 |
#define DEFEKT_PPM_ERR 0x08 |
#define DEFEKT_MIXER_ERR 0x10 |
#define CFG_HOEHENREGELUNG 0x01 |
#define CFG_HOEHEN_SCHALTER 0x02 |
#define CFG_HEADING_HOLD 0x04 |
71,6 → 89,34 |
#define CFG2_VARIO_BEEP 0x02 |
#define CFG_SENSITIVE_RC 0x04 |
#define CFG0_AIRPRESS_SENSOR 0x01 |
#define CFG0_HEIGHT_SWITCH 0x02 |
#define CFG0_HEADING_HOLD 0x04 |
#define CFG0_COMPASS_ACTIVE 0x08 |
#define CFG0_COMPASS_FIX 0x10 |
#define CFG0_GPS_ACTIVE 0x20 |
#define CFG0_AXIS_COUPLING_ACTIVE 0x40 |
#define CFG0_ROTARY_RATE_LIMITER 0x80 |
// defines for the receiver selection |
#define RECEIVER_PPM 0 |
#define RECEIVER_SPEKTRUM 1 |
#define RECEIVER_SPEKTRUM_HI_RES 2 |
#define RECEIVER_SPEKTRUM_LOW_RES 3 |
#define RECEIVER_JETI 4 |
#define RECEIVER_ACT_DSL 5 |
#define RECEIVER_UNKNOWN 0xFF |
struct s_MK_VersionInfo |
{ |
unsigned char SWMajor; |
unsigned char SWMinor; |
unsigned char ProtoMajor; |
unsigned char ProtoMinor; |
unsigned char SWPatch; |
unsigned char HardwareError[5]; |
}; |
struct s_MK_Debug |
{ |
unsigned char Digital[2]; |
95,8 → 141,8 |
{ |
// Die ersten beiden Bytes nicht an den MK senden. |
unsigned char Index; |
unsigned char Version; |
unsigned char Revision; |
unsigned char Kanalbelegung[12]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3 |
unsigned char GlobalConfig; // 0x01=H�henregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv |
unsigned char Hoehe_MinGas; // Wert : 0-100 |
120,6 → 166,7 |
unsigned char Gyro_D; // Wert : 0-250 |
unsigned char Gyro_Gier_P; // Wert : 10-250 |
unsigned char Gyro_Gier_I; // Wert : 0-250 |
unsigned char Gyro_Stability; // 0.80 Wert : 0-16 |
unsigned char UnterspannungsWarnung; // Wert : 0-250 |
unsigned char NotGas; // Wert : 0-250 //Gaswert bei Emp�ngsverlust |
unsigned char NotGasZeit; // Wert : 0-250 // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen |
133,12 → 180,10 |
unsigned char ServoNickComp; // Wert : 0-250 // Einfluss Gyro/Servo |
unsigned char ServoNickMin; // Wert : 0-250 // Anschlag |
unsigned char ServoNickMax; // Wert : 0-250 // Anschlag |
//--- Seit V0.75 |
unsigned char ServoRollControl; // Wert : 0-250 // Stellung des Servos |
unsigned char ServoRollComp; // Wert : 0-250 |
unsigned char ServoRollMin; // Wert : 0-250 |
unsigned char ServoRollMax; // Wert : 0-250 |
//--- |
unsigned char ServoRollControl; // 0.75 Wert : 0-250 // Stellung des Servos |
unsigned char ServoRollComp; // 0.75 Wert : 0-250 |
unsigned char ServoRollMin; // 0.75 Wert : 0-250 |
unsigned char ServoRollMax; // 0.75 Wert : 0-250 |
unsigned char ServoNickRefresh; // Speed of the Servo |
unsigned char Servo3; // Value or mapping of the Servo Output |
unsigned char Servo4; // Value or mapping of the Servo Output |
152,8 → 197,8 |
unsigned char WinkelUmschlagNick; // Wert: 0-250 180�-Punkt |
unsigned char WinkelUmschlagRoll; // Wert: 0-250 180�-Punkt |
unsigned char GyroAccAbgleich; // 1/k (Koppel_ACC_Wirkung) |
unsigned char Driftkomp; |
unsigned char DynamicStability; |
unsigned char Driftkomp; // |
unsigned char DynamicStability; // |
unsigned char UserParam5; // Wert : 0-250 |
unsigned char UserParam6; // Wert : 0-250 |
unsigned char UserParam7; // Wert : 0-250 |
163,9 → 208,8 |
unsigned char J16Timing; // for the J16 Output |
unsigned char J17Bitmask; // for the J17 Output |
unsigned char J17Timing; // for the J17 Output |
// seit version V0.75c |
unsigned char WARN_J16_Bitmask; // for the J16 Output |
unsigned char WARN_J17_Bitmask; // for the J17 Output |
unsigned char WARN_J16_Bitmask; // 0.75 for the J16 Output |
unsigned char WARN_J17_Bitmask; // 0.75 for the J17 Output |
//---NaviCtrl--------------------------------------------- |
unsigned char NaviGpsModeControl; // Parameters for the Naviboard |
unsigned char NaviGpsGain; |
185,19 → 229,24 |
unsigned char NaviPH_LoginTime; |
//---Ext.Ctrl--------------------------------------------- |
unsigned char ExternalControl; // for serial Control |
//------------------------------------------------ |
//---CareFree--------------------------------------------- |
unsigned char OrientationAngle; // 0.80 Where is the front-direction? |
unsigned char OrientationModeControl; // 0.80 switch for CareFree |
//-------------------------------------------------------- |
unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
unsigned char ServoCompInvert; // // 0x01 = Nick, 0x02 = Roll 0 oder 1 // WICHTIG!!! am Ende lassen |
unsigned char ExtraConfig; // bitcodiert |
char Name[12]; |
unsigned char crc; |
}; |
struct s_MK_Mixer |
{ |
char Revision; |
uint8_t Revision; |
char Name[12]; |
signed char Motor[16][4]; |
int8_t Motor[16][4]; |
uint8_t crc; |
}; |
/////////////// |
217,6 → 266,9 |
#define NC_FLAG_MANUAL_CONTROL 0x40 |
#define NC_FLAG_8 0x80 |
#define POINT_TYPE_WP 0 |
#define POINT_TYPE_POI 1 |
typedef struct |
{ |
int32_t Longitude; // in 1E-7 deg |
252,7 → 304,7 |
int8_t AngleNick; // current Nick angle in 1° |
int8_t AngleRoll; // current Rick angle in 1° |
uint8_t RC_Quality; // RC_Quality |
uint8_t MKFlags; // Flags from FC |
uint8_t FCFlags; // Flags from FC |
uint8_t NCFlags; // Flags from NC |
uint8_t Errorcode; // 0 --> okay |
uint8_t OperatingRadius; // current operation radius around the Home Position in m |
273,7 → 325,9 |
uint8_t ToleranceRadius; // in meters, if the MK is within that range around the target, then the next target is triggered |
uint8_t HoldTime; // in seconds, if the was once in the tolerance area around a WP, this time defies the delay before the next WP is triggered |
uint8_t Event_Flag; // future emplementation |
uint8_t reserve[12]; // reserve |
uint8_t Index; // to indentify different waypoints, workaround for bad communications PC <-> NC |
uint8_t Type; // type of Waypoint |
uint8_t reserve[11]; // reserve |
} __attribute__((packed)) s_MK_WayPoint; |
#endif // MK_DATATYPES_H |
/QMK-Groundstation/trunk/Global/Widget_Connection/wgt_Connection.cpp |
---|
142,6 → 142,7 |
void wgt_Connection::send_Data(QString ps_Data, int pi_ID) |
{ |
// qDebug(ps_Data.toLatin1().data()); |
o_Input->send_Data(ps_Data, pi_ID); |
} |
/QMK-Groundstation/trunk/Global/Widget_Connection/wgt_Connection.ui |
---|
6,7 → 6,7 |
<rect> |
<x>0</x> |
<y>0</y> |
<width>693</width> |
<width>765</width> |
<height>39</height> |
</rect> |
</property> |
35,10 → 35,10 |
<item row="0" column="0"> |
<widget class="QToolButton" name="btn_Connect"> |
<property name="text"> |
<string>...</string> |
<string>Verbinden</string> |
</property> |
<property name="icon"> |
<iconset resource="../../QMK-Maps/QMK-Maps.qrc"> |
<iconset resource="../../QMK-Scope/QMK-Scope.qrc"> |
<normaloff>:/Actions/Global/Images/Actions/Connection-NO.png</normaloff> |
<normalon>:/Actions/Global/Images/Actions/Connection-OK.png</normalon>:/Actions/Global/Images/Actions/Connection-NO.png</iconset> |
</property> |
48,6 → 48,9 |
<property name="checked"> |
<bool>false</bool> |
</property> |
<property name="toolButtonStyle"> |
<enum>Qt::ToolButtonTextBesideIcon</enum> |
</property> |
</widget> |
</item> |
<item row="0" column="1"> |
78,7 → 81,7 |
<item row="0" column="3"> |
<widget class="QLabel" name="label_4"> |
<property name="text"> |
<string>PW:</string> |
<string>Password:</string> |
</property> |
</widget> |
</item> |
199,7 → 202,7 |
</layout> |
</widget> |
<resources> |
<include location="../../QMK-Maps/QMK-Maps.qrc"/> |
<include location="../../QMK-Scope/QMK-Scope.qrc"/> |
</resources> |
<connections/> |
</ui> |
/QMK-Groundstation/trunk/Global/Widget_Connection.pri |
---|
1,7 → 1,6 |
DEPENDPATH += ../Global/Widget_Connection/ |
INCLUDEPATH += ../Global/Widget_Connection/ |
DEFINES += _TTY_POSIX_ |
include(../Global/Class_SerialPort.pri) |
SOURCES += wgt_Connection.cpp \ |