Ejemplo n.º 1
0
        public void Update(MovementMeasurement data)
        {
            if (double.IsNaN(_maxX) || data.MagX > _maxX)
            {
                _maxX = data.MagX;
            }
            if (double.IsNaN(_maxY) || data.MagY > _maxY)
            {
                _maxY = data.MagY;
            }
            if (double.IsNaN(_maxZ) || data.MagZ > _maxZ)
            {
                _maxZ = data.MagZ;
            }

            if (double.IsNaN(_minX) || data.MagX < _minX)
            {
                _minX = data.MagX;
            }
            if (double.IsNaN(_minY) || data.MagY < _minY)
            {
                _minY = data.MagY;
            }
            if (double.IsNaN(_minZ) || data.MagZ < _minZ)
            {
                _minZ = data.MagZ;
            }
        }
Ejemplo n.º 2
0
        public MovementMeasurement ConvertData(IBuffer buffer)
        {
            MovementMeasurement movement = new MovementMeasurement();
            uint dataLength = buffer.Length;

            using (DataReader reader = DataReader.FromBuffer(buffer))
            {
                if (dataLength == 18)
                {
                    short gx = Utility.ReadBigEndian16bit(reader);
                    short gy = Utility.ReadBigEndian16bit(reader);
                    short gz = Utility.ReadBigEndian16bit(reader);
                    short ax = Utility.ReadBigEndian16bit(reader);
                    short ay = Utility.ReadBigEndian16bit(reader);
                    short az = Utility.ReadBigEndian16bit(reader);
                    short mx = Utility.ReadBigEndian16bit(reader);
                    short my = Utility.ReadBigEndian16bit(reader);
                    short mz = Utility.ReadBigEndian16bit(reader);

                    movement.GyroX = ((double)gx * 500.0) / 65536.0;
                    movement.GyroY = ((double)gy * 500.0) / 65536.0;
                    movement.GyroZ = ((double)gz * 500.0) / 65536.0;

                    movement.AccelX = (((double)ax * 8.0) / 32768);
                    movement.AccelY = (((double)ay * 8.0) / 32768);
                    movement.AccelZ = (((double)az * 8.0) / 32768);

                    // on SensorTag CC2650 the conversion to micro tesla's is done in the firmware.
                    movement.MagX = (double)mx;
                    movement.MagY = (double)my;
                    movement.MagZ = (double)mz;
                }
            }
            return(movement);
        }