Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ingob 1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
// + Copyright (c) 04.2007 Holger Buss
3
// + only for non-profit use
4
// + www.MikroKopter.com
5
// + see the File "License.txt" for further Informations
6
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
886 killagreg 7
 
8
#include <stdlib.h>
9
#include <inttypes.h>
1 ingob 10
#include "main.h"
886 killagreg 11
#include "eeprom.h"
12
#include "timer2.h"
13
#include "fc.h"
14
#include "rc.h"
15
#include "uart.h"
16
#include "printf_P.h"
17
#include "analog.h"
1078 killagreg 18
 
886 killagreg 19
#ifdef USE_KILLAGREG
20
#include "mm3.h"
908 killagreg 21
#endif
1078 killagreg 22
 
953 killagreg 23
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG))
886 killagreg 24
#include "ubx.h"
25
#endif
1078 killagreg 26
 
886 killagreg 27
#include "_Settings.h"
1 ingob 28
 
1078 killagreg 29
#if (!defined (USE_KILLAGREG) && !defined (USE_MK3MAG))
30
uint8_t MaxMenuItem = 11;
31
#else
32
#ifdef USE_MK3MAG
33
uint8_t MaxMenuItem = 12;
34
#endif
1 ingob 35
 
1078 killagreg 36
#ifdef USE_KILLAGREG
37
uint8_t MaxMenuItem = 14;
38
#endif
39
#endif
40
uint8_t MenuItem = 0;
41
uint8_t RemoteKeys = 0;
886 killagreg 42
 
1 ingob 43
#define KEY1    0x01
44
#define KEY2    0x02
45
#define KEY3    0x04
46
#define KEY4    0x08
47
#define KEY5    0x10
48
 
1078 killagreg 49
 
50
 
51
#define DISPLAYBUFFSIZE 80
52
int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World";
53
uint8_t DispPtr = 0;
54
 
55
 
886 killagreg 56
/************************************/
57
/*        Clear LCD Buffer          */
58
/************************************/
59
void LCD_Clear(void)
1 ingob 60
{
886 killagreg 61
 uint8_t i;
62
 for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' ';
1 ingob 63
}
64
 
886 killagreg 65
 
