281,6 → 281,7 |
|
void NCMAG_Calibrate(void) |
{ |
u8 new = 1; |
static s16 Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0; |
static s16 X = 0, Y = 0, Z = 0; |
static u8 OldCalState = 0; |
305,20 → 306,28 |
|
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; |
else if(X > Xmax) Xmax = X; |
if(Y < Ymin) Ymin = Y; |
else if(Y > Ymax) Ymax = Y; |
if(X < Xmin) { Xmin = X; if(new) BeepTime = 20;} |
else if(X > Xmax) { Xmax = X; if(new) BeepTime = 20;} |
if(Y < Ymin) { Ymin = Y; if(new) BeepTime = 60;} |
else if(Y > Ymax) { Ymax = Y; if(new) BeepTime = 60;} |
|
if(new) |
{ |
if(Z < Zmin) { Zmin = Z; BeepTime = 100;} |
else if(Z > Zmax) { Zmax = Z; BeepTime = 100;} |
} |
|
break; |
|
case 3: // 3rd step of calibration |
// used to change the orientation of the MK3MAG vertical to the horizontal plane |
// if(new) Compass_CalState = 5; |
break; |
|
case 4: |
// find Min and Max of the Z-Sensor |
if(Z < Zmin) Zmin = Z; |
else if(Z > Zmax) Zmax = Z; |
if(Z < Zmin) { Zmin = Z; if(new) BeepTime = 80;} |
else if(Z > Zmax) { Zmax = Z; if(new) BeepTime = 80;} |
break; |
|
case 5: |
611,7 → 620,7 |
{ |
u8 msg[64]; |
|
#define LIMITS(value, min, max) {min = (90 * value)/100; max = (110 * value)/100;} |
#define LIMITS(value, min, max) {min = (80 * value)/100; max = (120 * value)/100;} |
u32 time; |
s32 XMin = 0, XMax = 0, YMin = 0, YMax = 0, ZMin = 0, ZMax = 0; |
s16 xscale, yscale, zscale, scale_min, scale_max; |