Subversion Repositories FlightCtrl

Rev

Go to most recent revision | 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
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
685 killagreg 7
 
8
 
9
#include <inttypes.h>
1 ingob 10
#include "main.h"
687 killagreg 11
#include "eeprom.h"
685 killagreg 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"
754 killagreg 18
#ifdef USE_MM3
694 killagreg 19
#include "mm3.h"
754 killagreg 20
#endif
702 killagreg 21
#include "ubx.h"
685 killagreg 22
#include "_Settings.h"
1 ingob 23
 
752 killagreg 24
 
685 killagreg 25
#define ARRAYSIZE 10
26
uint8_t Array[ARRAYSIZE] = {1,2,3,4,5,6,7,8,9,10};
27
#define DISPLAYBUFFSIZE 80
28
int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World";
29
uint8_t DispPtr = 0;
30
uint8_t RemoteButtons = 0;
1 ingob 31
 
32
#define KEY1    0x01
33
#define KEY2    0x02
34
#define KEY3    0x04
35
#define KEY4    0x08
36
#define KEY5    0x10
37
 
685 killagreg 38
/************************************/
39
/*        Clear LCD Buffer          */
40
/************************************/
41
void LCD_Clear(void)
1 ingob 42
{
685 killagreg 43
 uint8_t i;
44
 for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' ';
1 ingob 45
}
46
 
685 killagreg 47
 
