private async void MainPage_Loaded(object s, RoutedEventArgs e)
        {
            disconnected();

            _mqtt = new MqttClient("m11.cloudmqtt.com", 12360, false, MqttSslProtocols.None);
            _mqtt.ConnectionClosed += (sender, args) =>
            {
                disconnected();
            };
            _mqtt.MqttMsgSubscribed += (sender, args) =>
            {
                connected();
            };

            _mqtt.MqttMsgPublishReceived += (sender, args) =>
            {
                var msg = Encoding.ASCII.GetString(args.Message);

                switch (msg)
                {
                    case "happy":
                    {
                        _animator.drawFrame(0);
                    }
                    break;
                    case "sad":
                    {
                        _animator.drawFrame(1);
                    }
                    break;
                    case "indifferent":
                    {
                        _animator.drawFrame(2);
                    }
                    break;
                }

                _clear.schedule(() => _backpack.clear(), 5000);
            };

            Task.Run(() =>
            {

                _mqtt.Connect("1", "mike", "cloudmqtt");
                _mqtt.Subscribe(new[] {"mqttdotnet/pubtest/#"}, new[] {MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE});
            });

            _backpack = new Adafrut8x8LEDBackpack();
            await _backpack.initializeAsync();

            _animator = new BackpackAnimator(_backpack, EmoticonsFrameGenerator.getAnimationFrames());
        }
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            var width = this.ActualWidth;
            var height = this.ActualHeight;

            var min = Math.Min(width, height);

            var cwidth = min/8;
            for (var r = 0; r < 8; r++)
            {
                for (var c = 0; c < 8; c++)
                {
                    var ellipse = new Ellipse() {Width = cwidth, Height = cwidth};
                    grid.Children.Add(ellipse);
                    ellipse.Tag = r*8 + c;
                    ellipse.Stroke = new SolidColorBrush(Colors.White);
                    ellipse.Fill = _offBrush;
                    ellipse.PointerPressed += Ellipse_PointerPressed;
                    ellipse.SetValue(Grid.RowProperty, r);
                    ellipse.SetValue(Grid.ColumnProperty, c);
                }
            }

            _backpack = new Adafrut8x8LEDBackpack();
            await _backpack.initializeAsync();
        }
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            btnStart.IsEnabled = true;
            btnStop.IsEnabled = false;

            _backpack = new Adafrut8x8LEDBackpack();
            await _backpack.initializeAsync();
            _animator = new BackpackAnimator(_backpack, SpaceInvaderAnimationFrameGenerator.getAnimationFrames());
        }
 public BackpackAnimator(Adafrut8x8LEDBackpack backpack, AnimationFrame[] frames)
 {
     _backpack = backpack;
     _frames = frames;
 }