public IMUConfiguration GetIMUConfiguration(ConfigurationType type) { SPIStream stream = spi.GetStream(); int offset; switch (type) { case ConfigurationType.Factory: offset = 0x6020; break; case ConfigurationType.User: offset = 0x8028; break; default: goto case ConfigurationType.Factory; } stream.Seek(offset, SeekOrigin.Begin); int[] data = stream.Read(0x18).ToInt16(); IMUConfiguration config = new IMUConfiguration(); config.xAcc.origin = data[0]; config.yAcc.origin = data[1]; config.zAcc.origin = data[2]; config.xAcc.sensitivity = data[3]; config.yAcc.sensitivity = data[4]; config.zAcc.sensitivity = data[5]; config.xGyro.origin = data[6]; config.yGyro.origin = data[7]; config.zGyro.origin = data[8]; config.xGyro.sensitivity = data[9]; config.yGyro.sensitivity = data[10]; config.zGyro.sensitivity = data[11]; return(config); }
public IMUInterface(NintendoController controller) : base(controller) { config = controller.GetConfig().GetIMUConfiguration(ConfigurationType.Factory); }