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