Esempio n. 1
0
        public async Task Rotate(double angle)
        {
            if (IsBusy)
            {
                throw new InvalidOperationException();
            }
            IsBusy = true;
            short angleShort = (short)(angle / Math.PI * 180);

            byte[] packet = new byte[4];
            packet[0] = Magic;
            packet[1] = RotateCmd;
            MyBitConverter.GetBytesBE(angleShort).CopyTo(packet, 2);
            await WriteSerialAsync(packet, 0, packet.Length);
            await ReceiveAcknowledgment();

            Angle += angle;
            IsBusy = false;
        }