0,0 → 1,102 |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Copyright (c) 04.2007 Holger Buss |
// + only for non-profit use |
// + www.MikroKopter.com |
// + see the File "License.txt" for further Informations |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
#include <stdlib.h> |
#include <inttypes.h> |
#include "menu.h" |
#include "uart.h" |
#include "printf_P.h" |
#include "analog.h" |
#include "main.h" |
|
|
uint8_t MaxMenuItem = 2; |
uint8_t MenuItem = 0; |
uint8_t RemoteKeys = 0; |
|
#define KEY1 0x01 |
#define KEY2 0x02 |
#define KEY3 0x04 |
#define KEY4 0x08 |
#define KEY5 0x10 |
|
|
int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
uint8_t DispPtr = 0; |
|
|
/************************************/ |
/* 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) |
{ |
if(RemoteKeys & KEY1) |
{ |
if(MenuItem) MenuItem--; |
else MenuItem = MaxMenuItem; |
} |
if(RemoteKeys & KEY2) |
{ |
if(MenuItem == MaxMenuItem) MenuItem = 0; |
else MenuItem++; |
} |
if((RemoteKeys & KEY1) && (RemoteKeys & KEY2)) MenuItem = 0; |
|
LCD_Clear(); |
|
if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem; |
// 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,"++ MK3MAG ++ "); |
LCD_printfxy(0,1," V %d.%d%c", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH + 'a'); |
if(AccPresent) |
{ |
LCD_printfxy(0,2, " ACC Support "); |
} |
else |
{ |
LCD_printfxy(0,2, " "); |
} |
LCD_printfxy(0,3,"(c) Buss, Busker "); |
break; |
|
case 1: // Magnet readings |
LCD_printfxy(0,0,"Magnet Sensors: "); |
LCD_printfxy(0,1,"X:%+4d ", MagX); |
LCD_printfxy(0,2,"Y:%+4d ", MagY); |
LCD_printfxy(0,3,"Z:%+4d ", MagZ); |
break; |
|
default: |
MaxMenuItem = MenuItem - 1; |
MenuItem = 0; |
break; |
} |
RemoteKeys = 0; |
} |