示例#1
0
        public void Spin()
        {
            if (_device == null)
            {
                throw new InvalidOperationException("Sphero not connected yet...");
            }

            //_device.RunMacro(FLIP_MACRO, null);

            var spinMacro = new Macro(MacroType.Temporary, 255);

            spinMacro.Commands.Add(new LoopStartMacroCommand
            {
                Count = 30
            });
            spinMacro.Commands.Add(new RotateOverTimeMacroCommand
            {
                Angle = 360,
                Time  = 200
            });
            spinMacro.Commands.Add(new DelayMacroCommand
            {
                Time = 200
            });
            spinMacro.Commands.Add(new LoopEndMacroCommand {
            });


            _device.SaveTemporaryMacro(spinMacro, response =>
            {
                if (response == MessageResponseCode.ORBOTIX_RSP_CODE_OK)
                {
                    _device.RunTemporaryMacro(code => Tracer.Trace($"RunTemporaryMacro {code}"));
                }
            });
        }
示例#2
0
        private void btnRainbow_Click(object sender, RoutedEventArgs e)
        {
            Macro rainbowMacro = new Macro(MacroType.Temporary, 255);

            rainbowMacro.Commands.Add(new LoopStartMacroCommand()
            {
                Count = 5
            });
            rainbowMacro.Commands.Add(new FadeToLEDOverTimeMacroCommand()
            {
                Red   = 0xFF,
                Green = 0,
                Blue  = 0,
                Time  = 200
            });
            rainbowMacro.Commands.Add(new DelayMacroCommand {
                Time = 200
            });
            rainbowMacro.Commands.Add(new FadeToLEDOverTimeMacroCommand()
            {
                Red   = 0xFF,
                Green = 0x7E,
                Blue  = 0x6D,
                Time  = 200
            });
            rainbowMacro.Commands.Add(new DelayMacroCommand {
                Time = 200
            });
            rainbowMacro.Commands.Add(new FadeToLEDOverTimeMacroCommand()
            {
                Red   = 0x7F,
                Green = 0xFF,
                Blue  = 0x00,
                Time  = 200
            });
            rainbowMacro.Commands.Add(new DelayMacroCommand {
                Time = 200
            });
            rainbowMacro.Commands.Add(new FadeToLEDOverTimeMacroCommand()
            {
                Red   = 0x00,
                Green = 0xFF,
                Blue  = 0x00,
                Time  = 200
            });
            rainbowMacro.Commands.Add(new DelayMacroCommand {
                Time = 200
            });
            rainbowMacro.Commands.Add(new FadeToLEDOverTimeMacroCommand()
            {
                Red   = 0xDE,
                Green = 0x00,
                Blue  = 0xFF,
                Time  = 200
            });
            rainbowMacro.Commands.Add(new DelayMacroCommand {
                Time = 200
            });
            rainbowMacro.Commands.Add(new LoopEndMacroCommand());


            _spheroDevice.SaveTemporaryMacro(rainbowMacro, response =>
            {
                if (response == MessageResponseCode.ORBOTIX_RSP_CODE_OK)
                {
                    _spheroDevice.RunTemporaryMacro(null);
                }
            });
        }