Subversion Repositories Projects

Rev

Rev 2212 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2136 - 1
/*
2
 * FollowMe.c
3
 *
4
 *  Created on: 18.05.2012
5
 *      Author: cebra
6
 */
7
/*****************************************************************************
8
 *   Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net *
9
 *                                                                           *
10
 *   This program is free software; you can redistribute it and/or modify    *
11
 *   it under the terms of the GNU General Public License as published by    *
12
 *   the Free Software Foundation; either version 2 of the License.          *
13
 *                                                                           *
14
 *   This program is distributed in the hope that it will be useful,         *
15
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
16
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
17
 *   GNU General Public License for more details.                            *
18
 *                                                                           *
19
 *   You should have received a copy of the GNU General Public License       *
20
 *   along with this program; if not, write to the                           *
21
 *   Free Software Foundation, Inc.,                                         *
22
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
23
 *                                                                           *
24
 *                                                                           *
25
 *   Credits to:                                                             *
26
 *   Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN  *
27
 *                          http://www.mikrokopter.de                        *
28
 *   Gregor "killagreg" Stobrawa for his version of the MK code              *
29
 *   Thomas Kaiser "thkais" for the original project. See                    *
30
 *                          http://www.ft-fanpage.de/mikrokopter/            *
31
 *                          http://forum.mikrokopter.de/topic-4061-1.html    *
32
 *   Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
33
 *                          http://www.mylifesucks.de/oss/c-osd/             *
34
 *   Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
35
 *****************************************************************************/
36
//############################################################################
37
//# HISTORY  followme.c
38
//#
2212 - 39
//#
2214 - 40
//# 14.10.2015 Starter
41
//# - Added Offset to FollowMe
42
//# - Stuff in FollowMeStep2 only for debug!
2212 - 43
//#
44
//# 22.09.2015 Starter
45
//# - FollowMeStep2 erweitert mit Kreisberechnung und test auf PKT
46
//# - PKT-Pos von lat lon auf latitude und longitude umbenannt
47
//#
2200 - 48
//# 20.09.2015 Starter
49
//# FollowMeStep2 erweitert auf aktuelle GPS-Daten und followme_calculate_offset(...)
50
//#
2136 - 51
//# 03.08.2015 Cebra
52
//# - add: void Debug_GPS (void) hinzugefügt zur Test der GPS Berechnung FollowMe
53
//#
54
//# 20.07.2015 CB
55
//# - chg: FollowMe Datensatz an NC.211 angepasst
56
//#
57
//# 27.06.2014 OG
58
//# - chg: Anzeige von Satfix und Satanzahl auf MINVERSX, MNORMALX
59
//#
60
//# 26.06.2014 OG
61
//# - chg: angepasst auf neue NMEA-Datenstruktur (gps_nmea.h)
62
//#
63
//# 24.06.2014 OG
64
//# - chg: FollowMe() angepasst auf geaendertes GPSMouse_ShowData()
65
//#
66
//# 22.06.2014 OG
67
//# - chg: FollowMe() umgestellt auf GPSMouse_ShowData() (in gps/gpsmouse.c)
68
//# - del: Variable CheckGPS
69
//#
70
//# 21.06.2014 OG
71
//# - chg: verschiedene Layoutaenderungen am Anzeigescreen und Anzeige der
72
//#        Entfernung zwischen Kopter und Target
73
//# - chg: MK-Timeoutout Erkennung verbessert/angepasst
74
//#
75
//# 19.06.2014 OG
76
//# - erster Prototyp der Follow Me zum Kopter sendet
77
//# - etliche Aenderungen im Codeaufbau
78
//#
79
//# 01.06.2014 OG
80
//# - chg: FollowMe() - verschiedene Anzeigefunktionen auskommentiert und
81
//#        als DEPRICATED Klassifiziert wegen Cleanup der alten OSD Screens
82
//# - chg: FollowMe() - Check bzgl. NC-Hardware entfernt da das bereits durch das
83
//#        Hauptmenue erledigt wird
84
//#
85
//# 13.05.2014 OG
86
//# - chg: FollowMe() - Variable 'flag' auskommentiert
87
//#        wegen Warning: variable set but not used
88
//# - chg: FollowMe() - Variable 'old_FCFlags' auskommentiert
89
//#        wegen Warning: variable set but not used
90
//# - chg: FollowMe() - den Bereich in dem FC-Settings geladen werdeb
91
//#        auskommentiert weil man das a) vorallem nicht benoetigt
92
//#        und b) die load_setting() so nicht mehr existiert
93
//#        (der Codebereich kann meines erachtens geloescht werden)
94
//# - del: verschiedene Verweise auf 'mk_param_struct' entfernt, weil es
95
//#        das a) nicht mehr gibt und b) hier gar nicht benoetigt wird
96
//# - chg: FollowMe() - OSD_Timeout() entfernt (weil es das nicht mehr gibt)
97
//#        und erstmal durch ein PKT_Message_P() ersetzt
98
//#        * ACHTUNG: UNGETESTET! * (bei Bedarf anpassen, followme hat niedrige Prio)
99
//# - add: #include "../pkt/pkt.h"
100
//#
101
//# 05.05.2013 Cebra
102
//# - chg: #ifdef USE_FOLLOWME
103
//#
104
//############################################################################
105
 
