private async void DeviceIOSet_Click_1(object sender, RoutedEventArgs e) { var fx2Device = DeviceList.Current.GetSelectedDevice(); if (fx2Device == null) { rootPage.NotifyUser("Fx2 device not connected or accessible", NotifyType.ErrorMessage); return; } byte val = (byte)(DeviceIOSegmentInput.SelectedIndex + 1); byte[] input = new byte[] { Fx2Driver.DigitToSevenSegment(val) }; try { await fx2Device.SendIOControlAsync( Fx2Driver.SetSevenSegmentDisplay, input.AsBuffer(), null ); rootPage.NotifyUser("The segement display is set to " + val, NotifyType.StatusMessage); } catch (Exception exception) { rootPage.NotifyUser(exception.Message, NotifyType.ErrorMessage); } }
private async void DeviceIOGet_Click_1(object sender, RoutedEventArgs e) { var fx2Device = DeviceList.Current.GetSelectedDevice(); if (fx2Device == null) { rootPage.NotifyUser("Fx2 device not connected or accessible", NotifyType.ErrorMessage); return; } try { byte[] outputBuffer = new byte[1]; await fx2Device.SendIOControlAsync(Fx2Driver.GetSevenSegmentDisplay, null, outputBuffer.AsBuffer()); var segment = Fx2Driver.SevenSegmentToDigit(outputBuffer[0]); rootPage.NotifyUser( "The segment display value is " + segment, NotifyType.StatusMessage ); } catch (ArgumentException) { rootPage.NotifyUser( "The segment display value is not yet initialized", NotifyType.StatusMessage ); } catch (Exception exception) { rootPage.NotifyUser(exception.Message, NotifyType.ErrorMessage); return; } }