Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1484 → Rev 1485

/beta/Code Redesign killagreg/jetimenu.c
0,0 → 1,167
#include "jetimenu.h"
#include "libfc.h"
#include "printf_P.h"
#include "fc.h"
#include "rc.h"
#include "analog.h"
#include "eeprom.h"
#include "main.h"
#ifdef USE_NAVICTRL
#include "spi.h"
#endif
 
 
#define JETIBOX_KEY_RIGHT 0x1F
#define JETIBOX_KEY_UP 0x2F
#define JETIBOX_KEY_DOWN 0x4F
#define JETIBOX_KEY_LEFT 0x8F
#define JETIBOX_KEY_NONE 0x0F
#define JETIBOX_KEY_UNDEF 0x00
 
#define JetiBox_printfxy(x,y,format, args...) { LIBFC_JetiBox_SetPos(y * 16 + x); _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);}
#define JetiBox_printf(format, args...) { _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);}
 
// -----------------------------------------------------------
// the menu functions
// -----------------------------------------------------------
#define JETI_MENU_FCINFO 0
void mf0(uint8_t key)
{
JetiBox_printfxy(0,0,"+ Flight-Ctrl + ");
JetiBox_printfxy(0,1,"HW:%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a');
}
#define JETI_MENU_VOLT_RC 1
void mf1(uint8_t key)
{
JetiBox_printfxy(0,0,"Volt RC-Level");
JetiBox_printfxy(0,1,"%2i.%1iV %03i",UBat/10, UBat%10, RC_Quality);
}
#define JETI_MENU_HEIGHT 2
void mf2(uint8_t key)
{
JetiBox_printfxy(0,0,"Height Vario");
if(ParamSet.Config0 & CFG0_AIRPRESS_SENSOR)
{
JetiBox_printfxy(0,1,"%5i %5i", (int16_t)(ReadingHeight/5), ReadingVario);
}
else
{
JetiBox_printfxy(0,1,"no press. sensor");
}
}
#define JETI_MENU_ATTITUDE 3
void mf3(uint8_t key)
{
JetiBox_printfxy(0,0,"Nick Roll Yaw");
JetiBox_printfxy(0,1,"%4i %4i %4i", (int16_t)(IntegralGyroNick/1024), (int16_t)(IntegralGyroRoll/1024), (int16_t)(YawGyroHeading / GYRO_DEG_FACTOR));
}
#define JETI_MENU_NCINFO 4
void mf4(uint8_t key)
{
JetiBox_printfxy(0,0," + Navi-Ctrl + ");
#ifdef USE_NAVICTRL
if(NCDataOkay)
{
JetiBox_printfxy(0,1,"HW:%d.%d SW:%d.%d%c",NC_Version.Hardware/10,NC_Version.Hardware%10,NC_Version.Major, NC_Version.Minor, NC_Version.Patch+'a');
}
else
{
JetiBox_printfxy(0,1," Not found! ");
}
#else
JetiBox_printfxy(0,1,"No NC Support");
#endif
}
#define JETI_MENU_GPSINFO 5
void mf5(uint8_t key)
{
JetiBox_printfxy(0,0,"Sat:%02d", GPSInfo.NumOfSats);
switch (GPSInfo.SatFix)
{
case SATFIX_NONE:
JetiBox_printfxy(6,0,"NoFix");
break;
case SATFIX_2D:
JetiBox_printfxy(6,0,"2DFix");
break;
case SATFIX_3D:
JetiBox_printfxy(6,0,"3DFix");
break;
default:
JetiBox_printfxy(6,0,"??Fix");
break;
}
if(GPSInfo.Flags & FLAG_DIFFSOLN)
{
JetiBox_printfxy(11,0,"/DGPS");
}
JetiBox_printfxy(0,1,"Home:%03dm %03d%c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF);
}
 
// -----------------------------------------------------------
// the menu topology
// -----------------------------------------------------------
typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer
 
typedef struct{
int8_t left;
int8_t right;
int8_t up;
int8_t down;
pFctMenu pHandler;
} MENU_ENTRY;
 
 
// the menu navigation structure
/*
0 ----------------------------- 4
| |
3 - 1 - 2 - 3 - 1 5
 
*/
 
const MENU_ENTRY JetiBox_Menu[] PROGMEM=
{ // l r u d pHandler
{0, 4, 0, 1, &mf0 }, // 0
{3, 2, 0, 1, &mf1 }, // 1
{1, 3, 0, 2, &mf2 }, // 2
{2, 1, 0, 3, &mf3 }, // 3
{0, 4, 4, 5, &mf4 }, // 4
{5, 5, 4, 5, &mf5 } // 5
};
 
// -----------------------------------------------------------
// Update display buffer
// -----------------------------------------------------------
void JetiBox_Update(unsigned char key)
{
static uint8_t item = 0, last_item = 0; // the menu item
 
// navigate within the menu by key action
last_item = item;
switch(key)
{
case JETIBOX_KEY_LEFT:
item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item
break;
case JETIBOX_KEY_RIGHT:
item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item
break;
case JETIBOX_KEY_UP:
item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item
break;
case JETIBOX_KEY_DOWN:
item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item
break;
default:
break;
}
// if the menu item has been changed, do not pass the key to the item handler
// to avoid jumping over to items
if(item != last_item) key = JETIBOX_KEY_UNDEF;
 
LIBFC_JetiBox_Clear();
//execute menu item handler
((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key);
}
 
/beta/Code Redesign killagreg/jetimenu.h
0,0 → 1,7
#ifndef _JETIMENU_H
#define _JETIMENU_H
 
#include <inttypes.h>
extern void JetiBox_Update(uint8_t key);
 
#endif //_JETIMENU_H
/beta/Code Redesign killagreg/libfc.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/beta/Code Redesign killagreg/libfc.h
1,8 → 1,13
#ifndef _LIBFC_H
#define _LIBFC_H
#include <inttypes.h>
 
extern void LIBFC_Init(void); // general init function (must be called at startup)
extern void LIBFC_ReceiverInit(void); // init of reveicer type
extern void LIBFC_Polling(void); // must be called in main-loop
 
extern void LIBFC_JetiBox_Putchar(char c);
extern void LIBFC_JetiBox_SetPos(uint8_t index);
extern void LIBFC_JetiBox_Clear(void);
 
#endif //_LIBFC_H
/beta/Code Redesign killagreg/makefile
110,7 → 110,7
##########################################################################################################
# List C source files here. (C dependencies are automatically generated.)
SRC = main.c uart0.c timer0.c timer2.c analog.c menu.c led.c
SRC += twimaster.c rc.c fc.c eeprom.c mymath.c spektrum.c
SRC += twimaster.c rc.c fc.c eeprom.c mymath.c spektrum.c jetimenu.c
 
ifeq ($(EXT), MK3MAG)
SRC += mk3mag.c