106
#include "../cpu.h"
107
#include <avr/io.h>
108
#include <inttypes.h>
109
#include <stdlib.h>
110
#include <avr/pgmspace.h>
111
#include <util/delay.h>
112
 
113
#include <string.h>
114
#include <stdarg.h>
115
#include <stdio.h>
116
 
117
#include "../main.h"
118
 
119
#ifdef USE_FOLLOWME
120
 
121
#include "../followme/followme.h"
122
#include "../osd/osd.h"
123
#include "../lcd/lcd.h"
124
#include "../timer/timer.h"
125
#include "../uart/usart.h"
126
#include "../eeprom/eeprom.h"
127
#include "../messages.h"
128
#include "../bluetooth/bluetooth.h"
129
#include "../setup/setup.h"
130
#include "../uart/uart1.h"
131
#include "../mk-data-structs.h"
132
#include "../pkt/pkt.h"
133
#include "../gps/gps.h"
134
//#include "../gps/gps_nmea.h"
135
#include "../avr-nmea-gps-library/nmea.h"
136
#include "../gps/gpsmouse.h"
137
 
138
 
139
//#######################################################################################################################
140
 
141
 
142
//--------------------
143
// Timings
144
//--------------------
145
//#define MK_TIMEOUT          300 // MK-Verbindungsfehler wenn fuer n Zeit keine gueltigen Daten hereinkommen (3 sec)
146
#define MK_TIMEOUT            400 // MK-Verbindungsfehler wenn fuer n Zeit keine gueltigen Daten hereinkommen (4 sec)
147
 
148
 
149
 
150
//--------------------
151
#define COSD_WASFLYING 4
152
 
153
// global definitions and global vars
154
NaviData_t *naviData;
155
unsigned char Element;
156
uint16_t heading_home;
157
 
158
// Hier Höhenanzeigefehler Korrigieren
159
#define AltimeterAdjust 1.5
160
 
2212 - 161
positionOffset followMeOffset;
2136 - 162
 
163
 
2212 - 164
 
2136 - 165
// Flags
166
//uint8_t COSD_FLAGS2 = 0;
167
//
168
//GPS_Pos_t last5pos[7];
169
uint8_t FM_error = 0;
170
 
171
 
172
//---------------------
173
// Waypoint Types
174
// TODO OG: verschieben nach: mk-data-structs.h
175
//---------------------
176
#define POINT_TYPE_INVALID  255
177
#define POINT_TYPE_WP       0
178
#define POINT_TYPE_POI      1
179
 
