Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
53 ingob 1
## Die Parameterstruktur entspricht der Struktur in der FlightCtrl:
2
 
3
 
4
struct
5
  {
6
    unsigned char Kanalbelegung[8];       // GAS[0], GIER[1], NICK[2], ROLL[3], POTI1, POTI2, POTI3, POTI4
7
    unsigned char GlobalConfig;           // Höhenregler aktiv, HR-Schalter, Heading Hold aktiv, Kompass aktiv, Kompass Ausrichtung fest, GPS aktiv,
8
    unsigned char Hoehe_MinGas;           // Wert : 0-100
9
    unsigned char Luftdruck_D;            // Wert : 0-250
10
    unsigned char MaxHoehe;               // Wert : 0-32
11
    unsigned char Hoehe_P;                // Wert : 0-32
12
    unsigned char Hoehe_Verstaerkung;     // Wert : 0-50
13
    unsigned char Hoehe_ACC_Wirkung;      // Wert : 0-250
14
    unsigned char Stick_P;                // Wert : 1-6
15
    unsigned char Stick_D;                // Wert : 0-64
16
    unsigned char Gier_P;                 // Wert : 1-20
17
    unsigned char Gas_Min;                // Wert : 0-32
18
    unsigned char Gas_Max;                // Wert : 33-250
19
    unsigned char GyroAccFaktor;          // Wert : 1-64
20
    unsigned char KompassWirkung;         // Wert : 0-32
21
    unsigned char Gyro_P;                 // Wert : 10-250
22
    unsigned char Gyro_I;                 // Wert : 0-250
23
    unsigned char UnterspannungsWarnung;  // Wert : 0-250
24
    unsigned char NotGas;                 // Wert : 0-250     // Gaswert bei Empängsverlust
25
    unsigned char NotGasZeit;             // Wert : 0-250     // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen
26
    unsigned char UfoAusrichtung;         // X oder + Formation
27
    unsigned char I_Faktor;               // Wert : 0-250
28
    unsigned char UserParam1;             // Wert : 0-250
29
    unsigned char UserParam2;             // Wert : 0-250
30
    unsigned char UserParam3;             // Wert : 0-250   Default: LED
31
    unsigned char UserParam4;             // Wert : 0-250   Default: LED
32
    unsigned char ServoNickControl;       // Wert : 0-250
33
    unsigned char ServoNickComp;          // Wert : 0-250
34
    unsigned char ServoNickMin;           // Wert : 0-250
35
    unsigned char ServoNickMax;           // Wert : 0-250
36
    unsigned char ServoNickRefresh;       //
37
    unsigned char ServoNickCompInvert;    // Wert : 0-250   0 oder 1  // WICHTIG!!! am Ende lassen
38
    unsigned char Reserved[7];
39
    char Name[12];
40
  } Param;
41
 
42
 
43
##--------------------------------------------
44
## Per Windows wird diese wie folgt geladen:
45
     TIniFile *iniFile = new TIniFile(OD->FileName);
46
 
47
     strcpy(MK_Parameter[index].Name, (IniReadString(iniFile,"Setup", "Name","<unbenannt>")).c_str() );
48
 
49
     MK_Parameter[index].Kanalbelegung[0] = IniReadInteger(iniFile,"Channels", "Gas", 3);
50
     MK_Parameter[index].Kanalbelegung[1] = IniReadInteger(iniFile,"Channels", "Gier", 4);
51
     MK_Parameter[index].Kanalbelegung[2] = IniReadInteger(iniFile,"Channels", "Nick", 1);
52
     MK_Parameter[index].Kanalbelegung[3] = IniReadInteger(iniFile,"Channels", "Roll", 2);
53
     MK_Parameter[index].Kanalbelegung[4] = IniReadInteger(iniFile,"Channels", "Poti_1", 5);
54
     MK_Parameter[index].Kanalbelegung[5] = IniReadInteger(iniFile,"Channels", "Poti_2", 6);
55
     MK_Parameter[index].Kanalbelegung[6] = IniReadInteger(iniFile,"Channels", "Poti_3", 7);
56
     MK_Parameter[index].Kanalbelegung[7] = IniReadInteger(iniFile,"Channels", "Poti_3", 8);
57
 
58
     MK_Parameter[index].GlobalConfig = IniReadInteger(iniFile,"Setup", "GlobalConfig", 0);
59
 
60
     MK_Parameter[index].Stick_P = IniReadInteger(iniFile,"Stick", "Nick_Roll-P", 4);
61
     MK_Parameter[index].Stick_D = IniReadInteger(iniFile,"Stick", "Nick_Roll-D", 8);
62
     MK_Parameter[index].Gier_P = IniReadInteger(iniFile,"Stick", "Gier-P", 16);
63
 
64
     MK_Parameter[index].MaxHoehe = IniReadInteger(iniFile,"Altitude", "Setpoint", 251);
65
     MK_Parameter[index].Hoehe_MinGas = IniReadInteger(iniFile,"Altitude", "MinGas", 30);
66
     MK_Parameter[index].Hoehe_P = IniReadInteger(iniFile,"Altitude", "P", 10);
67
     MK_Parameter[index].Luftdruck_D = IniReadInteger(iniFile,"Altitude", "Barometric-D", 90);
