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