Example #1
0
        public async void OnStart(object sender, IDictionary <string, object> parameters)
        {
            ProcessParameters(parameters);
            await _misty.EnableAudioServiceAsync();

            _misty.TransitionLED(255, 140, 0, 0, 0, 255, LEDTransition.Breathe, 500, null);
            _misty.Wait(3000);
            _misty.ChangeLED(0, 0, 255, null);

            //Simple example of database use to track number of runs
            await LogNumberOfRuns();

            //Load assets if they do not exist on the robot or if reloadAssets sent in
            await LoadAssets();

            //Example of using a timer to play an uploaded sound every X ms
            _playSoundTimer = new Timer(PlaySoundCallback, null, 0, 15000);

            //Example of kicking off a side thread for the text display
            _ = Task.Run(() => DisplayTextLoop());

            //Example of setting a display setting and looping through simple display changes...
            await _misty.SetImageDisplaySettingsAsync
            (
                "AssetFunLayer2",
                new ImageSettings
            {
                Stretch = ImageStretch.Fill
            }
            );

            //_misty.Wait(milliseconds) will wait (approx.) that amount of time
            //if the skill is cancelled, it will return immediately with a false boolean response
            while (_misty.Wait(5000))
            {
                await _misty.DisplayImageAsync("AssetFunSkillPumpkin1.jpg", "AssetFunLayer2", false);

                _misty.Wait(5000);
                await _misty.DisplayImageAsync("AssetFunSkillPumpkin2.jpg", "AssetFunLayer2", false);
            }
        }