48
/************************************/
49
/*        Update Menu on LCD        */
50
/************************************/
51
// Display with 20 characters in 4 lines
52
void LCD_PrintMenu(void)
1 ingob 53
 {
754 killagreg 54
  #ifdef USE_MM3
55
  static uint8_t MaxMenuItem = 14;
56
  #else
57
  static uint8_t MaxMenuItem = 12;
58
  #endif
683 killagreg 59
 
754 killagreg 60
  static uint8_t MenuItem=0;
685 killagreg 61
  //  if KEY1 is activated goto previous menu item
62
  if(RemoteButtons & KEY1)
63
  {
64
          if(MenuItem) MenuItem--;
65
          else MenuItem = MaxMenuItem;
66
          LCD_Clear();
67
          RemotePollDisplayLine = -1;
68
  }
69
  // if KEY2 is activated goto next menu item
70
  if(RemoteButtons & KEY2)
71
  {
72
          if (MenuItem == MaxMenuItem) MenuItem = 0;
73
          else MenuItem++;
74
          LCD_Clear();
75
          RemotePollDisplayLine = -1;
76
   }
77
 
78
  // if KEY1 and KEY2 is activated goto initial menu item
79
  if((RemoteButtons & KEY1) && (RemoteButtons & KEY2)) MenuItem = 0;
80
 
81
  // print menu item number in the upper right corner
82
  if(MenuItem < 10)
83
  {
84
          LCD_printfxy(17,0,"[%i]",MenuItem);
85
  }
86
  else
87
  {
88
          LCD_printfxy(16,0,"[%i]",MenuItem);
89
  }
90
 
91
  switch(MenuItem)
92
  {
93
    case 0:// Version Info Menu Item
595 hbuss 94
           LCD_printfxy(0,0,"+ MikroKopter +");
735 killagreg 95
           LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR,VERSION_INDEX+'a');
687 killagreg 96
           LCD_printfxy(0,2,"Setting: %d ", GetActiveParamSet());
1 ingob 97
           LCD_printfxy(0,3,"(c) Holger Buss");
98
           break;
761 killagreg 99
    case 1:// Height Control Menu Item
690 killagreg 100
          if(ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL)
683 killagreg 101
           {
768 killagreg 102
           LCD_printfxy(0,0,"Height:    %5i",ReadingHeight);
103
           LCD_printfxy(0,1,"Set Point: %5i",SetPointHeight);
104
           LCD_printfxy(0,2,"Air Press.:%5i",ReadingAirPressure);
105
           LCD_printfxy(0,3,"Offset    :%5i",PressureSensorOffset);
1 ingob 106
           }
683 killagreg 107
           else
108
           {
694 killagreg 109
           LCD_printfxy(0,1,"No ");
761 killagreg 110
           LCD_printfxy(0,2,"Height Control");
1 ingob 111
           }
683 killagreg 112
 
1 ingob 113
           break;
685 killagreg 114
    case 2:// Attitude Menu Item
694 killagreg 115
           LCD_printfxy(0,0,"Attitude");
701 killagreg 116
           LCD_printfxy(0,1,"Pitch:     %5i",IntegralPitch/1024);
1 ingob 117
           LCD_printfxy(0,2,"Roll:      %5i",IntegralRoll/1024);
701 killagreg 118
           LCD_printfxy(0,3,"Compass:   %5i",CompassHeading);
1 ingob 119
           break;
685 killagreg 120
    case 3:// Remote Control Channel Menu Item
694 killagreg 121
           LCD_printfxy(0,0,"C1:%4i  C2:%4i ",PPM_in[1],PPM_in[2]);
122
           LCD_printfxy(0,1,"C3:%4i  C4:%4i ",PPM_in[3],PPM_in[4]);
123
           LCD_printfxy(0,2,"C5:%4i  C6:%4i ",PPM_in[5],PPM_in[6]);
124
           LCD_printfxy(0,3,"C7:%4i  C8:%4i ",PPM_in[7],PPM_in[8]);
1 ingob 125
           break;
685 killagreg 126
    case 4:// Remote Control Mapping Menu Item
701 killagreg 127
           LCD_printfxy(0,0,"Pi:%4i  Ro:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_PITCH]],PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]);
707 killagreg 128
           LCD_printfxy(0,1,"Gs:%4i  Ya:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_THRUST]],PPM_in[ParamSet.ChannelAssignment[CH_YAW]]);
690 killagreg 129
           LCD_printfxy(0,2,"P1:%4i  P2:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI1]],PPM_in[ParamSet.ChannelAssignment[CH_POTI2]]);
130
           LCD_printfxy(0,3,"P3:%4i  P4:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI3]],PPM_in[ParamSet.ChannelAssignment[CH_POTI4]]);
1 ingob 131
           break;
685 killagreg 132
    case 5:// Gyro Sensor Menu Item
1 ingob 133
           LCD_printfxy(0,0,"Gyro - Sensor");
685 killagreg 134
          if(BoardRelease == 10)
401 hbuss 135
          {
701 killagreg 136
           LCD_printfxy(0,1,"Pitch %4i (%3i)",AdValueGyrPitch - AdNeutralPitch, AdNeutralPitch);
137
           LCD_printfxy(0,2,"Roll  %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll);
711 killagreg 138
           LCD_printfxy(0,3,"Yaw   %4i (%3i)",Reading_GyroYaw, AdNeutralYaw);
401 hbuss 139
          }
683 killagreg 140
          else
401 hbuss 141
          {
701 killagreg 142
           LCD_printfxy(0,1,"Pitch %4i (%3i)",AdValueGyrPitch - AdNeutralPitch, AdNeutralPitch/2);
143
           LCD_printfxy(0,2,"Roll  %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll/2);
711 killagreg 144
           LCD_printfxy(0,3,"Yaw   %4i (%3i)",Reading_GyroYaw, AdNeutralYaw/2);
401 hbuss 145
          }
1 ingob 146
           break;
685 killagreg 147
    case 6:// Acceleration Sensor Menu Item
1 ingob 148
           LCD_printfxy(0,0,"ACC - Sensor");
768 killagreg 149
           LCD_printfxy(0,1,"Pitch  %4i (%3i)",AdValueAccPitch, NeutralAccX);
150
           LCD_printfxy(0,2,"Roll   %4i (%3i)",AdValueAccRoll, NeutralAccY);
761 killagreg 151
           LCD_printfxy(0,3,"Height %4i (%3i)",Mean_AccTop, (int)NeutralAccZ);
1 ingob 152
           break;
685 killagreg 153
    case 7:// Accumulator Voltage / Remote Control Level
694 killagreg 154
           LCD_printfxy(0,1,"Voltage:  %5i",UBat);
155
           LCD_printfxy(0,2,"RC-Level: %5i",SenderOkay);
1 ingob 156
           break;
685 killagreg 157
    case 8:// Compass Menu Item
694 killagreg 158
           LCD_printfxy(0,0,"Compass       ");
701 killagreg 159
           LCD_printfxy(0,1,"Course:    %5i",CompassCourse);
160
           LCD_printfxy(0,2,"Heading:   %5i",CompassHeading);
161
           LCD_printfxy(0,3,"OffCourse: %5i",CompassOffCourse);
1 ingob 162
           break;
685 killagreg 163
    case 9:// Poti Menu Item
762 killagreg 164
                   LCD_printfxy(0,0,"Po1: %3i Po5: %3i" ,Poti1,Poti5); //PPM24-Extesion
165
                   LCD_printfxy(0,1,"Po2: %3i Po6: %3i" ,Poti2,Poti6); //PPM24-Extesion
166
                   LCD_printfxy(0,2,"Po3: %3i Po7: %3i" ,Poti3,Poti7); //PPM24-Extesion
167
                   LCD_printfxy(0,3,"Po4: %3i Po8: %3i" ,Poti4,Poti8); //PPM24-Extesion
1 ingob 168
           break;
685 killagreg 169
    case 10:// Servo Menu Item
1 ingob 170
           LCD_printfxy(0,0,"Servo  " );
703 killagreg 171
           LCD_printfxy(0,1,"Setpoint  %3i",FCParam.ServoPitchControl);
694 killagreg 172
           LCD_printfxy(0,2,"Position: %3i",ServoValue);
703 killagreg 173
           LCD_printfxy(0,3,"Range:%3i-%3i",ParamSet.ServoPitchMin, ParamSet.ServoPitchMax);
1 ingob 174
           break;
685 killagreg 175
    case 11://Extern Control
595 hbuss 176
           LCD_printfxy(0,0,"ExternControl  " );
703 killagreg 177
           LCD_printfxy(0,1,"Pi:%4i  Ro:%4i ",ExternControl.Pitch, ExternControl.Roll);
707 killagreg 178
           LCD_printfxy(0,2,"Gs:%4i  Ya:%4i ",ExternControl.Thrust, ExternControl.Yaw);
761 killagreg 179
           LCD_printfxy(0,3,"Hi:%4i  Cf:%4i ",ExternControl.Height, ExternControl.Config);
595 hbuss 180
           break;
754 killagreg 181
        case 12://GPS Lat/Lon coords
702 killagreg 182
                        if (GPSInfo.status == INVALID)
183
                        {
722 killagreg 184
                                LCD_printfxy(0,0,"No data available!");
702 killagreg 185
                        }
186
                        else
187
                        {
188
                                switch (GPSInfo.satfix)
189
                                {
190
                                case SATFIX_NONE:
752 killagreg 191
                                        LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum);
702 killagreg 192
                                        break;
193
                                case SATFIX_2D:
752 killagreg 194
                                        LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum);
702 killagreg 195
                                        break;
196
                                case SATFIX_3D:
752 killagreg 197
                                        LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum);
702 killagreg 198
                                        break;
199
                                default:
752 killagreg 200
                                        LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum);
702 killagreg 201
                                        break;
202
                                }
746 killagreg 203
                                LCD_printfxy(0,1,"Lon: %d.%d deg",GPSInfo.longitude/10000000L, (GPSInfo.longitude%10000000L)/10000L);
204
                                LCD_printfxy(0,2,"Lat: %d.%d deg",GPSInfo.latitude/10000000L, (GPSInfo.latitude%10000000L)/10000L);
722 killagreg 205
                                LCD_printfxy(0,3,"Alt: %d.%d m",GPSInfo.altitude/1000L,GPSInfo.altitude%1000L);
702 killagreg 206
                        }
207
                        break;
754 killagreg 208
#ifdef USE_MM3
209
        case 13:// MM3 Kompass
210
                        LCD_printfxy(0,0,"MM3 Offset");
211
                        LCD_printfxy(0,1,"X_Offset:  %3i",MM3_calib.X_off);
212
                        LCD_printfxy(0,2,"Y_Offset:  %3i",MM3_calib.Y_off);
213
                        LCD_printfxy(0,3,"Z_Offset:  %3i",MM3_calib.Z_off);
214
                        break;
215
        case 14://MM3 Range
216
                        LCD_printfxy(0,0,"MM3 Range");
217
                        LCD_printfxy(0,1,"X_Range:  %4i",MM3_calib.X_range);
218
                        LCD_printfxy(0,2,"Y_Range:  %4i",MM3_calib.Y_range);
219
                        LCD_printfxy(0,3,"Z_Range:  %4i",MM3_calib.Z_range);
220
                        break;
221
#endif
685 killagreg 222
    default: MaxMenuItem = MenuItem - 1;
223
             MenuItem = 0;
1 ingob 224
           break;
225
    }
685 killagreg 226
 RemoteButtons = 0;
304 ingob 227
}