66
/************************************/
67
/*        Update Menu on LCD        */
68
/************************************/
69
// Display with 20 characters in 4 lines
70
void LCD_PrintMenu(void)
908 killagreg 71
{
1078 killagreg 72
        if(RemoteKeys & KEY1)
73
        {
74
                if(MenuItem) MenuItem--;
75
                else MenuItem = MaxMenuItem;
76
        }
77
        if(RemoteKeys  & KEY2)
78
        {
79
                if(MenuItem == MaxMenuItem) MenuItem = 0;
80
                else MenuItem++;
81
        }
82
        if((RemoteKeys  & KEY1) && (RemoteKeys  & KEY2)) MenuItem = 0;
908 killagreg 83
 
1078 killagreg 84
        LCD_Clear();
886 killagreg 85
 
1078 killagreg 86
        if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem;
87
        // print menu item number in the upper right corner
88
        if(MenuItem < 10)
89
        {
886 killagreg 90
          LCD_printfxy(17,0,"[%i]",MenuItem);
1078 killagreg 91
        }
92
        else
93
        {
886 killagreg 94
          LCD_printfxy(16,0,"[%i]",MenuItem);
1078 killagreg 95
        }
886 killagreg 96
 
1078 killagreg 97
        switch(MenuItem)
98
        {
886 killagreg 99
    case 0:// Version Info Menu Item
595 hbuss 100
           LCD_printfxy(0,0,"+ MikroKopter +");
1078 killagreg 101
           LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a');
886 killagreg 102
           LCD_printfxy(0,2,"Setting: %d ", GetActiveParamSet());
1 ingob 103
           LCD_printfxy(0,3,"(c) Holger Buss");
104
           break;
886 killagreg 105
    case 1:// Height Control Menu Item
106
          if(ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL)
107
           {
108
           LCD_printfxy(0,0,"Height:    %5i",ReadingHeight);
109
           LCD_printfxy(0,1,"Set Point: %5i",SetPointHeight);
110
           LCD_printfxy(0,2,"Air Press.:%5i",ReadingAirPressure);
111
           LCD_printfxy(0,3,"Offset    :%5i",PressureSensorOffset);
1 ingob 112
           }
886 killagreg 113
           else
114
           {
115
           LCD_printfxy(0,1,"No ");
116
           LCD_printfxy(0,2,"Height Control");
1 ingob 117
           }
886 killagreg 118
 
1 ingob 119
           break;
886 killagreg 120
    case 2:// Attitude Menu Item
121
           LCD_printfxy(0,0,"Attitude");
936 killagreg 122
           LCD_printfxy(0,1,"Nick:      %5i",IntegralNick/1024);
1 ingob 123
           LCD_printfxy(0,2,"Roll:      %5i",IntegralRoll/1024);
886 killagreg 124
           LCD_printfxy(0,3,"Heading:   %5i",CompassHeading);
1 ingob 125
           break;
886 killagreg 126
    case 3:// Remote Control Channel Menu Item
127
           LCD_printfxy(0,0,"C1:%4i  C2:%4i ",PPM_in[1],PPM_in[2]);
128
           LCD_printfxy(0,1,"C3:%4i  C4:%4i ",PPM_in[3],PPM_in[4]);
129
           LCD_printfxy(0,2,"C5:%4i  C6:%4i ",PPM_in[5],PPM_in[6]);
130
           LCD_printfxy(0,3,"C7:%4i  C8:%4i ",PPM_in[7],PPM_in[8]);
1 ingob 131
           break;
886 killagreg 132
    case 4:// Remote Control Mapping Menu Item
912 killagreg 133
           LCD_printfxy(0,0,"Ni:%4i  Ro:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_NICK]],PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]);
911 killagreg 134
           LCD_printfxy(0,1,"Gs:%4i  Ya:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_GAS]],PPM_in[ParamSet.ChannelAssignment[CH_YAW]]);
886 killagreg 135
           LCD_printfxy(0,2,"P1:%4i  P2:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI1]],PPM_in[ParamSet.ChannelAssignment[CH_POTI2]]);
136
           LCD_printfxy(0,3,"P3:%4i  P4:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI3]],PPM_in[ParamSet.ChannelAssignment[CH_POTI4]]);
1 ingob 137
           break;
1078 killagreg 138
        case 5:// Gyro Sensor Menu Item
1 ingob 139
           LCD_printfxy(0,0,"Gyro - Sensor");
936 killagreg 140
           switch(BoardRelease)
141
           {
142
                        case 10:
143
                           LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueGyrNick - AdNeutralNick, AdNeutralNick);
144
                           LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll);
145
                           LCD_printfxy(0,3,"Yaw  %4i (%3i)",AdNeutralYaw  - AdValueGyrYaw , AdNeutralYaw);
146
                           break;
147
 
148
                        case 11:
1078 killagreg 149
                        case 12:
150
                        case 20:
936 killagreg 151
                           LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueGyrNick - AdNeutralNick, AdNeutralNick/2);
152
                           LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll/2);
153
                           LCD_printfxy(0,3,"Yaw  %4i (%3i)",AdNeutralYaw  - AdValueGyrYaw , AdNeutralYaw/2);
154
                           break;
155
 
1078 killagreg 156
                        case 13:
936 killagreg 157
                        default:
158
                           LCD_printfxy(0,1,"Nick %4i (%3i)(%3i)",AdValueGyrNick - AdNeutralNick, AdNeutralNick/2, AnalogOffsetNick);
159
                           LCD_printfxy(0,2,"Roll %4i (%3i)(%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll/2, AnalogOffsetRoll);
160
                           LCD_printfxy(0,3,"Yaw  %4i (%3i)(%3i)",AdNeutralYaw  - AdValueGyrYaw , AdNeutralYaw/2 , AnalogOffsetYaw );
161
                           break;
401 hbuss 162
          }
936 killagreg 163
          break;
886 killagreg 164
    case 6:// Acceleration Sensor Menu Item
1 ingob 165
           LCD_printfxy(0,0,"ACC - Sensor");
936 killagreg 166
           LCD_printfxy(0,1,"Nick   %4i (%3i)",AdValueAccNick, NeutralAccX);
886 killagreg 167
           LCD_printfxy(0,2,"Roll   %4i (%3i)",AdValueAccRoll, NeutralAccY);
168
           LCD_printfxy(0,3,"Height %4i (%3i)",Mean_AccTop, (int)NeutralAccZ);
1 ingob 169
           break;
886 killagreg 170
    case 7:// Accumulator Voltage / Remote Control Level
171
           LCD_printfxy(0,1,"Voltage:  %5i",UBat);
172
           LCD_printfxy(0,2,"RC-Level: %5i",RC_Quality);
1 ingob 173
           break;
886 killagreg 174
    case 8:// Compass Menu Item
175
           LCD_printfxy(0,0,"Compass       ");
176
           LCD_printfxy(0,1,"Course:    %5i",CompassCourse);
177
           LCD_printfxy(0,2,"Heading:   %5i",CompassHeading);
178
           LCD_printfxy(0,3,"OffCourse: %5i",CompassOffCourse);
1 ingob 179
           break;
886 killagreg 180
    case 9:// Poti Menu Item
181
                   LCD_printfxy(0,0,"Po1: %3i Po5: %3i" ,Poti1,Poti5); //PPM24-Extesion
182
                   LCD_printfxy(0,1,"Po2: %3i Po6: %3i" ,Poti2,Poti6); //PPM24-Extesion
183
                   LCD_printfxy(0,2,"Po3: %3i Po7: %3i" ,Poti3,Poti7); //PPM24-Extesion
184
                   LCD_printfxy(0,3,"Po4: %3i Po8: %3i" ,Poti4,Poti8); //PPM24-Extesion
1 ingob 185
           break;
886 killagreg 186
    case 10:// Servo Menu Item
1 ingob 187
           LCD_printfxy(0,0,"Servo  " );
911 killagreg 188
           LCD_printfxy(0,1,"Setpoint  %3i",FCParam.ServoNickControl);
886 killagreg 189
           LCD_printfxy(0,2,"Position: %3i",ServoValue);
911 killagreg 190
           LCD_printfxy(0,3,"Range:%3i-%3i",ParamSet.ServoNickMin, ParamSet.ServoNickMax);
1 ingob 191
           break;
886 killagreg 192
    case 11://Extern Control
595 hbuss 193
           LCD_printfxy(0,0,"ExternControl  " );
912 killagreg 194
           LCD_printfxy(0,1,"Ni:%4i  Ro:%4i ",ExternControl.Nick, ExternControl.Roll);
195
           LCD_printfxy(0,2,"Gs:%4i  Ya:%4i ",ExternControl.Gas, ExternControl.Yaw);
886 killagreg 196
           LCD_printfxy(0,3,"Hi:%4i  Cf:%4i ",ExternControl.Height, ExternControl.Config);
595 hbuss 197
           break;
886 killagreg 198
 
938 killagreg 199
    #if (defined (USE_KILLAGREG) || defined (USE_MK3MAG))
886 killagreg 200
        case 12://GPS Lat/Lon coords
201
                        if (GPSInfo.status == INVALID)
202
                        {
203
                                LCD_printfxy(0,0,"No GPS data!");
204
                        }
205
                        else
206
                        {
207
                                switch (GPSInfo.satfix)
208
                                {
209
                                case SATFIX_NONE:
210
                                        LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum);
211
                                        break;
212
                                case SATFIX_2D:
213
                                        LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum);
214
                                        break;
215
                                case SATFIX_3D:
216
                                        LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum);
217
                                        break;
218
                                default:
219
                                        LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum);
220
                                        break;
221
                                }
