Rev 321 | Rev 329 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 321 | Rev 326 | ||
---|---|---|---|
Line 568... | Line 568... | ||
568 | static u8 send_config = 0; |
568 | static u8 send_config = 0; |
Line 569... | Line 569... | ||
569 | 569 | ||
570 | if( (I2C_State == I2C_STATE_OFF) || !NCMAG_Present ) |
570 | if( (I2C_State == I2C_STATE_OFF) || !NCMAG_Present ) |
571 | { |
571 | { |
- | 572 | Compass_Heading = -1; |
|
572 | Compass_Heading = -1; |
573 | DebugOut.Analog[14]++; // count I2C error |
573 | return; |
574 | return; |
574 | } |
- | |
575 | 575 | } |
|
576 | if(CheckDelay(TimerUpdate)) |
576 | if(CheckDelay(TimerUpdate)) |
- | 577 | { |
|
577 | { |
578 | if(Compass_Heading != -1) send_config = 0; // no re-configuration if value is valid |
578 | if(++send_config == 100) // every two seconds |
579 | if(++send_config == 25) // 500ms |
579 | { |
580 | { |
580 | send_config = 0; |
581 | send_config = 0; |
581 | MagConfig.mode = MODE_CONTINUOUS; |
582 | MagConfig.mode = MODE_CONTINUOUS; |
582 | // activate positive bias field |
583 | // activate positive bias field |
Line 587... | Line 588... | ||
587 | { |
588 | { |
588 | // check for new calibration state |
589 | // check for new calibration state |
589 | Compass_UpdateCalState(); |
590 | Compass_UpdateCalState(); |
590 | if(Compass_CalState) NCMAG_Calibrate(); |
591 | if(Compass_CalState) NCMAG_Calibrate(); |
591 | NCMAG_GetMagVector(); //Get new data; |
592 | NCMAG_GetMagVector(); //Get new data; |
592 | if(send_config == 99) TimerUpdate = SetDelay(5); // next event is the re-configuration |
593 | if(send_config == 24) TimerUpdate = SetDelay(5); // next event is the re-configuration |
593 | else TimerUpdate = SetDelay(20); // every 20 ms are 50 Hz |
594 | else TimerUpdate = SetDelay(20); // every 20 ms are 50 Hz |
594 | } |
595 | } |
595 | } |
596 | } |
596 | } |
597 | } |