180
 
181
//---------------------
182
// Status
183
// GPS_Pos_t
184
// aus MK source
185
//
186
// TODO OG: verschieben nach: mk-data-structs.h
187
//---------------------
188
#define INVALID         0x00
189
#define NEWDATA         0x01
190
#define PROCESSED       0x02
191
 
192
 
193
 
194
//--------------------------------------------------------------
195
//--------------------------------------------------------------
196
void FollowMe( void )
197
{
198
    //uint8_t status;
199
    GPS_Pos_t currpos;
200
    uint8_t   tmp_dat;
201
    uint8_t   redraw;
202
    uint8_t   drawmode;
203
    uint32_t  NMEA_GPGGA_counter_old;                                   // Merker: zaehlt empfangene GPGGA-Pakete
204
    uint32_t  send_followme_counter;
205
 
206
    int8_t    ok;
207
    int8_t    xoffs;
208
    int8_t    yoffs;
209
    Point_t   FollowMe;
210
    uint8_t   mktimeout = false;
211
 
2214 - 212
        nmeaPOS NMEApos;
213
        nmeaPOS NMEAtarget;
2136 - 214
 
215
    GPS_PosDev_t targetdev;
216
 
217
 
218
    //---------------------
219
    // 1. Daten GPS-Maus
220
    //---------------------
221
    ok = GPSMouse_ShowData( GPSMOUSE_SHOW_WAITSATFIX, 500 );            // 500 = 5 Sekunden Verzoegerung nach Satfix
222
    if( ok <= 0 )
223
    {
224
        return;                                                         // Fehler bzgl. BT GPS-Maus -> exit
225
    }
226
 
227
 
228
    //---------------------
229
    // 2. Follow Me
230
    //---------------------
231
    set_beep( 25, 0xffff, BeepNormal );                                 // kurzer Bestaetigungs-Beep
232
 
233
    lcd_cls ();
234
 
235
    SwitchToNC();
236
 
237
    mode = 'O';
238
 
239
    // disable debug...
240
    //      RS232_request_mk_data (0, 'd', 0);
241
    tmp_dat = 0;
242
    SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1);
243
 
244
    // request OSD Data from NC every 100ms
245
    //      RS232_request_mk_data (1, 'o', 100);
246
    tmp_dat = 10;
247
    SendOutData ('o', ADDRESS_NC, 1, &tmp_dat, 1);
248
 
249
    //OSD_active = true;              // benötigt für Navidata Ausgabe an SV2
250
 
251
    //-------------------------
252
    // Init: Timer & Flags
253
    //-------------------------
254
    timer_mk_timeout      = MK_TIMEOUT;
255
 
256
    abo_timer = ABO_TIMEOUT;
257
 
258
 
259
    MKLiPoCells_Init();
260
 
261
    redraw = true;
262
 
263
    NMEA.Counter           = 0;
264
    NMEA_GPGGA_counter_old = 0;
265
    send_followme_counter  = 0;
266
 
267
 
268
    while( (receiveNMEA) )
