Subversion Repositories MK3Mag

Compare Revisions

Ignore whitespace Rev 32 → Rev 33

/trunk/old_macros.h
File deleted
/trunk/main.lss
File deleted
/trunk/main.sym
File deleted
/trunk/main.map
File deleted
/trunk/main.c
158,7 → 158,7
void CalcHeading(void)
{
double nick_rad, roll_rad, Hx, Hy, Cx = 0.0, Cy = 0.0, Cz = 0.0;
int16_t nick, roll;
int16_t nick, roll;
int16_t heading = -1;
 
// blink code for normal operation
167,8 → 167,6
LED_GRN_TOGGLE;
Led_Timer = SetDelay(500);
}
//MagX = 150;
//MagZ = 1000;
 
switch(Orientation)
{
214,8 → 212,6
nick_rad = ((double)nick) * M_PI / (double)(1800.0);
roll_rad = ((double)roll) * M_PI / (double)(1800.0);
 
// nick_rad = 0;
// roll_rad = 0;
 
// calculate attitude correction
Hx = Cx * cos(nick_rad) - Cz * sin(nick_rad);
230,15 → 226,16
// but the compass course is defined in a range from 0 deg to 360 deg clockwise notation.
if (heading < 0) heading = -heading;
else heading = 360 - heading;
 
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
Hx = Cx * (double)cos(nick_rad) +
/* // Alternative formula
Hx = Cx * (double)cos(nick_rad) +
Cy * (double)sin(nick_rad) * (double)sin(roll_rad) -
Cz * (double)sin(nick_rad) * (double)cos(roll_rad);
Hy = Cy * (double)cos(roll_rad) +
Cz * (double)sin(nick_rad) * (double)cos(roll_rad);
 
Hy = Cy * (double)cos(roll_rad) +
Cz * (double)sin(roll_rad);
 
if(Hx == 0 && Hy < 0) heading = 90;
else if(Hx == 0 && Hy > 0) heading = 270;
else if(Hx < 0) heading = 180 - (atan(Hy / Hx) * 180.0) / M_PI;
249,11 → 246,11
*/
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
cli(); // stop interrupts
cli(); // stop interrupts
if(abs(heading) < 361) Heading = heading;
else (Heading = -1);
sei(); // start interrupts
sei(); // start interrupts
 
}
 
 
264,7 → 261,7
static int16_t Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0;
static uint8_t blinkcount = 0;
static uint8_t invert_blinking = 0;
 
// check both sources of communication for calibration request
if(I2C_WriteCal.CalByte) cal = I2C_WriteCal.CalByte;
else cal = ExternData.CalState;