namespace Tinkerforge
{
    public static class EIMU2
    {
        public static (short Roll, short Pitch, short Heading) GetOrientation(this BrickIMUV2 imu)
        {
            imu.GetOrientation(out short heading, out short roll, out short pitch);
            return (roll, pitch, heading);
        }

        public static (short X, short Y, short Z, short W) GetQuaternion(this BrickIMUV2 imu)
        {
            imu.GetQuaternion(out short w, out short x, out short y, out short z);
            return (x, y, z, w);
        }

        public static (short X, short Y, short Z) GetLinearAcceleration(this BrickIMUV2 imu)
        {
            imu.GetLinearAcceleration(out short x, out short y, out short z);
            return (x, y, z);
        }

        public static (short X, short Y, short Z) GetGravityVector(this BrickIMUV2 imu)
        {
            imu.GetGravityVector(out short x, out short y, out short z);
            return (x, y, z);
        }

        public static (short X, short Y, short Z) GetAcceleration(this BrickIMUV2 imu)
        {
            imu.GetAcceleration(out short x, out short y, out short z);
            return (x, y, z);
        }

        public static (short X, short Y, short Z) GetMagneticField(this BrickIMUV2 imu)
        {
            imu.GetMagneticField(out short x, out short y, out short z);
            return (x, y, z);
        }

        public static (short X, short Y, short Z) GetAngularVelocity(this BrickIMUV2 imu)
        {
            imu.GetAngularVelocity(out short x, out short y, out short z);
            return (x, y, z);
        }

        public static (short[] Acceleration, short[] MagneticField, short[] AngularVelocity, short[] EulerAngle, short[]
            Quaternion, short[] LinearAcceleration, short[] GravityVector, short Temperature, byte CalibrationStatus)
            GetAllData(this BrickIMUV2 imu)
        {
            imu.GetAllData(out short[] acceleration, out short[] magneticField, out short[] angularVelocity,
                out short[] eulerAngle, out short[] quaternion, out short[] linearAcceleration,
                out short[] gravityVector, out short temperature, out byte calibrationStatus);
            return (acceleration, magneticField, angularVelocity, eulerAngle, quaternion, linearAcceleration,
                gravityVector, temperature, calibrationStatus);
        }

        public static (byte MagnetometerRate, byte GyroscopeRange, byte GyroscopeBandwidth, byte AccelerometerRange,
            byte AccelerometerBandwidth) GetSensorConfiguration(this BrickIMUV2 imu)
        {
            imu.GetSensorConfiguration(out byte magnetometerRate, out byte gyroscopeRange, out byte gyroscopeBandwidth,
                out byte accelerometerRange, out byte accelerometerBandwidth);
            return (magnetometerRate, gyroscopeRange, gyroscopeBandwidth, accelerometerRange, accelerometerBandwidth);
        }

        public static (char Port, byte ProtocolVersion, byte[] FirmwareVersion, string Name) GetProtocol1BrickletName(
            this BrickIMUV2 imu, char port)
        {
            imu.GetProtocol1BrickletName(port, out byte protocolVersion, out byte[] firmwareVersion, out string name);
            return (port, protocolVersion, firmwareVersion, name);
        }
    }
}
