Subversion Repositories Projects

Rev

Rev 231 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 231 Rev 274
1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
// + Copyright (c) 04.2007 Holger Buss
2
// + Copyright (c) 04.2007 Holger Buss
3
// + only for non-profit use
3
// + only for non-profit use
4
// + www.MikroKopter.com
4
// + www.MikroKopter.com
5
// + see the File "License.txt" for further Informations
5
// + see the File "License.txt" for further Informations
6
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7
 
7
 
8
#include <stdlib.h>
8
#include <stdlib.h>
9
#include <inttypes.h>
9
#include <inttypes.h>
10
#include "main.h"
-
 
11
#include "uart0.h"
10
#include "uart0.h"
12
#include "printf_P.h"
11
#include "printf_P.h"
13
#include "ubx.h"
12
#include "ubx.h"
-
 
13
#include "timer0.h"
14
 
14
 
15
uint8_t MaxMenuItem = 1;
15
uint8_t MaxMenuItem = 3;
16
uint8_t MenuItem = 0;
16
uint8_t MenuItem = 0;
17
uint8_t RemoteKeys = 0;
17
uint8_t RemoteKeys = 0;
18
 
18
 
19
#define KEY1    0x01
19
#define KEY1    0x01
20
#define KEY2    0x02
20
#define KEY2    0x02
21
#define KEY3    0x04
21
#define KEY3    0x04
22
#define KEY4    0x08
22
#define KEY4    0x08
23
#define KEY5    0x10
23
#define KEY5    0x10
24
 
24
 
25
 
25
 
26
 
26
 
27
#define DISPLAYBUFFSIZE 80
27
#define DISPLAYBUFFSIZE 80
28
int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World";
28
int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World";
29
uint8_t DispPtr = 0;
29
uint8_t DispPtr = 0;
30
 
30
 
31
 
31
 
32
/************************************/
32
/************************************/
33
/*        Clear LCD Buffer          */
33
/*        Clear LCD Buffer          */
34
/************************************/
34
/************************************/
35
void LCD_Clear(void)
35
void LCD_Clear(void)
36
{
36
{
37
        uint8_t i;
37
        uint8_t i;
38
        for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' ';
38
        for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' ';
39
}
39
}
40
 
40
 
41
 
41
 