222
                                int16_t i1,i2,i3;
223
                                i1 = (int16_t)(GPSInfo.longitude/10000000L);
224
                                i2 = abs((int16_t)((GPSInfo.longitude%10000000L)/10000L));
225
                                i3 = abs((int16_t)(((GPSInfo.longitude%10000000L)%10000L)/10L));
226
                                LCD_printfxy(0,1,"Lon: %d.%.3d%.3d deg",i1, i2, i3);
227
                                i1 = (int16_t)(GPSInfo.latitude/10000000L);
228
                                i2 = abs((int16_t)((GPSInfo.latitude%10000000L)/10000L));
229
                                i3 = abs((int16_t)(((GPSInfo.latitude%10000000L)%10000L)/10L));
230
                                LCD_printfxy(0,2,"Lat: %d.%.3d%.3d deg",i1, i2, i3);
231
                                i1 = (int16_t)(GPSInfo.altitude/1000L);
232
                                i2 = abs((int16_t)(GPSInfo.altitude%1000L));
233
                                LCD_printfxy(0,3,"Alt: %d.%.3d m",i1, i2);
234
                        }
235
                        break;
908 killagreg 236
        #endif
237
        #ifdef USE_KILLAGREG
886 killagreg 238
        case 13:// MM3 Kompass
239
                        LCD_printfxy(0,0,"MM3 Offset");
240
                        LCD_printfxy(0,1,"X_Offset:  %3i",MM3_calib.X_off);
241
                        LCD_printfxy(0,2,"Y_Offset:  %3i",MM3_calib.Y_off);
242
                        LCD_printfxy(0,3,"Z_Offset:  %3i",MM3_calib.Z_off);
243
                        break;
244
        case 14://MM3 Range
245
                        LCD_printfxy(0,0,"MM3 Range");
246
                        LCD_printfxy(0,1,"X_Range:  %4i",MM3_calib.X_range);
247
                        LCD_printfxy(0,2,"Y_Range:  %4i",MM3_calib.Y_range);
248
                        LCD_printfxy(0,3,"Z_Range:  %4i",MM3_calib.Z_range);
249
                        break;
250
        #endif
251
 
252
    default: MaxMenuItem = MenuItem - 1;
253
             MenuItem = 0;
1 ingob 254
           break;
255
    }
1078 killagreg 256
    RemoteKeys = 0;
304 ingob 257
}