Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1491 → Rev 1492

/beta/Code Redesign killagreg/analog.c
219,6 → 219,7
static int32_t filtergyronick, filtergyroroll;
static int32_t tmpAirPressure = 0;
static uint8_t AirPressCount = 0;
static int8_t Sub_AdBiasAccTop = 0;
 
// state machine
switch(state++)
263,8 → 264,13
{
if(AdBiasAccTop < 750)
{
AdBiasAccTop += 0.02;
if(ModelIsFlying < 500) AdBiasAccTop += 0.1;
Sub_AdBiasAccTop += 2;
if(ModelIsFlying < 500) Sub_AdBiasAccTop += 10;
if(Sub_AdBiasAccTop > 100)
{
Sub_AdBiasAccTop -= 100;
AdBiasAccTop++;
}
}
}
else if(AdValueAccTop < -1)
271,8 → 277,14
{
if(AdBiasAccTop > 550)
{
AdBiasAccTop -= 0.02;
if(ModelIsFlying < 500) AdBiasAccTop -= 0.1;
Sub_AdBiasAccTop -= 2;
if(ModelIsFlying < 500) Sub_AdBiasAccTop -= 10;
if(Sub_AdBiasAccTop < 100)
{
Sub_AdBiasAccTop += 100;
AdBiasAccTop--;
}
 
}
}
// averaging acc
/beta/Code Redesign killagreg/capacity.c
115,8 → 115,8
else // motors are stopped
{ // determine offsets of motor currents
Capacity.ActualCurrent = 0;
#define CURRENT_AVERAGE 256L // 256 * 10 ms = 2.56s average time
CurrentOffset = (uint16_t)(SumCurrentOffset/CURRENT_AVERAGE);
#define CURRENT_AVERAGE 8 // 8bit = 256 * 10 ms = 2.56s average time
CurrentOffset = (uint16_t)(SumCurrentOffset>>CURRENT_AVERAGE);
SumCurrentOffset -= CurrentOffset;
SumCurrentOffset += Current;
}
/beta/Code Redesign killagreg/fc.c
93,7 → 93,7
 
// neutral acceleration readings
int16_t AdBiasAccNick = 0, AdBiasAccRoll = 0;
volatile float AdBiasAccTop = 0;
volatile int16_t AdBiasAccTop = 0;
// the additive gyro rate corrections according to the axis coupling
int16_t TrimNick, TrimRoll;
 
1407,7 → 1407,7
DebugOut.Analog[3] = (10 * AccRoll) / ACC_DEG_FACTOR; // in 0.1 deg
DebugOut.Analog[4] = GyroYaw;
DebugOut.Analog[5] = ReadingHeight/5;
DebugOut.Analog[6] = (ReadingIntegralTop / 512);
DebugOut.Analog[6] = AdValueAccTop;//(ReadingIntegralTop / 512);//AdValueAccZ;
DebugOut.Analog[8] = CompassHeading;
DebugOut.Analog[9] = UBat;
DebugOut.Analog[10] = RC_Quality;
/beta/Code Redesign killagreg/fc.h
85,7 → 85,7
// bias values
extern int16_t BiasHiResGyroNick, BiasHiResGyroRoll, AdBiasGyroYaw;
extern int16_t AdBiasAccNick, AdBiasAccRoll;
extern volatile float AdBiasAccTop;
extern volatile int16_t AdBiasAccTop;
 
extern volatile int32_t ReadingIntegralTop; // calculated in analog.c
 
/beta/Code Redesign killagreg/jetimenu.c
18,7 → 18,7
#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_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);}
 
// -----------------------------------------------------------
/beta/Code Redesign killagreg/libfc.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/beta/Code Redesign killagreg/main.c
129,7 → 129,7
if(print)
{
Beep(3, 200);
printf(" 3 Cells ");
printf(" 3 Cells ");
}
}
else // <= 13.0V
138,7 → 138,7
if(print)
{
Beep(4, 200);
printf(" 4 Cells ");
printf(" 4 Cells ");
}
}
}
246,11 → 246,11
 
if(ParamSet.Config0 & CFG0_AIRPRESS_SENSOR)
{
printf("\n\rCalibrating air pressure sensor..");
printf("\n\rCalibrating air pressure sensor.");
timer = SetDelay(1000);
SearchAirPressureOffset();
while (!CheckDelay(timer));
printf("OK\n\r");
printf("ok\n\r");
}
 
