예제 #1
0
 /// <summary>
 /// Set the Axis map
 /// </summary>
 /// <param name="x">X axis setting</param>
 /// <param name="y">Y axis setting</param>
 /// <param name="z">Z axis setting</param>
 public void SetAxisMap(AxisSetting x, AxisSetting y, AxisSetting z)
 {
     SetConfigMode(true);
     WriteReg(Registers.AXIS_MAP_CONFIG, (byte)(((byte)z.Axis << 4) | ((byte)y.Axis << 2) | (byte)x.Axis));
     WriteReg(Registers.AXIS_MAP_SIGN, (byte)(((byte)z.Sign << 2) | ((byte)y.Sign << 1) | (byte)x.Sign));
     SetConfigMode(false);
 }
예제 #2
0
        /// <summary>
        /// Get the Axis map
        /// </summary>
        /// <returns>Returns an array where first element is axis X, then Y then Z</returns>
        public AxisSetting[] GetAxisMap()
        {
            SetConfigMode(true);
            var retMap  = ReadByte(Registers.AXIS_MAP_CONFIG);
            var retSign = ReadByte(Registers.AXIS_MAP_SIGN);

            AxisSetting[] axisSettings = new AxisSetting[3];
            axisSettings[0].Axis = (AxisMap)(retMap & 0x03);
            axisSettings[1].Axis = (AxisMap)((retMap >> 2) & 0x03);
            axisSettings[2].Axis = (AxisMap)((retMap >> 4) & 0x03);
            axisSettings[0].Sign = (AxisSign)(retSign & 0x01);
            axisSettings[1].Sign = (AxisSign)((retSign >> 1) & 0x01);
            axisSettings[2].Sign = (AxisSign)((retSign >> 2) & 0x01);
            SetConfigMode(false);
            return(axisSettings);
        }