42
/************************************/
42
/************************************/
43
/*        Update Menu on LCD        */
43
/*        Update Menu on LCD        */
44
/************************************/
44
/************************************/
45
// Display with 20 characters in 4 lines
45
// Display with 20 characters in 4 lines
46
void LCD_PrintMenu(void)
46
void LCD_PrintMenu(void)
47
{
47
{
-
 
48
        int32_t i1,i2;
-
 
49
        uint8_t sign;
-
 
50
 
48
        if(RemoteKeys & KEY1)
51
        if(RemoteKeys & KEY1)
49
        {
52
        {
50
                if(MenuItem) MenuItem--;
53
                if(MenuItem) MenuItem--;
51
                else MenuItem = MaxMenuItem;
54
                else MenuItem = MaxMenuItem;
52
        }
55
        }
53
        if(RemoteKeys  & KEY2)
56
        if(RemoteKeys  & KEY2)
54
        {
57
        {
55
                if(MenuItem == MaxMenuItem) MenuItem = 0;
58
                if(MenuItem == MaxMenuItem) MenuItem = 0;
56
                else MenuItem++;
59
                else MenuItem++;
57
        }
60
        }
58
        if((RemoteKeys  & KEY1) && (RemoteKeys  & KEY2)) MenuItem = 0;
61
        if((RemoteKeys  & KEY1) && (RemoteKeys  & KEY2)) MenuItem = 0;
59
 
62
 
60
        LCD_Clear();
63
        LCD_Clear();
61
 
64
 
62
        if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem;
65
        if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem;
63
        // print menu item number in the upper right corner
66
        // print menu item number in the upper right corner
64
        if(MenuItem < 10)
67
        if(MenuItem < 10)
65
        {
68
        {
66
          LCD_printfxy(17,0,"[%i]",MenuItem);
69
          LCD_printfxy(17,0,"[%i]",MenuItem);
67
        }
70
        }
68
        else
71
        else
69
        {
72
        {
70
          LCD_printfxy(16,0,"[%i]",MenuItem);
73
          LCD_printfxy(16,0,"[%i]",MenuItem);
71
        }
74
        }
72
 
75
 
73
        switch(MenuItem)
76
        switch(MenuItem)
74
        {
77
        {
75
    case 0:// Version Info Menu Item
78
    case 0:// Version Info Menu Item
76
           LCD_printfxy(0,0,"+ Follow Me +");
79
           LCD_printfxy(0,0,"+ Follow Me +");
77
           #ifdef USE_SDLOGGER
80
           #ifdef USE_SDLOGGER
78
           LCD_printfxy(0,1,"HW: SD-Logger");
81
           LCD_printfxy(0,1,"HW: SD-Logger");
79
           #endif
82
           #endif
80
           #ifdef USE_FOLLOWME
83
           #ifdef USE_FOLLOWME
81
           LCD_printfxy(0,1,"HW: Follow-Me");
84
           LCD_printfxy(0,1,"HW: Follow-Me");
82
           #endif
85
           #endif
83
           LCD_printfxy(0,2,"SW: %d.%d%c", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a');
86
           LCD_printfxy(0,2,"SW: %d.%d%c", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a');
84
           LCD_printfxy(0,3,"          ");
87
           LCD_printfxy(0,3,"          ");
85
           break;
88
           break;
-
 
89
        case 1:
-
 
90
                if (GPSData.Status == INVALID)
86
 
91
                {
-
 
92
                        LCD_printfxy(0,0,"No GPS data");
-
 
93
                        LCD_printfxy(0,1,"Lon:                ");
-
 
94
                        LCD_printfxy(0,2,"Lat:                ");
-
 
95
                        LCD_printfxy(0,3,"Alt:                ");
-
 
96
                }
87
        case 1://GPS Lat/Lon coords
97
                else // newdata or processed
-
 
98
                {
88
                        if (GPSInfo.status == INVALID)
99
                        switch (GPSData.SatFix)
89
                        {
100
                        {
-
 
101
                        case SATFIX_NONE:
90
                                LCD_printfxy(0,0,"No GPS data!");
102
                                LCD_printfxy(0,0,"Sats:%02d Fix:None", GPSData.NumOfSats);
-
 
103
                                break;
-
 
104
                        case SATFIX_2D:
-
 
105
                                LCD_printfxy(0,0,"Sats:%02d Fix:2D  ", GPSData.NumOfSats);
-
 
106
                                break;
-
 
107
                        case SATFIX_3D:
-
 
108
                                LCD_printfxy(0,0,"Sats:%02d Fix:3D  ", GPSData.NumOfSats);
-
 
109
                                break;
-
 
110
                        default:
-
 
111
                                LCD_printfxy(0,0,"Sats:%02d Fix:??  ", GPSData.NumOfSats);
-
 
112
                                break;
91
                        }
113
                        }
-
 
114
                        if(GPSData.Position.Longitude < 0) sign = '-';
-
 
115
                        else sign = '+';
-
 
116
                        i1 = abs(GPSData.Position.Longitude)/10000000L;
-
 
117
                        i2 = abs(GPSData.Position.Longitude)%10000000L;
-
 
118
                        LCD_printfxy(0,1,"Lon:%c%03ld.%07ld deg",sign, i1, i2);
-
 
119
                        if(GPSData.Position.Latitude < 0) sign = '-';
-
 
120
                        else sign = '+';
-
 
121
                        i1 = abs(GPSData.Position.Latitude)/10000000L;
-
 
122
                        i2 = abs(GPSData.Position.Latitude)%10000000L;
-
 
123
                        LCD_printfxy(0,2,"Lat:%c%03ld.%07ld deg",sign, i1, i2);
-
 
124
                        if(GPSData.Position.Altitude < 0) sign = '-';
-
 
125
                        else sign = '+';
-
 
126
                        i1 = abs(GPSData.Position.Altitude)/1000L;
-
 
127
                        i2 = abs(GPSData.Position.Altitude)%1000L;
-
 
128
                        LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m", sign, i1, i2);
-
 
129
                }
92
                        else
130
                break;
-
 
131
        case 2:
-
 
132
                if (GPSData.Status == INVALID)
-
 
133
                {
-
 
134
                        LCD_printfxy(0,0,"No GPS data");
-
 
135
                        LCD_printfxy(0,1,"Speed N:            ");
-
 
136
                        LCD_printfxy(0,2,"Speed E:            ");
-
 
137
                        LCD_printfxy(0,3,"Speed T:            ");
-
 
138
                }
-
 
139
                else // newdata or processed
-
 
140
                {
-
 
141
                        switch (GPSData.SatFix)
93
                        {
142
                        {
94
                                switch (GPSInfo.satfix)
-
 
95
                                {
-
 
96
                                case SATFIX_NONE:
143
                        case SATFIX_NONE:
97
                                        LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum);
144
                                LCD_printfxy(0,0,"Sats:%02d Fix:None", GPSData.NumOfSats);
98
                                        break;
145
                                break;
99
                                case SATFIX_2D:
146
                        case SATFIX_2D:
100
                                        LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum);
147
                                LCD_printfxy(0,0,"Sats:%02d Fix:2D  ", GPSData.NumOfSats);
101
                                        break;
148
                                break;
102
                                case SATFIX_3D:
149
                        case SATFIX_3D:
103
                                        LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum);
150
                                LCD_printfxy(0,0,"Sats:%02d Fix:3D  ", GPSData.NumOfSats);
104
                                        break;
151
                                break;
105
                                default:
152
                        default:
106
                                        LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum);
153
                                LCD_printfxy(0,0,"Sats:%02d Fix:??  ", GPSData.NumOfSats);
107
                                        break;
154
                                break;
108
                                }
-
 
109
                                int16_t i1,i2,i3;
-
 
110
                                i1 = (int16_t)(GPSInfo.longitude/10000000L);
-
 
111
                                i2 = abs((int16_t)((GPSInfo.longitude%10000000L)/10000L));
-
 
112
                                i3 = abs((int16_t)(((GPSInfo.longitude%10000000L)%10000L)/10L));
-
 
113
                                LCD_printfxy(0,1,"Lon: %d.%.3d%.3d deg",i1, i2, i3);
-
 
114
                                i1 = (int16_t)(GPSInfo.latitude/10000000L);
-
 
115
                                i2 = abs((int16_t)((GPSInfo.latitude%10000000L)/10000L));
-
 
116
                                i3 = abs((int16_t)(((GPSInfo.latitude%10000000L)%10000L)/10L));
-
 
117
                                LCD_printfxy(0,2,"Lat: %d.%.3d%.3d deg",i1, i2, i3);
-
 
118
                                i1 = (int16_t)(GPSInfo.altitude/1000L);
-
 
119
                                i2 = abs((int16_t)(GPSInfo.altitude%1000L));
-
 
120
                                LCD_printfxy(0,3,"Alt: %d.%.3d m",i1, i2);
-
 
121
                        }
155
                        }
-
 
156
                        LCD_printfxy(0,1,"Speed N: %+4ld cm/s",GPSData.Speed_North);
-
 
157
                        LCD_printfxy(0,2,"Speed E: %+4ld cm/s",GPSData.Speed_East);
-
 
158
                        LCD_printfxy(0,3,"Speed T: %+4ld cm/s",GPSData.Speed_Top);
-
 
159
                }
122
                        break;
160
                break;
-
 
161
        case 3:
-
 
162
                LCD_printfxy(0,0,"GPS UTC Time");
-
 
163
                if (!SystemTime.Valid)
-
 
164
                {
-
 
165
                        LCD_printfxy(0,1,"                    ");
-
 
166
                        LCD_printfxy(0,2,"  No time data!     ");
-
 
167
                        LCD_printfxy(0,3,"                    ");
-
 
168
                }
-
 
169
                else // newdata or processed
-
 
170
                {
-
 
171
                        LCD_printfxy(0,1,"                    ");
-
 
172
                        LCD_printfxy(0,2,"Date: %02i/%02i/%04i",SystemTime.Month, SystemTime.Day, SystemTime.Year);
-
 
173
                        LCD_printfxy(0,3,"Time: %02i:%02i:%02i.%03i", SystemTime.Hour, SystemTime.Min, SystemTime.Sec, SystemTime.mSec);
-
 
174
                }
-
 
175
        break;
123
 
176
 
124
    default: MaxMenuItem = MenuItem - 1;
177
    default: MaxMenuItem = MenuItem - 1;
125
             MenuItem = 0;
178
             MenuItem = 0;
126
           break;
179
           break;
127
    }
180
    }
128
    RemoteKeys = 0;
181
    RemoteKeys = 0;
129
}
182
}
130
 
183