#ifdef USE_NAVICTRL
422,6 → 422,7
}
#endif
}
 
return (1);
}
 
/beta/Code Redesign killagreg/main.h
18,6 → 18,7
extern uint16_t FlightMinutes, FlightMinutesTotal;
void LipoDetection(uint8_t print);
 
 
#endif //_MAIN_H
 
 
/beta/Code Redesign killagreg/makefile
104,8 → 104,8
 
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = 2
#OPT = s
#OPT = 2
OPT = s
 
##########################################################################################################
# List C source files here. (C dependencies are automatically generated.)
159,6 → 159,11
#CFLAGS += -std=c99
CFLAGS += -std=gnu99
 
# shrink code size
CFLAGS += -mtiny-stack
#CFLAGS += -fno-inline-functions
CFLAGS += -mcall-prologues
 
CFLAGS += -DF_CPU=$(F_CPU) -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_PATCH=$(VERSION_PATCH) -DVERSION_SERIAL_MAJOR=$(VERSION_SERIAL_MAJOR) -DVERSION_SERIAL_MINOR=$(VERSION_SERIAL_MINOR) -DNC_SPI_COMPATIBLE=$(NC_SPI_COMPATIBLE)
 
ifeq ($(EXT), MK3MAG)
271,6 → 276,7
 
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) -A $(TARGET).elf
LIMITS = $(SIZE) --mcu=atmega644 -C $(TARGET).elf
 
# Define Messages
# English
326,10 → 332,10
 
# Display size of file.
sizebefore:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); $(LIMITS); echo; fi
 
sizeafter:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); $(LIMITS); echo; fi
 
 
 
/beta/Code Redesign killagreg/menu.c
67,7 → 67,7
uint8_t MenuItem = 0;
 
 
int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World";
int8_t DisplayBuff[DISPLAYBUFFSIZE];
uint8_t DispPtr = 0;
 
 
86,6 → 86,8
 
void Menu_Update(uint8_t Keys)
{
uint8_t i, j;
 
if(Keys & KEY1)
{
if(MenuItem) MenuItem--;
96,22 → 98,15
if(MenuItem == MaxMenuItem) MenuItem = 0;
else MenuItem++;
}
if((Keys & KEY1) && (Keys & KEY2)) MenuItem = 0;
 
 
Menu_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);
}
if(MenuItem < 10) i=17;
else i=16;
LCD_printfxy(i,0,"[%i]",MenuItem);
 