68
     MK_Parameter[index].Hoehe_ACC_Wirkung = IniReadInteger(iniFile,"Altitude", "Z-ACC-Effect",15);
69
     MK_Parameter[index].Hoehe_Verstaerkung = IniReadInteger(iniFile,"Altitude", "Gain", 2);
70
 
71
     MK_Parameter[index].Gyro_P = IniReadInteger(iniFile,"Gyro", "P", 120);
72
     MK_Parameter[index].Gyro_I = IniReadInteger(iniFile,"Gyro", "I", 150);
73
     MK_Parameter[index].GyroAccFaktor = IniReadInteger(iniFile,"Gyro", "ACC_Gyro-Factor", 26);
74
 
75
     MK_Parameter[index].I_Faktor = IniReadInteger(iniFile,"Gyro", "Main-I", 5);
76
 
77
     MK_Parameter[index].Gas_Min = IniReadInteger(iniFile,"Others", "MinGas",15);
78
     MK_Parameter[index].Gas_Max = IniReadInteger(iniFile,"Others", "MaxGas",250);
79
     MK_Parameter[index].KompassWirkung = IniReadInteger(iniFile,"Others", "Compass-Effect",128);
80
     MK_Parameter[index].UnterspannungsWarnung = IniReadInteger(iniFile,"Others", "UnderVoltage",90);
81
 
82
     MK_Parameter[index].NotGas = IniReadInteger(iniFile,"Others", "NotGas",35);
83
     MK_Parameter[index].NotGasZeit = IniReadInteger(iniFile,"Others", "NotGasTime",20);
84
 
85
     MK_Parameter[index].UserParam1 = IniReadInteger(iniFile,"User", "Parameter_1",0);
86
     MK_Parameter[index].UserParam2 = IniReadInteger(iniFile,"User", "Parameter_2",0);
87
     MK_Parameter[index].UserParam3 = IniReadInteger(iniFile,"User", "Parameter_3",0);
88
     MK_Parameter[index].UserParam4 = IniReadInteger(iniFile,"User", "Parameter_4",0);
89
 
90
     MK_Parameter[index].ServoNickControl = IniReadInteger(iniFile,"Camera", "ServoNickControl",252);
91
     MK_Parameter[index].ServoNickComp = IniReadInteger(iniFile,"Camera", "ServoNickCompensation",100);
92
     MK_Parameter[index].ServoNickCompInvert = IniReadBool(iniFile,"Camera", "ServoNickInvert",false);
93
     MK_Parameter[index].ServoNickMin = IniReadInteger(iniFile,"Camera", "ServoNickMin",0);
94
     MK_Parameter[index].ServoNickMax = IniReadInteger(iniFile,"Camera", "ServoNickMax",250);
95
     MK_Parameter[index].ServoNickRefresh = IniReadInteger(iniFile,"Camera", "ServoNickRefreshRate",50);
96
 
97
 
98
 
99
##--------------------------------------------
100
 Senden der Daten: (diese Funktionen gibt es entsprechend auch in den FlightCtrl-Quellen
101
 
102
//---------------------------------------------------------------------------
103
void AddCRC(unsigned int wieviele)
104
{
105
 unsigned int tmpCRC = 0,i;
106
 for(i = 0; i < wieviele;i++)
107
  {
108
   tmpCRC += TxBuffer[i];
109
  }
110
   tmpCRC %= 4096;
111
   TxBuffer[i++] = '=' + tmpCRC / 64;
112
   TxBuffer[i++] = '=' + tmpCRC % 64;
113
   TxBuffer[i++] = '\r';
114
 
115
   SEND_BYTES(TxBuffer, wieviele+3);
116
}
117
 
118
// --------------------------------------------------------------------------
119
void SendOutData(unsigned char cmd,unsigned char modul, unsigned char *buffer, int len)
120
{
121
 unsigned int pt = 0,i;
122
 
123
 TxBuffer[pt++] = '#';           // Startzeichen
124
 TxBuffer[pt++] = modul+'a'; // Adresse (a=0; b=1,...)
125
 TxBuffer[pt++] = cmd;		  // Commando
126
 if(len)
127
 for(i = 0;i < len; i+=3)
128
  {												      // Ausgangs-Daten
129
    TxBuffer[pt++] = '=' + (buffer[i] >> 2);
130
    TxBuffer[pt++] = '=' + (((buffer[i] & 0x03) << 4) | ((buffer[i+1] & 0xf0) >> 4));
131
    TxBuffer[pt++] = '=' + ((unsigned char) ((buffer[i+1] & 0x0f) << 2) | ((buffer[i+2] & 0xc0) >> 6));
132
    TxBuffer[pt++] = '=' + ((unsigned char) buffer[i+2] & 0x3f);
133
  }
134
 AddCRC(pt);
135
}
136
 
137
#########################################
138
 
139
--------------------------------------------
140
 übertragen zum MikroKopter mit dem Befehl
141
 'l'+Paramterset  (siehe auch Quellen FlightCtrl):
142
 also m = 1, n = 2, ...
143
 
144
 Beispiel:
145
 
146
 SendOutData('l'+ParameterSet, 1,  MK_Parameter, sizeof(MK_Parameter));
147