Rev 287 | Rev 292 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 287 | Rev 288 | ||
---|---|---|---|
Line 155... | Line 155... | ||
155 | } |
155 | } |
Line 156... | Line 156... | ||
156 | 156 | ||
157 | //---------------------------------------------------------------- |
157 | //---------------------------------------------------------------- |
158 | void MK3MAG_SendCommand(u8 command) |
158 | void MK3MAG_SendCommand(u8 command) |
159 | { |
159 | { |
160 | // trya to catch the I2C buffer |
160 | // try to catch the I2C buffer |
161 | if(I2C_LockBuffer(0)) |
161 | if(I2C_LockBuffer(0)) |
162 | { |
162 | { |
163 | u16 TxBytes = 0; |
163 | u16 TxBytes = 0; |
164 | u16 RxBytes = 0; |
164 | u16 RxBytes = 0; |
Line 277... | Line 277... | ||
277 | x_max = -30000; y_max = -30000; z_max = -30000; |
277 | x_max = -30000; y_max = -30000; z_max = -30000; |
278 | x_min = 30000; y_min = 30000; z_min = 30000; |
278 | x_min = 30000; y_min = 30000; z_min = 30000; |
279 | } |
279 | } |
280 | if(MK3MAG_WriteCal.CalByte == 2) |
280 | if(MK3MAG_WriteCal.CalByte == 2) |
281 | { |
281 | { |
282 | Compass_UpdateMagVector(); |
282 | MK3MAG_SendCommand(MK3MAG_CMD_READ_MAGVECT); |
283 | if(MagVector.X > x_max) { x_max = MagVector.X; BeepTime = 30; }; |
283 | if(MagVector.X > x_max) { x_max = MagVector.X; BeepTime = 30; }; |
284 | if(MagVector.Y > y_max) { y_max = MagVector.Y; BeepTime = 30; }; |
284 | if(MagVector.Y > y_max) { y_max = MagVector.Y; BeepTime = 30; }; |
285 | if(MagVector.X < x_min) { x_min = MagVector.X; BeepTime = 30; }; |
285 | if(MagVector.X < x_min) { x_min = MagVector.X; BeepTime = 30; }; |
286 | if(MagVector.Y < y_min) { y_min = MagVector.Y; BeepTime = 30; }; |
286 | if(MagVector.Y < y_min) { y_min = MagVector.Y; BeepTime = 30; }; |
287 | } |
287 | } |
288 | if(MK3MAG_WriteCal.CalByte == 4) |
288 | if(MK3MAG_WriteCal.CalByte == 4) |
289 | { |
289 | { |
290 | Compass_UpdateMagVector(); |
290 | MK3MAG_SendCommand(MK3MAG_CMD_READ_MAGVECT); |
291 | if(MagVector.Z > z_max) { z_max = MagVector.Z; BeepTime = 30; }; |
291 | if(MagVector.Z > z_max) { z_max = MagVector.Z; BeepTime = 30; }; |
292 | if(MagVector.Z < z_min) { z_min = MagVector.Z; BeepTime = 30; }; |
292 | if(MagVector.Z < z_min) { z_min = MagVector.Z; BeepTime = 30; }; |
293 | } |
293 | } |
294 | else // request current heading |
294 | else // request current heading |
295 | { |
295 | { |
296 | MK3MAG_SendCommand(MK3MAG_CMD_READ_HEADING); |
296 | MK3MAG_SendCommand(MK3MAG_CMD_READ_HEADING); |
297 | } |
297 | } |