269
    {
270
        //-----------------------------------------
271
        // Screen redraw
272
        //-----------------------------------------
273
        if( redraw )
274
        {
275
            lcd_cls();
276
 
277
            lcdx_printf_center_P( 0, MNORMAL, 1,0, PSTR("FollowMe") );  // Titel: oben, mitte
278
 
279
            lcd_line(  (6*6-3),  0,  (6*6-3), 11, 1);                   // Linie Vertikal links
280
            lcd_line( (15*6+5),  0, (15*6+5), 11, 1);                   // Linie Vertikal rechts
281
            lcd_line(        0, 12,      127, 12, 1);                   // Linie Horizontal
282
 
283
          //lcd_line(        0, 39,      127, 39, 1);                   // Linie Horizontal Mitte
284
            lcd_line(        66, 39,      127, 39, 1);                  // Linie Horizontal Mitte
285
 
286
            lcd_rect_round( 0, 33, 66, 12, 1, R1);                      // Rahmen fuer "Di" (Distance)
287
 
288
            lcdx_printf_at_P( 3, 2, MNORMAL, 3,-1, PSTR("Al:")  );      // Label: "Al:"
289
 
290
            draw_icon_mk( 1, 18);
291
            draw_icon_target_round( 1, 50);
292
 
293
            redraw = false;
294
        }
295
 
296
 
297
 
298
        //-----------------------------------------
299
        // neue MK Daten vorhanden
300
        //-----------------------------------------
301
        if( rxd_buffer_locked )     // neue MK Daten
302
        {
303
            Decode64 ();
304
            naviData = (NaviData_t *) pRxData;
305
 
306
            if( mktimeout ) redraw = true;
307
            mktimeout = false;
308
 
309
            FM_error = 0;   // noch benoetigt?
310
 
311
            currpos.Latitude  = naviData->CurrentPosition.Latitude;
312
            currpos.Longitude = naviData->CurrentPosition.Longitude;
313
 
314
            //----------------------------------
315
            // speichere letzte GPS-Positionen
316
            //----------------------------------
317
            Config.LastLatitude  = naviData->CurrentPosition.Latitude;    // speichere letzte Position in Config
318
            Config.LastLongitude = naviData->CurrentPosition.Longitude;   // speichere letzte Position in Config
319
 
320
 
321
            //----------------------------------
322
            // LiPo Cell Check
323
            //----------------------------------
324
            MKLiPoCells_Check();                    // ggf. Zellenzahl ermitteln
325
 
326
 
327
            //#################
328
            //# MK
329
            //#################
330
 
331
            //-----------------
332
            // Oben: MK-Batt Level (Volt)
333
            //-----------------
334
            OSD_Element_BattLevel2( 0, 0, 0,0 );
335
 
336
            //-----------------
337
            // Oben: Batt Level Bar
338
            //-----------------
339
            OSD_Element_Battery_Bar( 0, 9, 30, 1, ORIENTATION_H);
340
 
341
            //-----------------
342
            // Oben: MK-Flugzeit
343
            //-----------------
344
            writex_time(16, 0, naviData->FlyingTime, MNORMAL, 2,0);
345
 
346
            //-----------------
347
            // Hoehe
348
            //-----------------
349
            xoffs = 3;
350
            yoffs = -1;
351
            writex_altimeter( 7, 2, naviData->Altimeter, MNORMAL, xoffs,yoffs );
352
 
353
            //-----------------
354
            // MK: Sat Anzahl
355
            //-----------------
356
            yoffs = -27;
2212 - 357
            if( naviData->SatsInUse > 5 )
358
                drawmode = MNORMALX;
359
            else
360
                drawmode = MINVERSX;
2136 - 361
            writex_ndigit_number_u( 17, 5, naviData->SatsInUse, 2, 0,drawmode,  3,2+yoffs);
362
            draw_icon_satmini( 116+3, 42+yoffs);
363
 
364
 
365
            //-----------------
366
            // MK: GPS
367
            //-----------------
368
            writex_gpspos( 3, 4, currpos.Latitude , MNORMAL,-3,-8 );                 // Line 4 L: Latitude
369
            writex_gpspos(12, 4, currpos.Longitude, MNORMAL, 1,-8 );                 // Line 4 R: Longitude
370
//             lcdx_printf_at_P( 1, 4, MNORMAL, -3,-8 , PSTR("%d"), NMEA.Latitude);
371
//             lcdx_printf_at_P( 10, 4, MNORMAL, -1,-8 , PSTR("%d"), NMEA.Longitude);
372
 
373
 
374
 
375
            //#################
376
            //# DISTANCE TO TARGET
377
            //#################
378
 
379
            //-----------------
380
            // Target: Distance to Target
381
            //-----------------
382
            xoffs = 7;
383
            yoffs = 4;
384
            //GPS_PosDev_t gps_Deviation( GPS_Pos_t pos1, GPS_Pos_t pos2 )
385
            targetdev = gps_Deviation( FollowMe.Position, naviData->CurrentPosition);
386
            lcdx_printf_at_P( 0, 4, MNORMAL, xoffs,yoffs , PSTR("Di: %3d m"), (targetdev.Distance / 10) );
387
 
388
 
389
            //#################
390
            //# TARGET (GPS Maus)
391
            //#################
392
 
393
            yoffs = 8;
394
 
395
            //-----------------
396
            // Send Counter
397
            //-----------------
398
          //lcdx_printf_at_P(4, 5, MNORMAL, 0,5, PSTR("S: %ld"), send_followme_counter );               // Anzahl gesendeter Target-Positionen
399
            lcdx_printf_at_P( 4, 5, MNORMAL, -3,yoffs, PSTR("Tx:%5ld"), send_followme_counter );        // Anzahl gesendeter Target-Positionen
400
 
401
 
402
            //-----------------
403
            // Target: Fix
404
            //-----------------
405
            if( NMEA.SatFix == 1 || NMEA.SatFix == 2 )
406
                drawmode = MNORMALX;
407
            else
408
                drawmode = MINVERSX;
409
 
410
            lcdx_printf_at_P( 14, 5, drawmode, 1,yoffs, PSTR("F:%1d"), NMEA.SatFix );               // GPS-Maus: Satfix
411
 
412
 
413
            //-----------------
414
            // Target: Sat Anzahl
415
            //-----------------
416
            if( NMEA.SatsInUse > 5 )
417
                drawmode = MNORMALX;
418
            else
419
                drawmode = MINVERSX;
420
 
421
            writex_ndigit_number_u( 17, 5, NMEA.SatsInUse, 2, 0,drawmode,  4,yoffs);
422
            draw_icon_satmini( 116+4, 40+yoffs);
423
 
424
 
425
            //-----------------
426
            // Target: Lat / Long
427
            //-----------------
428
            writex_gpspos( 3, 7, NMEA.Latitude , MNORMAL,-3,1 );                 // GPS-Maus: Latitude
429
            writex_gpspos(12, 7, NMEA.Longitude, MNORMAL, 1,1 );                 // GPS-Maus: Longitude
430
 
431
            rxd_buffer_locked = FALSE;
432
 
433
            timer_mk_timeout = MK_TIMEOUT;
434
        }
435
 
436
        //-----------------------------------------
437
//        if( !NMEA_receiveBT() )
438
//        {
439
//            receiveNMEA = false;
440
//        }
441
//        else
442
//        {
443
//            NMEA_GetNewData();
444
//        }
445
 
446
 
447
// Sourcecode aus NaviCtrl/V2.10e/uart1.c
448
//  FOLLOW_ME
449
//        else if(CheckDelay(UART1_FollowMe_Timer) && (UART1_tx_buffer.Locked == FALSE))
450
//        {
451
//                if((GPSData.Status != INVALID) && (GPSData.SatFix == SATFIX_3D) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.NumOfSats >= 4))
452
//                {
453
//                        TransmitAlsoToFC = 1;
454
//                        // update FollowMe content
455
//                        FollowMe.Position.Longitude     = GPSData.Position.Longitude;
456
//                        FollowMe.Position.Latitude      = GPSData.Position.Latitude;
457
//                        FollowMe.Position.Status = NEWDATA;
458
//                        FollowMe.Position.Altitude = 1;
459
//                        // 0  -> no Orientation
460
//                        // 1-360 -> CompassCourse Setpoint
461
//                        // -1 -> points to  WP1 -> itself
462
//                FollowMe.Heading = -1;
463
//                        FollowMe.ToleranceRadius = 1;
464
//                        FollowMe.HoldTime = 60;
465
//                        FollowMe.Event_Flag = 1;
466
//                        FollowMe.Index = 1; // 0 = Delete List, 1 place at first entry in the list
467
//                        FollowMe.Type = POINT_TYPE_WP;
468
//                        FollowMe.WP_EventChannelValue = 100;  // set servo value
469
//                        FollowMe.AltitudeRate = 0;                        // do not change height
470
//                        FollowMe.Speed = 0;                             // rate to change the Position (0 = max)
471
//                        FollowMe.CamAngle = 255;                // Camera servo angle in degree (255 -> POI-Automatic)
472
//                        FollowMe.Name[0] = 'F';             // Name of that point (ASCII)
473
//                        FollowMe.Name[1] = 'O';             // Name of that point (ASCII)
474
//                        FollowMe.Name[2] = 'L';             // Name of that point (ASCII)
475
//                        FollowMe.Name[3] = 'L';             // Name of that point (ASCII)
476
//                        FollowMe.reserve[0] = 0;                // reserve
477
//                        FollowMe.reserve[1] = 0;                // reserve
478
//                        MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 's', NC_ADDRESS, 1, (u8 *)&FollowMe, sizeof(FollowMe));
479
//                }
480
//                UART1_FollowMe_Timer = SetDelay(FOLLOW_ME_INTERVAL); // set new update time
481
//        }
482
//
483
 
484
 
485
 
486
 
487
        //-----------------------------------------
488
        // neue NMEA Daten?
489
        //-----------------------------------------
490
        if(NMEA_isdataready() && receiveNMEA)
491
        {
492
            if( NMEA.Counter > NMEA_GPGGA_counter_old )
493
            {
494
                if( (NMEA.SatsInUse > 5) && (NMEA.SatFix == 1 || NMEA.SatFix == 2) )
495
                {
496
                    //Config.FM_Refresh
497
 
2212 - 498
                        // FollowMeStep2
2214 - 499
                        followMeOffset.latitude = Config.FM_Offest_Latitude;
500
                        followMeOffset.longitude = Config.FM_Offset_Longitude;
2212 - 501
 
2214 - 502
                        NMEApos.latitude = NMEA.Latitude;
503
                        NMEApos.longitude = NMEA.Longitude;
504
 
505
                        followme_add_offset(&NMEApos, &NMEAtarget, &followMeOffset);
506
 
2136 - 507
                    FollowMe.Position.Status    = NEWDATA;
2214 - 508
                    FollowMe.Position.Longitude = NMEAtarget.longitude;
509
                    FollowMe.Position.Latitude  = NMEAtarget.latitude;
2136 - 510
                    FollowMe.Position.Altitude  = 1;                    // 20.7.2015 CB
511
    //                FollowMe.Position.Altitude  = NMEA.Altitude;        // ist das wirklich ok? NEIN C.B.
512
 
513
                    FollowMe.Heading = -1;                              // invalid heading
514
                    FollowMe.ToleranceRadius = Config.FM_Radius;        // 5 meter default
515
                    FollowMe.HoldTime = 60;                             // ????? go home after 60s without any update ??????
516
    //                FollowMe.Event_Flag = 0;                            // no event
517
                    FollowMe.Event_Flag = 1;                            //  20.7.2015 CB
518
                    FollowMe.Index = 1;                                 // 2st wp, 0 = Delete List, 1 place at first entry in the list
519
                    FollowMe.Type = POINT_TYPE_WP;                      // Typ des Wegpunktes
520
                    FollowMe.Name[0] = 'F';                             // Name des Wegpunktes (ASCII)
521
                    FollowMe.Name[1] = 'O';
522
                    FollowMe.Name[2] = 'L';
523
                    FollowMe.Name[3] = 'L';
524
    //                FollowMe.WP_EventChannelValue = 0;                  // Will be transferred to the FC and can be used as Poti value there
525
                    FollowMe.WP_EventChannelValue = 100;                 // set servo value 20.7.2015
526
                    FollowMe.AltitudeRate = 0;                          // rate to change the Aetpoint
527
                    FollowMe.Speed = Config.FM_Speed;                   // rate to change the Position
528
                    FollowMe.CamAngle = 255;                            // Camera servo angle in degree (255 -> POI-Automatic)
529
                    FollowMe.reserve[0] = 0;                            // reserve
530
                    FollowMe.reserve[1] = 0;                            // reserve
531
 
532
                    SendOutData( 's', ADDRESS_NC, 1, &FollowMe, sizeof(FollowMe) );       //'s' = target Position  'w' = Waypoint
533
                    send_followme_counter++;
534
 
535
                    //void SendOutData(uint8_t cmd, uint8_t addr, uint8_t numofbuffers, ...) // uint8_t *pdata, uint8_t len, ...
536
                    // SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1);
537
                    //SendOutData( 's', NC_ADDRESS, 1, (uint8_t *)&FollowMe, sizeof(FollowMe));   //'s' = target Position  'w' = Waypoint
538
 
539
                }
540
 
541
                NMEA_GPGGA_counter_old = NMEA.Counter;
542
            }
543
        }
544
 
545
        //-----------------------------------------
546
        // TASTEN
547
        //-----------------------------------------
548
        if( get_key_press(1 << KEY_ESC) )
549
        {
550
            break;
551
        }
552
 
553
        if( get_key_press(1 << KEY_ENTER) )
554
        {
555
            break;
556
        }
557
 
558
        //-----------------------------------------
559
        //-----------------------------------------
560
        if( !abo_timer )
561
        {
562
            // renew abo every 3 sec
563
            // request OSD Data from NC every 100ms
564
            //      RS232_request_mk_data (1, 'o', 100);
565
            tmp_dat = 10;
566
            SendOutData ( 'o', ADDRESS_NC, 1, &tmp_dat, 1);
567
 
568
            abo_timer = ABO_TIMEOUT;
569
        }
570
 
571
        //--------------------------
572
        // Daten Timeout vom MK?
573
        //--------------------------
574
        if( timer_mk_timeout == 0 )
575
        {
576
            if( !mktimeout ) OSD_MK_ShowTimeout();              // nur anzeigen wenn noch nicht im mktimeout-Modus
577
            set_beep ( 200, 0x0080, BeepNormal);                // Beep
578
            mktimeout        = true;
579
            timer_mk_timeout = MK_TIMEOUT;
580
            //OSDScreenRefresh = OSD_SCREEN_REDRAW;
581
            // OSD_MK_Connect( MK_CONNECT );
582
        }
583
 
584
    } // end: while( (receiveNMEA) );
