/beta/Code Redesign killagreg/main.c |
---|
327,7 → 327,7 |
if (ParamSet.Config0 & CFG0_HEADING_HOLD) printf("HeadingHold"); |
else printf("Neutral (ACC-Mode)"); |
LCD_Clear(); |
Menu_Clear(); |
I2CTimeout = 5000; |
LipoDetection(1); |
printf("\n\r===================================\n\r"); |
/beta/Code Redesign killagreg/menu.c |
---|
60,6 → 60,7 |
#include "printf_P.h" |
#include "analog.h" |
#include "twimaster.h" |
#include "menu.h" |
#ifdef USE_KILLAGREG |
#include "mm3.h" |
81,25 → 82,13 |
#endif |
#endif |
uint8_t MenuItem = 0; |
uint8_t RemoteKeys = 0; |
#define KEY1 0x01 |
#define KEY2 0x02 |
#define KEY3 0x04 |
#define KEY4 0x08 |
#define KEY5 0x10 |
#define DISPLAYBUFFSIZE 80 |
int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
uint8_t DispPtr = 0; |
/************************************/ |
/* Clear LCD Buffer */ |
/************************************/ |
void LCD_Clear(void) |
void Menu_Clear(void) |
{ |
uint8_t i; |
for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' '; |
106,29 → 95,24 |
} |
/************************************/ |
/* Update Menu on LCD */ |
/************************************/ |
// Display with 20 characters in 4 lines |
void LCD_PrintMenu(void) |
void Menu_Update(uint8_t Keys) |
{ |
if(RemoteKeys & KEY1) |
if(Keys & KEY1) |
{ |
if(MenuItem) MenuItem--; |
else MenuItem = MaxMenuItem; |
} |
if(RemoteKeys & KEY2) |
if(Keys & KEY2) |
{ |
if(MenuItem == MaxMenuItem) MenuItem = 0; |
else MenuItem++; |
} |
if((RemoteKeys & KEY1) && (RemoteKeys & KEY2)) MenuItem = 0; |
if((Keys & KEY1) && (Keys & KEY2)) MenuItem = 0; |
Menu_Clear(); |
LCD_Clear(); |
if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem; |
// print menu item number in the upper right corner |
if(MenuItem < 10) |
281,7 → 265,7 |
LCD_printfxy(0,1,"Total:%5u min",FlightMinutesTotal); |
LCD_printfxy(0,2,"Trip: %5u min",FlightMinutes); |
LCD_printfxy(13,3,"(reset)"); |
if(RemoteKeys & KEY4) |
if(Keys & KEY4) |
{ |
FlightMinutes = 0; |
SetParamWord(PID_FLIGHT_MINUTES, FlightMinutes); |
345,6 → 329,5 |
MaxMenuItem = MenuItem - 1; |
MenuItem = 0; |
break; |
} // end switch |
} |
RemoteKeys = 0; |
} |
/beta/Code Redesign killagreg/menu.h |
---|
5,13 → 5,19 |
#define DISPLAYBUFFSIZE 80 |
extern void LCD_PrintMenu(void); |
extern void LCD_Clear(void); |
#define KEY1 0x01 |
#define KEY2 0x02 |
#define KEY3 0x04 |
#define KEY4 0x08 |
extern void Menu_Update(uint8_t Keys); |
extern void Menu_Clear(void); |
extern int8_t DisplayBuff[DISPLAYBUFFSIZE]; |
extern uint8_t DispPtr; |
extern uint8_t MenuItem; |
extern uint8_t MaxMenuItem; |
extern uint8_t RemoteKeys; |
#endif //_MENU_H |
/beta/Code Redesign killagreg/uart0.c |
---|
93,6 → 93,7 |
uint8_t Request_PPMChannels = FALSE; |
uint8_t Request_MotorTest = FALSE; |
uint8_t DisplayLine = 0; |
uint8_t DisplayKeys = 0; |
volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
volatile uint8_t rxd_buffer_locked = FALSE; |
333,7 → 334,7 |
// if 2nd byte is an 'R' enable watchdog that will result in an reset |
if(rxd_buffer[2] == 'R') // Reset-Commando |
{ |
LCD_Clear(); |
Menu_Clear(); |
wdt_enable(WDTO_250MS); |
Servo_Off(); |
} |
634,7 → 635,7 |
} |
else // new format |
{ |
RemoteKeys |= ~pRxData[0]; |
DisplayKeys |= ~pRxData[0]; |
Display_Interval = (uint16_t) pRxData[1] * 10; |
DisplayLine = 4; |
AboTimeOut = SetDelay(ABO_TIMEOUT); |
716,8 → 717,8 |
{ |
if(DisplayLine > 3)// new format |
{ |
LCD_PrintMenu(); |
SendOutData('H', FC_ADDRESS, 1, (uint8_t *)DisplayBuff, 80); |
Menu_Update(DisplayKeys); |
SendOutData('H', FC_ADDRESS, 1, (uint8_t *)DisplayBuff, sizeof(DisplayBuff)); |
} |
else // old format |
{ |
730,7 → 731,7 |
} |
else if(Request_Display1 && txd_complete) |
{ |
LCD_PrintMenu(); |
Menu_Update(0); |
SendOutData('L', FC_ADDRESS, 3, &MenuItem, sizeof(MenuItem), &MaxMenuItem, sizeof(MaxMenuItem), DisplayBuff, sizeof(DisplayBuff)); |
Request_Display1 = FALSE; |
} |