Subversion Repositories Projects

Rev

Rev 442 | Rev 462 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 442 Rev 449
Line 80... Line 80...
80
void Handler::stop_navictrl_debug() {
80
void Handler::stop_navictrl_debug() {
81
    set_navictrl_debug(0);
81
    set_navictrl_debug(0);
82
}
82
}
Line 83... Line 83...
83
 
83
 
84
/**
84
/**
85
 * send a waypoint to the NaviCtrl (the copter will fly to the position emidiately)
85
 * send a waypoint to the NaviCtrl (the MikroKopter will fly to the position emidiately)
86
 */
86
 */
87
void Handler::send_waypoint(Waypoint_t desired_pos) {
87
void Handler::send_waypoint(Waypoint_t desired_pos) {
88
    com->send_cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
88
    com->send_cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
Line 187... Line 187...
187
}
187
}
Line 188... Line 188...
188
 
188
 
189
/**
189
/**
190
 * receive data
190
 * receive data
191
 */
191
 */
192
void Handler::receive_data(sRxData RX) {
192
//Parser::decode64(data);
193
    //extract hardware ID from received Data
-
 
194
    int hardwareID = RX.input[1] - 'a';
193
void Handler::receive_data(int hardwareID, int cmd, char * data) {
195
    switch(hardwareID)
194
    switch(hardwareID)
196
    {
195
    {
197
        case ADDRESS_FC :
196
        case ADDRESS_FC :
198
            switch(RX.input[2])
197
            switch(cmd)
199
            {
198
            {
200
                // Motor-Mixer
199
                // Motor-Mixer
201
                case 'N' :
200
                case 'N' :
202
                    if (Parser::decode64(RX))
201
                    //if (Parser::decode64(RX))
203
                    {
202
                    //{
204
                        com->stop_resend();
-
 
-
 
203
                        com->stop_resend();
205
 
204
                        //decoded data
206
                        if (RX.decode[0] == VERSION_MIXER)
205
                        if (data[0] == VERSION_MIXER)
207
                        {
206
                        {
208
                            //f_MotorMixer->set_MotorConfig(RX);
207
                            //f_MotorMixer->set_MotorConfig(RX);
209
                        }
208
                        }
210
                    }
209
                    //}
211
                break;
210
                    break;
212
                // Motor-Mixer Schreib-Bestätigung
211
                // Motor-Mixer Schreib-Bestätigung
213
                case 'M' :
-
 
214
                    if (Parser::decode64(RX))
-
 
215
                    {
212
                case 'M' :
Line 216... Line 213...
216
                        com->stop_resend();
213
                    com->stop_resend();
217
 
214
 
218
                        if (RX.decode[0] == 1)
215
                    if (data[0] == 1)
219
                        {
216
                    {
220
                            //lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben."));
-
 
221
                        }
217
                        //lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben."));
Line 222... Line 218...
222
                    }
218
                    }
223
                break;
219
                    break;
224
 
-
 
225
                // Stick-Belegung der Fernsteuerung
-
 
226
                case 'P' : // DONE 0.71g
220
 
227
                    if (Parser::decode64(RX))
221
                // Stick-Belegung der Fernsteuerung
228
                    {
222
                case 'P' : // DONE 0.71g
229
                        /*f_Settings->pb_K1->setValue(Parser::dataToInt(RX.decode,  2,true));
223
                    /*f_Settings->pb_K1->setValue(Parser::dataToInt(RX.decode,  2,true));
230
                        f_Settings->pb_K2->setValue(Parser::dataToInt(RX.decode,  4,true));
224
                    f_Settings->pb_K2->setValue(Parser::dataToInt(RX.decode,  4,true));
231
                        f_Settings->pb_K3->setValue(Parser::dataToInt(RX.decode,  6,true));
225
                    f_Settings->pb_K3->setValue(Parser::dataToInt(RX.decode,  6,true));
232
                        f_Settings->pb_K4->setValue(Parser::dataToInt(RX.decode,  8,true));
226
                    f_Settings->pb_K4->setValue(Parser::dataToInt(RX.decode,  8,true));
233
                        f_Settings->pb_K5->setValue(Parser::dataToInt(RX.decode, 10 ,true));
227
                    f_Settings->pb_K5->setValue(Parser::dataToInt(RX.decode, 10 ,true));
234
                        f_Settings->pb_K6->setValue(Parser::dataToInt(RX.decode, 12,true));
-
 
235
                        f_Settings->pb_K7->setValue(Parser::dataToInt(RX.decode, 14,true));
228
                    f_Settings->pb_K6->setValue(Parser::dataToInt(RX.decode, 12,true));
236
                        f_Settings->pb_K8->setValue(Parser::dataToInt(RX.decode, 16,true));*/
229
                    f_Settings->pb_K7->setValue(Parser::dataToInt(RX.decode, 14,true));
237
                    }
230
                    f_Settings->pb_K8->setValue(Parser::dataToInt(RX.decode, 16,true));*/
238
                break;
-
 
239
                // Settings lesen
-
 
240
                case 'Q' : // DONE 0.71g
231
                    break;
Line 241... Line 232...
241
                    if (Parser::decode64(RX))
232
                // Settings lesen
242
                    {
233
                case 'Q' : // DONE 0.71g
243
                        com->stop_resend();
234
                    com->stop_resend();
244
 
235
 
245
                        if (RX.decode[1] == VERSION_SETTINGS)
236
                    if (data[1] == VERSION_SETTINGS)
246
                        {
237
                    {
247
                            int Settings_ID = RX.decode[0];
238
                        int Settings_ID = data[0];
248
                            /*for (int a = 0; a < MaxParameter; a++)
239
                        /*for (int a = 0; a < MaxParameter; a++)
Line 265... Line 256...
265
                                      QString(RX.decode[1]) +
256
                                    QString(RX.decode[1]) +
266
                                      QString("\nParameterbearbeitung nicht moeglich.");
257
                                    QString("\nParameterbearbeitung nicht moeglich.");
267
                            QMessageBox::warning(this, QA_NAME,
258
                        QMessageBox::warning(this, QA_NAME,
268
                                   name, QMessageBox::Ok);*/
259
                                name, QMessageBox::Ok);*/
269
                        }
260
                    }
270
                    }
-
 
271
                break;
261
                    break;
272
                // Settings written
262
                // Settings written
273
                case 'S' : // DONE 0.71g
263
                case 'S' : // DONE 0.71g
274
                    com->stop_resend();
264
                    com->stop_resend();
275
                    //TODO: QMessagebox("settings written successful") ?
265
                    //TODO: QMessagebox("settings written successful") ?
276
                break;
266
                    break;
277
            }
267
            }
Line 278... Line 268...
278
 
268
 
279
        case ADDRESS_NC :
269
        case ADDRESS_NC :
280
            switch(RX.input[2])
270
            switch(cmd)
281
            {
271
            {
282
                // Navigationsdaten
272
                // Navigationsdaten
283
                case 'O' : // NOT DONE 0.12h
-
 
284
                    if (Parser::decode64(RX))
-
 
285
                    {
273
                case 'O' : // NOT DONE 0.12h
286
                        //new_NaviData(RX);
-
 
287
                    }
274
                    //new_NaviData(RX);
288
                break;
275
                    break;
289
            }
276
            }
Line 290... Line 277...
290
//        case ADDRESS_MK3MAG :
277
//        case ADDRESS_MK3MAG :
291
 
278
 
292
        default :
279
        default :
293
            switch(RX.input[2])
280
            switch(cmd)
294
            {
281
            {
295
                // LCD-Anzeige
-
 
296
                case 'L' : // DONE 0.71g
-
 
297
                    if (Parser::decode64(RX))
282
                // LCD-Anzeige
Line 298... Line 283...
298
                    {
283
                case 'L' : // DONE 0.71g
299
                        com->stop_resend();
284
                    com->stop_resend();
Line 300... Line 285...
300
 
285
 
Line 301... Line 286...
301
                        /*int LCD[150];
286
                    /*int LCD[150];
302
                        memcpy(LCD,RX.decode, sizeof(RX.decode));
287
                    memcpy(LCD,RX.decode, sizeof(RX.decode));
303
 
288
 
304
                        f_LCD->show_Data(LCD);
-
 
305
 
289
                    f_LCD->show_Data(LCD);
306
                        LCD_Page     = RX.decode[0];
290
 
307
                        LCD_MAX_Page = RX.decode[1];
291
                    LCD_Page     = RX.decode[0];
308
                        */
-
 
309
                    }
-
 
310
                break;
292
                    LCD_MAX_Page = RX.decode[1];
Line 311... Line -...
311
                // Analoglabels
-
 
312
                case 'A' : // DONE 0.71g
293
                    */
313
                    if (Parser::decode64(RX))
294
                    break;
314
                    {
295
                // Analoglabels
315
                        com->stop_resend();
296
                case 'A' : // DONE 0.71g
316
 
297
                    com->stop_resend();
317
                        int Position = RX.decode[0];
298
 
318
                        if (Position != 31)
299
                    //check position
319
                        {
300
                    if (data[0] != 31) {
320
                            /*
301
                        /*
321
                            Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed();
302
                        Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed();
322
                            if (Settings->Analog1.Label[Position] == "")
303
                        if (Settings->Analog1.Label[Position] == "")
323
                            {
-
 
324
                                Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position);
-
 
325
                            }
304
                        {
326
                            Position ++;
305
                            Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position);
327
                            TX_Data[0] = Position;
306
                        }
328
                            o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);*/
307
                        Position ++;
329
                        }
308
                        TX_Data[0] = Position;
330
                        if (Position == 31)
309
                        o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);*/
331
                        {
310
                    } else {
332
                            /*
311
                        /*
333
                            for (int a = 0; a < MaxAnalog; a++)
312
                        for (int a = 0; a < MaxAnalog; a++)
334
                            {
313
                        {
335
                                lb_Analog[a]->setText(Settings->Analog1.Label[a]);
-
 
336
                            }
314
                            lb_Analog[a]->setText(Settings->Analog1.Label[a]);
337
                            Settings->Analog1.Version = QString(Mode.Version);
315
                        }
338
                            Settings->write_Settings_AnalogLabels(HardwareID);
316
                        Settings->Analog1.Version = QString(Mode.Version);
339
                            config_Plot();*/
-
 
340
                        }
-
 
341
                    }
317
                        Settings->write_Settings_AnalogLabels(HardwareID);
342
                break;
-
 
343
                // Debug-Daten
318
                        config_Plot();*/
344
                case 'D' : // DONE 0.71g
319
                    }
345
                    if (Parser::decode64(RX))
320
                    break;
346
                    {
-
 
347
                        for (int i = 0; i < MaxAnalog; i++)
321
                // Debug-Daten
348
                        {
322
                case 'D' : // DONE 0.71g
349
                            //AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2);
323
                    for (int i = 0; i < MaxAnalog; i++) {
350
                        }
-
 
351
                        //show_DebugData();
-
 
352
                    }
324
                        //AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2);
353
                break;
325
                    }
354
                // Version
326
                    //show_DebugData();
355
                case 'V' : // DONE 0.71h
327
                    break;
356
                    if (Parser::decode64(RX))
328
                // Version
Line 460... Line 432...
460
                        for (int a = 0; a < MaxAnalog; a++)
432
                    for (int a = 0; a < MaxAnalog; a++)
461
                        {
433
                    {
462
                            lb_Analog[a]->setText(Settings->Analog1.Label[a]);
434
                        lb_Analog[a]->setText(Settings->Analog1.Label[a]);
463
                        }
435
                    }
464
                        config_Plot();*/
436
                    config_Plot();*/
465
                    }
-
 
466
                break;
437
                    break;
467
            }
438
            }
468
    }
439
    }
469
}
440
}
470
441