Rev 416 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 416 | Rev 419 | ||
---|---|---|---|
Line 731... | Line 731... | ||
731 | } |
731 | } |
732 | // -------------------------------------------------------- |
732 | // -------------------------------------------------------- |
733 | void NCMAG_Update(void) |
733 | void NCMAG_Update(void) |
734 | { |
734 | { |
735 | static u32 TimerUpdate = 0; |
735 | static u32 TimerUpdate = 0; |
736 | static u8 send_config = 0; |
736 | static s8 send_config = 0; |
737 | u32 delay = 20; |
737 | u32 delay = 20; |
Line 738... | Line 738... | ||
738 | 738 | ||
739 | if( (I2C_State == I2C_STATE_OFF) || !NCMAG_Present ) |
739 | if( (I2C_State == I2C_STATE_OFF) || !NCMAG_Present ) |
740 | { |
740 | { |
Line 745... | Line 745... | ||
745 | if(CheckDelay(TimerUpdate)) |
745 | if(CheckDelay(TimerUpdate)) |
746 | { |
746 | { |
747 | if(Compass_Heading != -1) send_config = 0; // no re-configuration if value is valid |
747 | if(Compass_Heading != -1) send_config = 0; // no re-configuration if value is valid |
748 | if(++send_config == 25) // 500ms |
748 | if(++send_config == 25) // 500ms |
749 | { |
749 | { |
750 | send_config = 0; |
750 | send_config = -25; // next try after 1 second |
751 | InitNC_MagnetSensor(); |
751 | InitNC_MagnetSensor(); |
752 | TimerUpdate = SetDelay(15); // back into the old time-slot |
752 | TimerUpdate = SetDelay(20); // back into the old time-slot |
753 | } |
753 | } |
754 | else |
754 | else |
755 | { |
755 | { |
756 | // static u8 s = 0; |
756 | // static u8 s = 0; |
757 | // check for new calibration state |
757 | // check for new calibration state |
Line 773... | Line 773... | ||
773 | else { NCMAG_GetAccVector(); s = 1;} |
773 | else { NCMAG_GetAccVector(); s = 1;} |
774 | delay = 10; |
774 | delay = 10; |
775 | */ |
775 | */ |
776 | break; |
776 | break; |
777 | } |
777 | } |
778 | if(send_config == 24) TimerUpdate = SetDelay(5); // next event is the re-configuration |
778 | if(send_config == 24) TimerUpdate = SetDelay(15); // next event is the re-configuration |
779 | else TimerUpdate = SetDelay(delay); // every 20 ms are 50 Hz |
779 | else TimerUpdate = SetDelay(delay); // every 20 ms are 50 Hz |
780 | } |
780 | } |
781 | } |
781 | } |
782 | } |
782 | } |