Subversion Repositories NaviCtrl

Rev

Rev 271 | Rev 284 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 271 Rev 275
Line 279... Line 279...
279
}
279
}
Line 280... Line 280...
280
 
280
 
281
 
281
 
282
void NCMAG_Calibrate(void)
-
 
283
{
282
void NCMAG_Calibrate(void)
284
u8 new = 1;
283
{
285
        static s16 Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0;
284
        static s16 Xmin = 0, Xmax = 0, Ymin = 0, Ymax = 0, Zmin = 0, Zmax = 0;
Line 286... Line 285...
286
        static s16 X = 0, Y = 0, Z = 0;
285
        static s16 X = 0, Y = 0, Z = 0;
Line 304... Line 303...
304
                        Zmax = -10000;
303
                        Zmax = -10000;
305
                        break;
304
                        break;
Line 306... Line 305...
306
               
305
               
307
                case 2: // 2nd step of calibration
306
                case 2: // 2nd step of calibration
308
                        // find Min and Max of the X- and Y-Sensors during rotation in the horizontal plane
307
                        // find Min and Max of the X- and Y-Sensors during rotation in the horizontal plane
309
                        if(X < Xmin)            { Xmin = X; if(new) BeepTime = 20;}
308
                        if(X < Xmin)            { Xmin = X; BeepTime = 20;}
310
                        else if(X > Xmax)       { Xmax = X; if(new) BeepTime = 20;}
309
                        else if(X > Xmax)       { Xmax = X; BeepTime = 20;}
311
                        if(Y < Ymin)            { Ymin = Y; if(new) BeepTime = 60;}
310
                        if(Y < Ymin)            { Ymin = Y; BeepTime = 60;}
312
                        else if(Y > Ymax)       { Ymax = Y; if(new) BeepTime = 60;}
-
 
313
 
-
 
314
                        if(new)
-
 
315
                         {
-
 
316
                          if(Z < Zmin)          { Zmin = Z; BeepTime = 100;}
-
 
317
                          else if(Z > Zmax) { Zmax = Z; BeepTime = 100;}
-
 
318
                         }
-
 
319
 
311
                        else if(Y > Ymax)       { Ymax = Y; BeepTime = 60;}
Line 320... Line 312...
320
                        break;
312
                        break;
321
 
313
 
322
                case 3: // 3rd step of calibration
-
 
323
                        // used to change the orientation of the MK3MAG vertical to the horizontal plane
314
                case 3: // 3rd step of calibration
Line 324... Line 315...
324
//                      if(new) Compass_CalState = 5; 
315
                        // used to change the orientation of the MK3MAG vertical to the horizontal plane
325
                        break;
316
                        break;
326
 
317
 
327
                case 4:
318
                case 4:
328
                        // find Min and Max of the Z-Sensor
319
                        // find Min and Max of the Z-Sensor
Line 329... Line 320...
329
                        if(Z < Zmin)      { Zmin = Z; if(new) BeepTime = 80;}
320
                        if(Z < Zmin)      { Zmin = Z; BeepTime = 80;}
330
                        else if(Z > Zmax) { Zmax = Z; if(new) BeepTime = 80;}
321
                        else if(Z > Zmax) { Zmax = Z; BeepTime = 80;}
331
                        break;
322
                        break;
Line 617... Line 608...
617
 
608
 
618
// --------------------------------------------------------
609
// --------------------------------------------------------
619
u8 NCMAG_SelfTest(void)
610
u8 NCMAG_SelfTest(void)
620
{
611
{
-
 
612
        u8 msg[64];
Line -... Line 613...
-
 
613
        static u8 done = 0;
-
 
614
 
621
        u8 msg[64];
615
        if(done) return(1);
622
 
616
       
623
        #define LIMITS(value, min, max) {min = (80 * value)/100; max = (120 * value)/100;}
617
        #define LIMITS(value, min, max) {min = (80 * value)/100; max = (120 * value)/100;}
624
        u32 time;
618
        u32 time;
625
        s32 XMin = 0, XMax = 0, YMin = 0, YMax = 0, ZMin = 0, ZMax = 0;
619
        s32 XMin = 0, XMax = 0, YMin = 0, YMax = 0, ZMin = 0, ZMax = 0;
Line 712... Line 706...
712
         {
706
         {
713
          retval = 0;
707
          retval = 0;
714
      sprintf(msg, "\r\n Value Z: %d not %d-%d !", zscale, scale_min,scale_max);
708
      sprintf(msg, "\r\n Value Z: %d not %d-%d !", zscale, scale_min,scale_max);
715
          UART1_PutString(msg);
709
          UART1_PutString(msg);
716
     }
710
     }
-
 
711
        done = retval;
717
        return(retval);
712
        return(retval);
718
}
713
}
Line 719... Line 714...
719
 
714