Subversion Repositories FlightCtrl

Rev

Rev 685 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Copyright (c) 04.2007 Holger Buss
// + only for non-profit use
// + www.MikroKopter.com
// + see the File "License.txt" for further Informations
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


#include <inttypes.h>
#include "main.h"
#include "eeprom.h"
#include "timer2.h"
#include "fc.h"
#include "rc.h"
#include "uart.h"
#include "printf_P.h"
#include "analog.h"
#include "_Settings.h"

uint16_t  TestInt = 0;
#define ARRAYSIZE 10
uint8_t Array[ARRAYSIZE] = {1,2,3,4,5,6,7,8,9,10};
#define DISPLAYBUFFSIZE 80
int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World";
uint8_t DispPtr = 0;
uint8_t RemoteButtons = 0;

#define KEY1    0x01
#define KEY2    0x02
#define KEY3    0x04
#define KEY4    0x08
#define KEY5    0x10

/************************************/
/*        Clear LCD Buffer          */
/************************************/
void LCD_Clear(void)
{
 uint8_t i;
 for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' ';
}


/************************************/
/*        Update Menu on LCD        */
/************************************/
// Display with 20 characters in 4 lines
void LCD_PrintMenu(void)
 {
  static uint8_t MaxMenuItem = 11, MenuItem=0;

  //  if KEY1 is activated goto previous menu item
  if(RemoteButtons & KEY1)
  {
          if(MenuItem) MenuItem--;
          else MenuItem = MaxMenuItem;
          LCD_Clear();
          RemotePollDisplayLine = -1;
  }
  // if KEY2 is activated goto next menu item
  if(RemoteButtons & KEY2)
  {
          if (MenuItem == MaxMenuItem) MenuItem = 0;
          else MenuItem++;
          LCD_Clear();
          RemotePollDisplayLine = -1;
   }

  // if KEY1 and KEY2 is activated goto initial menu item
  if((RemoteButtons & KEY1) && (RemoteButtons & KEY2)) MenuItem = 0;

  // print menu item number in the upper right corner
  if(MenuItem < 10)
  {
          LCD_printfxy(17,0,"[%i]",MenuItem);
  }
  else
  {
          LCD_printfxy(16,0,"[%i]",MenuItem);
  }

  switch(MenuItem)
  {
    case 0:// Version Info Menu Item
           LCD_printfxy(0,0,"+ MikroKopter +");
           LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_HAUPTVERSION, VERSION_NEBENVERSION,VERSION_INDEX+'a');
           LCD_printfxy(0,2,"Setting: %d ", GetActiveParamSet());
           LCD_printfxy(0,3,"(c) Holger Buss");
           break;
    case 1:// Hight Control Menu Item
          if(ParamSet.GlobalConfig & CFG_HOEHENREGELUNG)
           {
           LCD_printfxy(0,0,"Hoehe:     %5i",HoehenWert);
           LCD_printfxy(0,1,"SollHoehe: %5i",SollHoehe);
           LCD_printfxy(0,2,"Luftdruck: %5i",MessLuftdruck);
           LCD_printfxy(0,3,"Off      : %5i",DruckOffsetSetting);
           }
           else
           {
           LCD_printfxy(0,1,"Keine ");
           LCD_printfxy(0,2,"Höhenregelung");
           }

           break;
    case 2:// Attitude Menu Item
           LCD_printfxy(0,0,"akt. Lage");
           LCD_printfxy(0,1,"Nick:      %5i",IntegralNick/1024);
           LCD_printfxy(0,2,"Roll:      %5i",IntegralRoll/1024);
           LCD_printfxy(0,3,"Kompass:   %5i",KompassValue);
           break;
    case 3:// Remote Control Channel Menu Item
           LCD_printfxy(0,0,"K1:%4i  K2:%4i ",PPM_in[1],PPM_in[2]);
           LCD_printfxy(0,1,"K3:%4i  K4:%4i ",PPM_in[3],PPM_in[4]);
           LCD_printfxy(0,2,"K5:%4i  K6:%4i ",PPM_in[5],PPM_in[6]);
           LCD_printfxy(0,3,"K7:%4i  K8:%4i ",PPM_in[7],PPM_in[8]);
           break;
    case 4:// Remote Control Mapping Menu Item
           LCD_printfxy(0,0,"Ni:%4i  Ro:%4i ",PPM_in[ParamSet.Kanalbelegung[K_NICK]],PPM_in[ParamSet.Kanalbelegung[K_ROLL]]);
           LCD_printfxy(0,1,"Gs:%4i  Gi:%4i ",PPM_in[ParamSet.Kanalbelegung[K_GAS]],PPM_in[ParamSet.Kanalbelegung[K_GIER]]);
           LCD_printfxy(0,2,"P1:%4i  P2:%4i ",PPM_in[ParamSet.Kanalbelegung[K_POTI1]],PPM_in[ParamSet.Kanalbelegung[K_POTI2]]);
           LCD_printfxy(0,3,"P3:%4i  P4:%4i ",PPM_in[ParamSet.Kanalbelegung[K_POTI3]],PPM_in[ParamSet.Kanalbelegung[K_POTI4]]);
           break;
    case 5:// Gyro Sensor Menu Item
           LCD_printfxy(0,0,"Gyro - Sensor");
          if(BoardRelease == 10)
          {
           LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueGyrNick - AdNeutralNick, AdNeutralNick);
           LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll);
           LCD_printfxy(0,3,"Gier %4i (%3i)",MesswertGier, AdNeutralGier);
          }
          else
          {
           LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueGyrNick - AdNeutralNick, AdNeutralNick/2);
           LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll/2);
           LCD_printfxy(0,3,"Gier %4i (%3i)",MesswertGier, AdNeutralGier/2);
          }
           break;
    case 6:// Acceleration Sensor Menu Item
           LCD_printfxy(0,0,"ACC - Sensor");
           LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueAccNick,NeutralAccX);
           LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueAccRoll,NeutralAccY);
           LCD_printfxy(0,3,"Hoch %4i (%3i)",Mittelwert_AccHoch/*accumulate_AccHoch / messanzahl_AccHoch*/,(int)NeutralAccZ);
           break;
    case 7:// Accumulator Voltage / Remote Control Level
           LCD_printfxy(0,1,"Spannung:  %5i",UBat);
           LCD_printfxy(0,2,"Empf.Pegel:%5i",SenderOkay);
           break;
    case 8:// Compass Menu Item
           LCD_printfxy(0,0,"Kompass       ");
           LCD_printfxy(0,1,"Richtung:  %5i",KompassRichtung);
           LCD_printfxy(0,2,"Messwert:  %5i",KompassValue);
           LCD_printfxy(0,3,"Start:     %5i",KompassStartwert);
           break;
    case 9:// Poti Menu Item
           LCD_printfxy(0,0,"Poti1:  %3i",Poti1);
           LCD_printfxy(0,1,"Poti2:  %3i",Poti2);
           LCD_printfxy(0,2,"Poti3:  %3i",Poti3);
           LCD_printfxy(0,3,"Poti4:  %3i",Poti4);
           break;
    case 10:// Servo Menu Item
           LCD_printfxy(0,0,"Servo  " );
           LCD_printfxy(0,1,"Setpoint  %3i",Parameter_ServoNickControl);
           LCD_printfxy(0,2,"Stellung: %3i",ServoValue);
           LCD_printfxy(0,3,"Range:%3i-%3i",ParamSet.ServoNickMin,ParamSet.ServoNickMax);
           break;
    case 11://Extern Control
           LCD_printfxy(0,0,"ExternControl  " );
           LCD_printfxy(0,1,"Ni:%4i  Ro:%4i ",ExternControl.Nick,ExternControl.Roll);
           LCD_printfxy(0,2,"Gs:%4i  Gi:%4i ",ExternControl.Gas,ExternControl.Gier);
           LCD_printfxy(0,3,"Hi:%4i  Cf:%4i ",ExternControl.Hight,ExternControl.Config);
           break;
    default: MaxMenuItem = MenuItem - 1;
             MenuItem = 0;
           break;
    }
 RemoteButtons = 0;
}