Subversion Repositories NaviCtrl

Rev

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

Rev 311 Rev 321
Line 140... Line 140...
140
        }
140
        }
141
}
141
}
Line 142... Line 142...
142
 
142
 
143
void Compass_Update(void)
143
void Compass_Update(void)
-
 
144
{
-
 
145
static s16vec_t old;  
144
{
146
static u32 check_value_counter = 0;
145
        // check for new cal state
147
        // check for new cal state
146
        Compass_UpdateCalState();
148
        Compass_UpdateCalState();
147
        // initiate new compass communication
149
        // initiate new compass communication
148
        switch(Compass_Device)
150
        switch(Compass_Device)
Line 156... Line 158...
156
                        break;
158
                        break;
157
        }
159
        }
158
        DebugOut.Analog[24] = MagVector.X;
160
        DebugOut.Analog[24] = MagVector.X;
159
        DebugOut.Analog[25] = MagVector.Y;
161
        DebugOut.Analog[25] = MagVector.Y;
160
        DebugOut.Analog[26] = MagVector.Z;
162
        DebugOut.Analog[26] = MagVector.Z;
-
 
163
    if(!((old.X == MagVector.X) || (old.Y == MagVector.Y) || (old.Z == MagVector.Z))) check_value_counter = 0; // Values are normally changing
-
 
164
 
-
 
165
        if(check_value_counter > 5000)
-
 
166
         {
-
 
167
          Compass_Heading = -1; // values didn't change for 5 seconds -> probably a compass-fault
-
 
168
         }
-
 
169
         else check_value_counter++;
-
 
170
 
-
 
171
DebugOut.Analog[16] = check_value_counter;
-
 
172
 
-
 
173
        old.X = MagVector.X;
-
 
174
        old.Y = MagVector.Y;
-
 
175
        old.Z = MagVector.Z;
161
}
176
}
Line 162... Line 177...
162
 
177
 
163
// put cal state into fifo
178
// put cal state into fifo
164
void Compass_SetCalState(u8 CalState)
179
void Compass_SetCalState(u8 CalState)