585
 
586
 
587
 
588
    //---------------------
589
    // BEENDEN
590
    //---------------------
591
    OSD_active = false;
592
 
593
 
594
    //---------------------
595
    // GPS beenden
596
    //---------------------
597
    GPSMouse_Disconnect();
598
}
599
 
600
 
601
 
602
 
603
 
2200 - 604
//
605
#ifdef USE_FOLLOWME_STEP2
2136 - 606
void Debug_GPS (void)
607
{
2212 - 608
        uint8_t redraw = true;
609
        nmeaPOS NMEApos;
610
        nmeaPOS NMEATarget;
2195 - 611
 
2199 - 612
        set_beep( 25, 0xffff, BeepNormal );                                 // kurzer Bestaetigungs-Beep
2136 - 613
 
614
 
2212 - 615
#ifdef ONLINE
616
    int retcode = GPSMouse_Connect();                                   // Abfrage der GPS-Daten zum testen -> Quick an Dirty ;-)
2200 - 617
    if( retcode <= 0 )
618
    {
619
        return;
620
    }
2212 - 621
#endif
2195 - 622
 
2212 - 623
#ifdef DEBUG
624
//      NMEApos.lat = 520000000;
625
//      NMEApos.lon = 0;
626
//      Config.FM_Azimuth = 90;
627
//      Config.FM_Distance = 10000;
628
#endif
2200 - 629
 
2199 - 630
        while( true )
631
        {
2212 - 632
                NMEApos.latitude = NMEA.Latitude;
633
                NMEApos.longitude = NMEA.Longitude;
2136 - 634
 
2199 - 635
                if( redraw )
636
                {
637
                        lcd_cls();
2136 - 638
 
2212 - 639
                        lcdx_printf_center_P( 0, MNORMAL, 1,0, PSTR("FollowMeStep2") );
2200 - 640
                        lcdx_printf_center_P( 1, MNORMAL, 1,0, PSTR(" Source Lat/Lon") );
641
                        lcdx_printf_center_P( 3, MNORMAL, 1,0, PSTR(" Target Lat/Lon") );
2136 - 642
 
2199 - 643
                        redraw = false;
644
                }
2136 - 645
 
2212 - 646
                writex_gpspos( 1, 2, NMEApos.latitude, MNORMAL, 0,0 );                 // GPS-Maus: Latitude
647
                writex_gpspos(10, 2, NMEApos.longitude, MNORMAL, 0,0 );                // GPS-Maus: Longitude
2136 - 648
 
2214 - 649
                followme_calculate_offset(Config.FM_Offset_Longitude, Config.FM_Offest_Latitude, &followMeOffset);
2136 - 650
 
2212 - 651
#ifdef DEBUG
2214 - 652
                writex_gpspos(  1, 6, (int32_t)Config.FM_Offest_Latitude*100, MNORMAL, 0, 0 );
653
                writex_gpspos( 10, 6, (int32_t)Config.FM_Offset_Longitude*100, MNORMAL, 0, 0 );
2212 - 654
                writex_gpspos(  1, 7, (int32_t)followMeOffset.latitude*100, MNORMAL, 0, 0 );
655
                writex_gpspos( 10, 7, (int32_t)followMeOffset.longitude*100, MNORMAL, 0, 0 );
656
#endif
2136 - 657
 
2212 - 658
                followme_add_offset(&NMEApos, &NMEATarget, &followMeOffset);
2136 - 659
 
2212 - 660
                writex_gpspos( 1, 4, (int32_t)NMEATarget.latitude, MNORMAL, 0, 0 );        // Ziel Latitude
661
                writex_gpspos(10, 4, (int32_t)NMEATarget.longitude, MNORMAL, 0, 0 );       // Ziel Longitude
2136 - 662
 
663
 
664
 
665
 
2212 - 666
                // Tasten
2199 - 667
                if( get_key_press(1 << KEY_ESC) )
668
                {
2212 - 669
#ifdef ONLINE
2200 - 670
                        GPSMouse_Disconnect();
2212 - 671
#endif
2199 - 672
                        break;
673
                }
2136 - 674
 
2199 - 675
                if( get_key_press(1 << KEY_ENTER) )
676
                {
2212 - 677
                        redraw = true;
2199 - 678
                }
2212 - 679
 
680
                if( get_key_press(1 << KEY_MINUS) )
681
                {
2214 - 682
                        Config.FM_Offest_Latitude -= 10;
2212 - 683
                        redraw = true;
684
                }
685
                if( get_key_press(1 << KEY_PLUS) )
686
                {
2214 - 687
                        Config.FM_Offest_Latitude += 10;
2212 - 688
                        redraw = true;
689
                }
2195 - 690
        }
2136 - 691
}
692
 
2195 - 693
 
694
 
2212 - 695
#endif  // FOLLOW_ME_STEP2
2136 - 696
#endif  // #ifdef USE_FOLLOWME
697
 
698