switch(MenuItem)
{
121,7 → 116,7
LCD_printfxy(0,2,"Setting: %d %s", GetActiveParamSet(), Mixer.Name);
if(I2CTimeout < 6)
{
LCD_printfxy(0,3,"I2C Error!!!");
LCD_printfxy(0,3,"I2C Error!");
}
else if (MissingMotor)
{
141,59 → 136,58
{
LCD_printfxy(0,0,"Height Control");
LCD_printfxy(0,1,"DISABLED");
LCD_printfxy(0,2,"Height Control");
LCD_printfxy(0,3,"DISABLED");
}
break;
case 2:// Attitude Menu Item
LCD_printfxy(0,0,"Attitude");
LCD_printfxy(0,1,"Nick: %5i",IntegralGyroNick/1024);
LCD_printfxy(0,2,"Roll: %5i",IntegralGyroRoll/1024);
LCD_printfxy(0,3,"Heading: %5i",CompassHeading);
LCD_printfxy(0,1,"Nick: %5i",IntegralGyroNick/1024);
LCD_printfxy(0,2,"Roll: %5i",IntegralGyroRoll/1024);
LCD_printfxy(0,3,"Hdg: %5i",CompassHeading);
break;
case 3:// Remote Control Channel Menu Item
LCD_printfxy(0,0,"C1:%4i C2:%4i ",PPM_in[1],PPM_in[2]);
LCD_printfxy(0,1,"C3:%4i C4:%4i ",PPM_in[3],PPM_in[4]);
LCD_printfxy(0,2,"C5:%4i C6:%4i ",PPM_in[5],PPM_in[6]);
LCD_printfxy(0,3,"C7:%4i C8:%4i ",PPM_in[7],PPM_in[8]);
LCD_printfxy(0,0,"C1:%4i C2:%4i",PPM_in[1],PPM_in[2]);
LCD_printfxy(0,1,"C3:%4i C4:%4i",PPM_in[3],PPM_in[4]);
LCD_printfxy(0,2,"C5:%4i C6:%4i",PPM_in[5],PPM_in[6]);
LCD_printfxy(0,3,"C7:%4i C8:%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.ChannelAssignment[CH_NICK]],PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]);
LCD_printfxy(0,1,"Gs:%4i Ya:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_GAS]] + RC_GAS_OFFSET,PPM_in[ParamSet.ChannelAssignment[CH_YAW]]);
LCD_printfxy(0,2,"P1:%4i P2:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + RC_GAS_OFFSET, PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + RC_POTI_OFFSET);
LCD_printfxy(0,3,"P3:%4i P4:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + RC_POTI_OFFSET, PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + RC_POTI_OFFSET);
LCD_printfxy(0,0,"Ni:%4i Ro:%4i",PPM_in[ParamSet.ChannelAssignment[CH_NICK]],PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]);
LCD_printfxy(0,1,"Gs:%4i Ya:%4i",PPM_in[ParamSet.ChannelAssignment[CH_GAS]] + RC_GAS_OFFSET,PPM_in[ParamSet.ChannelAssignment[CH_YAW]]);
LCD_printfxy(0,2,"P1:%4i P2:%4i",PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + RC_GAS_OFFSET, PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + RC_POTI_OFFSET);
LCD_printfxy(0,3,"P3:%4i P4:%4i",PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + RC_POTI_OFFSET, PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + RC_POTI_OFFSET);
break;
case 5:// Gyro Sensor Menu Item
LCD_printfxy(0,0,"Gyro - Sensor");
switch(BoardRelease)
{
case 10:
LCD_printfxy(0,1,"Nick %4i(%3i.%i)",AdValueGyroNick - BiasHiResGyroNick / HIRES_GYRO_AMPLIFY, BiasHiResGyroNick / HIRES_GYRO_AMPLIFY, BiasHiResGyroNick % HIRES_GYRO_AMPLIFY);
LCD_printfxy(0,2,"Roll %4i(%3i.%i)",AdValueGyroRoll - BiasHiResGyroRoll / HIRES_GYRO_AMPLIFY, BiasHiResGyroRoll / HIRES_GYRO_AMPLIFY, BiasHiResGyroRoll % HIRES_GYRO_AMPLIFY);
LCD_printfxy(0,3,"Yaw %4i(%3i)",AdBiasGyroYaw - AdValueGyroYaw , AdBiasGyroYaw);
break;
 
case 11:
case 12:
case 20: // divice Offests by 2 becuse 2 samples are added in adc isr
LCD_printfxy(0,1,"Nick %4i(%3i.%i)",AdValueGyroNick - BiasHiResGyroNick/HIRES_GYRO_AMPLIFY, BiasHiResGyroNick / (HIRES_GYRO_AMPLIFY * 2), (BiasHiResGyroNick % (HIRES_GYRO_AMPLIFY * 2)) / 2); // division by 2 to push the reminder below 10 (15/2 = 7)
LCD_printfxy(0,2,"Roll %4i(%3i.%i)",AdValueGyroRoll - BiasHiResGyroRoll/HIRES_GYRO_AMPLIFY, BiasHiResGyroRoll / (HIRES_GYRO_AMPLIFY * 2), (BiasHiResGyroRoll % (HIRES_GYRO_AMPLIFY * 2)) / 2); // division by 2 to push the reminder below 10 (15/2 = 7)
LCD_printfxy(0,3,"Yaw %4i(%3i)",AdBiasGyroYaw - AdValueGyroYaw , AdBiasGyroYaw/2);
case 10:
LCD_printfxy(0,1,"Nick %4i(%3i.%i)",AdValueGyroNick - BiasHiResGyroNick / HIRES_GYRO_AMPLIFY, BiasHiResGyroNick / HIRES_GYRO_AMPLIFY, BiasHiResGyroNick % HIRES_GYRO_AMPLIFY);
LCD_printfxy(0,2,"Roll %4i(%3i.%i)",AdValueGyroRoll - BiasHiResGyroRoll / HIRES_GYRO_AMPLIFY, BiasHiResGyroRoll / HIRES_GYRO_AMPLIFY, BiasHiResGyroRoll % HIRES_GYRO_AMPLIFY);
LCD_printfxy(0,3,"Yaw %4i(%3i)",AdBiasGyroYaw - AdValueGyroYaw , AdBiasGyroYaw);
break;
 
case 13:
default: // divice Offests by 2 becuse 2 samples are added in adc isr
LCD_printfxy(0,1,"Nick %4i (%3i.%i)(%3i)",AdValueGyroNick - BiasHiResGyroNick/HIRES_GYRO_AMPLIFY, BiasHiResGyroNick / (HIRES_GYRO_AMPLIFY * 2), (BiasHiResGyroNick % (HIRES_GYRO_AMPLIFY * 2))/2, DacOffsetGyroNick); // division by 2 to push the reminder below 10 (15/2 = 7)
LCD_printfxy(0,2,"Roll %4i (%3i.%i)(%3i)",AdValueGyroRoll - BiasHiResGyroRoll/HIRES_GYRO_AMPLIFY, BiasHiResGyroRoll / (HIRES_GYRO_AMPLIFY * 2), (BiasHiResGyroRoll % (HIRES_GYRO_AMPLIFY * 2))/2, DacOffsetGyroRoll); // division by 2 to push the reminder below 10 (15/2 = 7)
LCD_printfxy(0,3,"Yaw %4i (%3i)(%3i)",AdBiasGyroYaw - AdValueGyroYaw , AdBiasGyroYaw/2, DacOffsetGyroYaw );
break;
case 11:
case 12:
case 20: // divice Offests by 2 becuse 2 samples are added in adc isr
LCD_printfxy(0,1,"Nick %4i(%3i.%i)",AdValueGyroNick - BiasHiResGyroNick/HIRES_GYRO_AMPLIFY, BiasHiResGyroNick / (HIRES_GYRO_AMPLIFY * 2), (BiasHiResGyroNick % (HIRES_GYRO_AMPLIFY * 2)) / 2); // division by 2 to push the reminder below 10 (15/2 = 7)
LCD_printfxy(0,2,"Roll %4i(%3i.%i)",AdValueGyroRoll - BiasHiResGyroRoll/HIRES_GYRO_AMPLIFY, BiasHiResGyroRoll / (HIRES_GYRO_AMPLIFY * 2), (BiasHiResGyroRoll % (HIRES_GYRO_AMPLIFY * 2)) / 2); // division by 2 to push the reminder below 10 (15/2 = 7)
LCD_printfxy(0,3,"Yaw %4i(%3i)",AdBiasGyroYaw - AdValueGyroYaw , AdBiasGyroYaw/2);
break;
 
case 13:
default: // divice Offests by 2 becuse 2 samples are added in adc isr
LCD_printfxy(0,1,"Nick %4i (%3i.%i)(%3i)",AdValueGyroNick - BiasHiResGyroNick/HIRES_GYRO_AMPLIFY, BiasHiResGyroNick / (HIRES_GYRO_AMPLIFY * 2), (BiasHiResGyroNick % (HIRES_GYRO_AMPLIFY * 2))/2, DacOffsetGyroNick); // division by 2 to push the reminder below 10 (15/2 = 7)
LCD_printfxy(0,2,"Roll %4i (%3i.%i)(%3i)",AdValueGyroRoll - BiasHiResGyroRoll/HIRES_GYRO_AMPLIFY, BiasHiResGyroRoll / (HIRES_GYRO_AMPLIFY * 2), (BiasHiResGyroRoll % (HIRES_GYRO_AMPLIFY * 2))/2, DacOffsetGyroRoll); // division by 2 to push the reminder below 10 (15/2 = 7)
LCD_printfxy(0,3,"Yaw %4i (%3i)(%3i)",AdBiasGyroYaw - AdValueGyroYaw , AdBiasGyroYaw/2, DacOffsetGyroYaw );
break;
}
 
break;
case 6:// Acceleration Sensor Menu Item
LCD_printfxy(0,0,"ACC - Sensor");
LCD_printfxy(0,1,"Nick %4i(%3i)",AdValueAccNick/2, AdBiasAccNick/2); // factor 2 because of adding 2 samples in ADC ISR
LCD_printfxy(0,2,"Roll %4i(%3i)",AdValueAccRoll/2, AdBiasAccRoll/2); // factor 2 because of adding 2 samples in ADC ISR
LCD_printfxy(0,3,"Z %4i(%3i)",AdValueAccTop, (int16_t)AdBiasAccTop);
LCD_printfxy(0,1,"Nick %4i(%3i)",AdValueAccNick/2, AdBiasAccNick/2); // factor 2 because of adding 2 samples in ADC ISR
LCD_printfxy(0,2,"Roll %4i(%3i)",AdValueAccRoll/2, AdBiasAccRoll/2); // factor 2 because of adding 2 samples in ADC ISR
LCD_printfxy(0,3,"Z %4i(%3i)",AdValueAccTop, AdBiasAccTop);
break;
case 7://Discharge
LCD_printfxy(0,0,"Battery");
226,30 → 220,37
LCD_printfxy(0,3,"Poti8: %3i" ,Poti[7]);
break;
case 12:// Servo Menu Item
LCD_printfxy(0,0,"Servo " );
LCD_printfxy(0,0,"Servo" );
LCD_printfxy(0,1,"Setpoint %3i",FCParam.ServoNickControl);
LCD_printfxy(0,2,"Position: %3i",ServoNickValue);
LCD_printfxy(0,3,"Range:%3i-%3i",ParamSet.ServoNickMin, ParamSet.ServoNickMax);
break;
case 13://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 Ya:%4i ",ExternControl.Gas, ExternControl.Yaw);
LCD_printfxy(0,3,"Hi:%4i Cf:%4i ",ExternControl.Height, ExternControl.Config);
LCD_printfxy(0,0,"ExternControl" );
LCD_printfxy(0,1,"Ni:%4i Ro:%4i",ExternControl.Nick, ExternControl.Roll);
LCD_printfxy(0,2,"Gs:%4i Ya:%4i",ExternControl.Gas, ExternControl.Yaw);
LCD_printfxy(0,3,"Hi:%4i Cf:%4i",ExternControl.Height, ExternControl.Config);
break;
 
case 14://BL Communication errors
LCD_printfxy(0,0,"BL-Ctrl Errors " );
LCD_printfxy(0,1," %3d %3d %3d %3d ",Motor[0].State & MOTOR_STATE_ERROR_MASK,Motor[1].State & MOTOR_STATE_ERROR_MASK,Motor[2].State & MOTOR_STATE_ERROR_MASK,Motor[3].State & MOTOR_STATE_ERROR_MASK);
LCD_printfxy(0,2," %3d %3d %3d %3d ",Motor[4].State & MOTOR_STATE_ERROR_MASK,Motor[5].State & MOTOR_STATE_ERROR_MASK,Motor[6].State & MOTOR_STATE_ERROR_MASK,Motor[7].State & MOTOR_STATE_ERROR_MASK);
LCD_printfxy(0,3," %3d %3d %3d %3d ",Motor[8].State & MOTOR_STATE_ERROR_MASK,Motor[9].State & MOTOR_STATE_ERROR_MASK,Motor[10].State & MOTOR_STATE_ERROR_MASK,Motor[11].State & MOTOR_STATE_ERROR_MASK);
LCD_printfxy(0,0,"BL-Ctrl Errors" );
for(i = 0; i < 3; i++)
{
j=i<<2;
LCD_printfxy(0,1+i," %3d %3d %3d %3d ",Motor[j].State & MOTOR_STATE_ERROR_MASK,Motor[1+j].State & MOTOR_STATE_ERROR_MASK,Motor[2+j].State & MOTOR_STATE_ERROR_MASK,Motor[3+j].State & MOTOR_STATE_ERROR_MASK);
}
break;
 
case 15://BL Overview
LCD_printfxy(0,0,"BL-Ctrl found " );
LCD_printfxy(0,1," %c %c %c %c ",'-' + 4 * (Motor[0].State>>7),'-' + 5 * (Motor[1].State>>7),'-' + 6 * (Motor[2].State>>7),'-' + 7 * (Motor[3].State>>7));
LCD_printfxy(0,2," %c %c %c %c ",'-' + 8 * (Motor[4].State>>7),'-' + 9 * (Motor[5].State>>7),'-' + 10 * (Motor[6].State>>7),'-' + 11 * (Motor[7].State>>7));
LCD_printfxy(0,3," %c - - - ",'-' + 12 * (Motor[8].State>>7));
LCD_printfxy(0,0,"BL-Ctrl found" );
for(i = 0; i < 2; i++)
{
j=i<<2;
LCD_printfxy(0,i+1," %c %c %c %c",'-' + 4 * (Motor[j].State>>7),'-' + 5 * (Motor[1+j].State>>7),'-' + 6 * (Motor[2+j].State>>7),'-' + 7 * (Motor[3+j].State>>7));
}
//LCD_printfxy(0,1," %c %c %c %c",'-' + 4 * (Motor[0].State>>7),'-' + 5 * (Motor[1].State>>7),'-' + 6 * (Motor[2].State>>7),'-' + 7 * (Motor[3].State>>7));
//LCD_printfxy(0,2," %c %c %c %c",'-' + 8 * (Motor[4].State>>7),'-' + 9 * (Motor[5].State>>7),'-' + 10 * (Motor[6].State>>7),'-' + 11 * (Motor[7].State>>7));
LCD_printfxy(0,3," %c - - -",'-' + 12 * (Motor[8].State>>7));
if(Motor[9].State>>7) LCD_printfxy(4,3,"10");
if(Motor[10].State>>7) LCD_printfxy(8,3,"11");
if(Motor[11].State>>7) LCD_printfxy(12,3,"12");
256,7 → 257,7
break;
 
case 16:// flight time counter
LCD_printfxy(0,0,"Flight-Time " );
LCD_printfxy(0,0,"Flight-Time");
LCD_printfxy(0,1,"Total:%5u min",FlightMinutesTotal);
LCD_printfxy(0,2,"Trip: %5u min",FlightMinutes);
LCD_printfxy(13,3,"(reset)");
/beta/Code Redesign killagreg/menu.h
6,7 → 6,7
 
#define DISPLAYBUFFSIZE 80
 
#define LCD_printfxy(x,y,format, args...) { DispPtr = y * 20 + x; _printf_P(&Menu_Putchar, PSTR(format) , ## args);}
#define LCD_printfxy(x,y,format, args...) { DispPtr = (y) * 20 + x; _printf_P(&Menu_Putchar, PSTR(format) , ## args);}
#define LCD_printf(format, args...) { _printf_P(&Menu_Putchar, PSTR(format) , ## args);}
 
#define KEY1 0x01
/beta/Code Redesign killagreg/mymath.c
40,40 → 40,3
return (c_sin_8192(90 - angle));
}
 
 
// Arcustangens returns degree in a range of +/. 180 deg
const uint8_t pgm_atanlookup[346] PROGMEM = {0,1,2,3,4,4,5,6,7,8,9,10,11,11,12,13,14,15,16,17,17,18,19,20,21,21,22,23,24,24,25,26,27,27,28,29,29,30,31,31,32,33,33,34,35,35,36,36,37,37,38,39,39,40,40,41,41,42,42,43,43,44,44,45,45,45,46,46,47,47,48,48,48,49,49,50,50,50,51,51,51,52,52,52,53,53,53,54,54,54,55,55,55,55,56,56,56,57,57,57,57,58,58,58,58,59,59,59,59,60,60,60,60,60,61,61,61,61,62,62,62,62,62,63,63,63,63,63,63,64,64,64,64,64,64,65,65,65,65,65,65,66,66,66,66,66,66,66,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,76,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79,79};
 
int16_t c_atan2(int16_t y, int16_t x)
{
int16_t index, angle;
int8_t m;
 
if (!x && !y) return 0; //atan2(0, 0) is undefined
 
if (y < 0) m = -1;
else m = 1;
 
if (!x) return (90 * m); // atan2(y,0) = +/- 90 deg
 
index = (int16_t)(((int32_t)y * 64) / x);// calculate index for lookup table
if (index < 0) index = -index;
 
if (index < 346) angle = pgm_read_byte(&pgm_atanlookup[index]); // lookup for 0 deg to 79 deg
else if (index > 7334) angle = 90; // limit is 90 deg
else if (index > 2444) angle = 89; // 89 deg to 80 deg is mapped via intervalls
else if (index > 1465) angle = 88;
else if (index > 1046) angle = 87;
else if (index > 813) angle = 86;
else if (index > 664) angle = 85;
else if (index > 561) angle = 84;
else if (index > 486) angle = 83;
else if (index > 428) angle = 82;
else if (index > 382) angle = 81;
else angle = 80; // (index>345)
 
if (x > 0) return (angle * m); // 1st and 4th quadrant
else if ((x < 0) && (m > 0)) return (180 - angle); // 2nd quadrant
else return (angle - 180); // ( (x < 0) && (y < 0)) 3rd quadrant
}
 
/beta/Code Redesign killagreg/spi.h
115,7 → 115,6
uint8_t SatFix; // type of satfix
uint16_t HomeDistance; // distance to Home in dm
int16_t HomeBearing; // bearing to home in deg
 
} __attribute__((packed)) GPSInfo_t;
 
extern GPSInfo_t GPSInfo;