Beispiel #1
0
        private void Button_Record(object sender, RoutedEventArgs e)
        {
            if (recordButton.Content.ToString().Equals("Start Recording"))
            {
                IRControl.StartRecording();
                recordButton.Content = "Stop Recording";
            }
            else
            {
                IRMessage msg = IRControl.EndRecording();
                recordButton.Content = "Start Recording";
                if (msg != null)
                {
                    mainText.Text  = msg.ToString() + "\n";
                    mainText.Text += msg.ParseToBits() + "\n";
                }

                else
                {
                    mainText.Text = "Nothing was recorded.";
                }
                recordedByButton = msg;
            }
        }
Beispiel #2
0
        public void OnButtonValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.RisingEdge) // Button is opposite to intuition, so that if checks 'if just pressed'
            {
                IRControl.StartRecording();
            }
            else
            {
                IRMessage msg = IRControl.EndRecording();
                string    debugString;
                if (msg != null)
                {
                    debugString  = msg.ToString() + "\n";
                    debugString += msg.ParseToBits() + "\n";
                    AzureIoTHub.SendDeviceToCloudMessageAsync("\"ProductName;Action" + DateTimeOffset.Now.ToUnixTimeMilliseconds() + "\"" + ";" + msg.Encode()).Wait();
                }
                else
                {
                    debugString = "Nothing was recorded.";
                }

                Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { mainText.Text = debugString; });
            }
        }