A sample use:
private static HMC5843 magSensor = new HMC5843(0x1E); public static void Main() { // Create a new I2C bus instance at startup. I2CBus i2cBus = I2CBus.Instance; magSensor.DirectionChanged += new HMC5843.DirectionChangedDelegate(magSensor_DirectionChanged); magSensor.StatusChanged += new HMC5843.StatusChangedDelegate(magSensor_StatusChanged); magSensor.ModeChanged += new HMC5843.ModeChangedDelegate(magSensor_ModeChanged); while (true) { magSensor.Start(); Thread.Sleep(30000); magSensor.Stop(); Thread.Sleep(30000); } } static void magSensor_ModeChanged(HMC5843.ModeBits mode) { Debug.Print("Mode Changed to " + mode.ToString()); if (mode == HMC5843.ModeBits.Idle || mode == HMC5843.ModeBits.Sleep) { LED.Write(false); } else { LED.Write(true); } } static void magSensor_StatusChanged(HMC5843.StatusBits status) { Debug.Print("Status Changed to " + status.ToString()); } static void magSensor_DirectionChanged(short X, short Y, short Z) { Debug.Print("XYZ = " + X + ", " + Y + ", " + Z); }