Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 474 → Rev 475

/trunk/main.h
14,7 → 14,7
 
#define VERSION_MAJOR 2
#define VERSION_MINOR 1
#define VERSION_PATCH 4
#define VERSION_PATCH 5
// 0 = A
// 1 = B
// 2 = C
194,6 → 194,8
u8 Error[5];
u8 StatusFlags2;
u8 FromFC_SpeakHoTT;
s16 FromFC_CompassOffset;
u8 FromFC_DisableDeclination;
} __attribute__((packed)) FC_t; // from FC
 
 
/trunk/menu.c
361,11 → 361,19
if(FC_is_Calibrated) LCD_printfxy(0,3,"Calibrated ") else LCD_printfxy(0,3,"not calibrated");
break;
case 15:
LCD_printfxy(0,0,"Ubat: %2i.%1i V", FC.BAT_Voltage/10, FC.BAT_Voltage%10);
LCD_printfxy(0,1,"Compass: %3i", Compass_Heading);
if(GeoMagDec < 0) sign = '-';
else sign = '+';
LCD_printfxy(0,2,"Mag.Declinat.:%c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
// LCD_printfxy(0,0,"Ubat: %2i.%1i V", FC.BAT_Voltage/10, FC.BAT_Voltage%10);
LCD_printfxy(0,0,"Compass: %3i", FromFlightCtrl.GyroHeading / 10);
LCD_printfxy(0,1,"Man.-Offset:%3i", FC.FromFC_CompassOffset / 10);
if(FC.FromFC_DisableDeclination)
{
LCD_printfxy(0,2,"Mag.Declinat.:disabl");
}
else
{
if(GeoMagDec < 0) sign = '-';
else sign = '+';
LCD_printfxy(0,2,"Mag.Declinat.:%c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
}
LCD_printfxy(0,3,"True Compass: %3i", GyroCompassCorrected/10);
break;
case 16: // User Parameter
464,11 → 472,12
if(I2C_CompassPort == I2C_EXTERN_0)
{
u8 tmp;
LCD_printfxy(0,1,"ACC X Y Z");
LCD_printfxy(0,2," %5d %5d %5d",AccRawVector.X,AccRawVector.Y,AccRawVector.Z);
LCD_printfxy(0,1,"ACC X Y Z");
LCD_printfxy(0,2," %5d %5d %5d",AccRawVector.X/40,AccRawVector.Y/40,AccRawVector.Z/40);
tmp = GetExtCompassOrientation();
LCD_printfxy(0,3,"Orientat.: ");
if(!tmp) LCD_printfxy(11,3,"??") else LCD_printfxy(11,3,"%2d",tmp);
LCD_printfxy(15,3,"(%d)",ExtCompassOrientation);
}
else
{
/trunk/ncmag.c
338,7 → 338,7
{
u8 msg[64];
static u8 speak = 0;
static s16 Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0;
static s16 Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0, Zmin2 = 0, Zmax2 = 0;
static s16 X = 0, Y = 0, Z = 0;
static u8 OldCalState = 0;
s16 MinCalibration = 450;
360,8 → 360,19
Zmin = 10000;
Zmax = -10000;
speak = 1;
if(Compass_CalState != OldCalState) // avoid continously writing of eeprom!
{
UART1_PutString("\r\nStarting compass calibration");
if(I2C_CompassPort == I2C_EXTERN_0)
{
if(!ExtCompassOrientation) ExtCompassOrientation = GetExtCompassOrientation();
UART1_PutString(" - External sensor ");
sprintf(msg, "with orientation: %d ",ExtCompassOrientation);
UART1_PutString(msg);
}
else UART1_PutString(" - Internal sensor");
}
break;
case 2: // 2nd step of calibration
// find Min and Max of the X- and Y-Sensors during rotation in the horizontal plane
if(X < Xmin) { Xmin = X; BeepTime = 20;}
368,6 → 379,9
else if(X > Xmax) { Xmax = X; BeepTime = 20;}
if(Y < Ymin) { Ymin = Y; BeepTime = 60;}
else if(Y > Ymax) { Ymax = Y; BeepTime = 60;}
if(Z < Zmin) { Zmin = Z; } // silent
else if(Z > Zmax) { Zmax = Z; }
 
if(speak) SpeakHoTT = SPEAK_CALIBRATE; speak = 0;
break;
 
378,8 → 392,14
 
case 4:
// find Min and Max of the Z-Sensor
if(Z < Zmin) { Zmin = Z; BeepTime = 80;}
else if(Z > Zmax) { Zmax = Z; BeepTime = 80;}
if(Z < Zmin2) { Zmin2 = Z; BeepTime = 80;}
else if(Z > Zmax2) { Zmax2 = Z; BeepTime = 80;}
if(X < Xmin) { Xmin = X; BeepTime = 20;}
else if(X > Xmax) { Xmax = X; BeepTime = 20;}
if(Y < Ymin) { Ymin = Y; BeepTime = 60;}
else if(Y > Ymax) { Ymax = Y; BeepTime = 60;}
 
if(speak) SpeakHoTT = SPEAK_CALIBRATE; speak = 0;
break;
390,13 → 410,13
switch(NCMAG_SensorType)
{
case TYPE_HMC5843:
UART1_PutString("\r\nHMC5843 calibration\n\r");
UART1_PutString("\r\nFinished: HMC5843 calibration\n\r");
MinCalibration = HMC5843_CALIBRATION_RANGE;
break;
 
case TYPE_LSM303DLH:
case TYPE_LSM303DLM:
UART1_PutString("\r\n\r\nLSM303 calibration\n\r");
UART1_PutString("\r\nFinished: LSM303 calibration\n\r");
MinCalibration = LSM303_CALIBRATION_RANGE;
break;
}
408,6 → 428,9
}
else UART1_PutString("without GPS\n\r");
 
if(Zmin2 < Zmin) { Zmin = Zmin2; }
else if(Zmax2 > Zmax) { Zmax = Zmax2; }
 
Calibration.MagX.Range = Xmax - Xmin;
Calibration.MagX.Offset = (Xmin + Xmax) / 2;
Calibration.MagY.Range = Ymax - Ymin;
556,9 → 579,12
u8 GetExtCompassOrientation(void)
{
if(I2C_CompassPort != I2C_EXTERN_0) return(0);
if(abs(FromFlightCtrl.AngleNick) > 300) return(0); // MK tilted
if(abs(FromFlightCtrl.AngleRoll) > 300) return(0);
 
if((abs(FromFlightCtrl.AngleNick) > 300) || (abs(FromFlightCtrl.AngleRoll) > 300))
{
// UART1_PutString("\r\nTilted");
return(0);
}
if(AccRawVector.Z > 3300) return(1); // Flach - Bestückung oben - Pfeil nach vorn
else
if(AccRawVector.Z < -3300) return(2); // Flach - Bestückung unten - Pfeil nach vorn
1022,7 → 1048,8
{
NCMAG_GetAccVector(10); // only the sensor with ACC is supported
ExtCompassOrientation = GetExtCompassOrientation();
if(ExtCompassOrientation) break;
if(ExtCompassOrientation && (ExtCompassOrientation == Calibration.Version / 16)) break;
//UART1_Putchar('-');
}
//DebugOut.Analog[19] = repeat;
 
1034,7 → 1061,7
UART1_PutString(msg);
if(ExtCompassOrientation != Calibration.Version / 16)
{
sprintf(msg, "\n\r! Warining: calibrated orientation was %d !",Calibration.Version / 16);
sprintf(msg, "\n\r! Warning: calibrated orientation was %d !",Calibration.Version / 16);
UART1_PutString(msg);
}
else UART1_PutString("ok");
/trunk/spi_slave.c
309,7 → 309,7
VIC_ITCmd(SSP0_ITLine, DISABLE); // disable SPI interrupt
ToFlightCtrl.CompassHeading = Compass_Heading;
DebugOut.Analog[10] = ToFlightCtrl.CompassHeading;
GyroCompassCorrected = (3600 + FromFlightCtrl.GyroHeading - GeoMagDec) % 3600;
GyroCompassCorrected = (3600 + FromFlightCtrl.GyroHeading + FC.FromFC_CompassOffset - GeoMagDec) % 3600;
if(ToFlightCtrl.CompassHeading >= 0) ToFlightCtrl.CompassHeading = (360 + ToFlightCtrl.CompassHeading + FromFlightCtrl.GyroYaw / 12) % 360;
ToFlightCtrl.MagVecX = MagVector.X;
ToFlightCtrl.MagVecY = MagVector.Y;
618,7 → 618,7
FC.BAT_Voltage = FromFlightCtrl.Param.Byte[10];
DebugOut.Analog[5] = FC.StatusFlags;
NaviData.FCStatusFlags = FC.StatusFlags;
if(FC.StatusFlags2 & FC_STATUS2_WAIT_FOR_TAKEOFF) NaviData.FCStatusFlags &= ~FC_STATUS_FLY;
if(FC.StatusFlags2 & FC_STATUS2_WAIT_FOR_TAKEOFF) NaviData.FCStatusFlags &= ~FC_STATUS_FLY;
FC.StatusFlags2 = FromFlightCtrl.Param.Byte[11];
NaviData.FCStatusFlags2 = (NaviData.FCStatusFlags2 & (FC_STATUS2_OUT1_ACTIVE | FC_STATUS2_OUT2_ACTIVE)) | (FC.StatusFlags2 & (0xff - (FC_STATUS2_OUT1_ACTIVE | FC_STATUS2_OUT2_ACTIVE)));
 
737,7 → 737,17
FC_Version.Hardware = FromFlightCtrl.Param.Byte[4];
FC.Error[0] |= FromFlightCtrl.Param.Byte[5];
FC.Error[1] |= FromFlightCtrl.Param.Byte[6];
// frei FC.Error[2] |= FromFlightCtrl.Param.Byte[7];
if(FromFlightCtrl.Param.Byte[7] >= 68 && FromFlightCtrl.Param.Byte[7] <= 188)
{
FC.FromFC_DisableDeclination = 1;
FC.FromFC_CompassOffset = 10 * (signed char) ((unsigned char) FromFlightCtrl.Param.Byte[7] - 128);
GeoMagDec = 0;
}
else
{
FC.FromFC_DisableDeclination = 0;
FC.FromFC_CompassOffset = 10 * (signed char) FromFlightCtrl.Param.Byte[7];
}
Parameter.GlobalConfig = FromFlightCtrl.Param.Byte[8];
Parameter.ExtraConfig = FromFlightCtrl.Param.Byte[9];
Parameter.OrientationAngle = FromFlightCtrl.Param.Byte[10];
/trunk/timer2.c
81,6 → 81,7
//----------------------------------------------------------------------------------------------------
void TIM2_IRQHandler(void)
{
/*
#define MULTIPLYER 4
static s16 ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center position
static s16 ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center position
175,6 → 176,7
TIM2->OC2R += pulselen;
}
IDISABLE;
*/
VIC0->VAR = 0xFF; // write any value to VIC0 Vector address register
}
 
183,7 → 185,7
//----------------------------------------------------------------------------------------------------
void TIMER2_Init(void)
{
 
/*
GPIO_InitTypeDef GPIO_InitStructure;
TIM_InitTypeDef TIM_InitStructure;
 
246,10 → 248,13
TIM_CounterCmd(TIM2, TIM_START); // start the timer
UART1_PutString("ok\r\n");
*/
}
 
void TIMER2_Deinit(void)
{
}
/*
GPIO_InitTypeDef GPIO_InitStructure;
 
UART1_PutString("\r\n Timer2 deinit...");
278,3 → 283,4
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
GPIO_Init(GPIO6, &GPIO_InitStructure);
}
*/