Rev 266 | Rev 268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 266 | Rev 267 | ||
---|---|---|---|
Line 322... | Line 322... | ||
322 | 322 | ||
323 | case 5: |
323 | case 5: |
324 | // Save values |
324 | // Save values |
325 | if(Compass_CalState != OldCalState) // avoid continously writing of eeprom! |
325 | if(Compass_CalState != OldCalState) // avoid continously writing of eeprom! |
326 | { |
326 | { |
327 | #define MIN_CALIBRATION 512 |
327 | #define MIN_CALIBRATION 256 |
328 | Calibration.MagX.Range = Xmax - Xmin; |
328 | Calibration.MagX.Range = Xmax - Xmin; |
329 | Calibration.MagX.Offset = (Xmin + Xmax) / 2; |
329 | Calibration.MagX.Offset = (Xmin + Xmax) / 2; |
330 | Calibration.MagY.Range = Ymax - Ymin; |
330 | Calibration.MagY.Range = Ymax - Ymin; |
331 | Calibration.MagY.Offset = (Ymin + Ymax) / 2; |
331 | Calibration.MagY.Offset = (Ymin + Ymax) / 2; |
Line 676... | Line 676... | ||
676 | // setup final configuration |
676 | // setup final configuration |
677 | MagConfig.cra = cra_rate|CRA_MODE_NORMAL; |
677 | MagConfig.cra = cra_rate|CRA_MODE_NORMAL; |
678 | // activate positive bias field |
678 | // activate positive bias field |
679 | NCMAG_SetMagConfig(); |
679 | NCMAG_SetMagConfig(); |
680 | // check scale for all axes |
680 | // check scale for all axes |
681 | xscale = (XMax - XMin)/(2*AVERAGE); |
- | |
682 | // prepare scale limits |
681 | // prepare scale limits |
683 | LIMITS(xscale, scale_min, scale_max); |
682 | LIMITS(xscale, scale_min, scale_max); |
- | 683 | xscale = (XMax - XMin)/(2*AVERAGE); |
|
684 | if((xscale > scale_max) || (xscale < scale_min)) |
684 | if((xscale > scale_max) || (xscale < scale_min)) |
685 | { |
685 | { |
686 | retval = 0; |
686 | retval = 0; |
687 | sprintf(msg, "\r\n Value X: %d not %d-%d !", xscale, scale_min,scale_max); |
687 | sprintf(msg, "\r\n Value X: %d not %d-%d !", xscale, scale_min,scale_max); |
688 | UART1_PutString(msg); |
688 | UART1_PutString(msg); |
689 | } |
689 | } |
690 | yscale = (YMax - YMin)/(2*AVERAGE); |
- | |
691 | LIMITS(yscale, scale_min, scale_max); |
690 | LIMITS(yscale, scale_min, scale_max); |
- | 691 | yscale = (YMax - YMin)/(2*AVERAGE); |
|
692 | if((yscale > scale_max) || (yscale < scale_min)) |
692 | if((yscale > scale_max) || (yscale < scale_min)) |
693 | { |
693 | { |
694 | retval = 0; |
694 | retval = 0; |
695 | sprintf(msg, "\r\n Value Y: %d not %d-%d !", yscale, scale_min,scale_max); |
695 | sprintf(msg, "\r\n Value Y: %d not %d-%d !", yscale, scale_min,scale_max); |
696 | UART1_PutString(msg); |
696 | UART1_PutString(msg); |
697 | } |
697 | } |
698 | zscale = (ZMax - ZMin)/(2*AVERAGE); |
- | |
699 | LIMITS(zscale, scale_min, scale_max); |
698 | LIMITS(zscale, scale_min, scale_max); |
- | 699 | zscale = (ZMax - ZMin)/(2*AVERAGE); |
|
700 | if((zscale > scale_max) || (zscale < scale_min)) |
700 | if((zscale > scale_max) || (zscale < scale_min)) |
701 | { |
701 | { |
702 | retval = 0; |
702 | retval = 0; |
703 | sprintf(msg, "\r\n Value Z: %d not %d-%d !", zscale, scale_min,scale_max); |
703 | sprintf(msg, "\r\n Value Z: %d not %d-%d !", zscale, scale_min,scale_max); |
704 | UART1_PutString(msg); |
704 | UART1_PutString(msg); |