public void OnGestureEvent(INuimoController controller, NuimoGestureEvent nuimoGestureEvent) { if (!IsInitialized) { controller.DisplayLedMatrixAsync(Icons.Cross); return; } switch (nuimoGestureEvent.Gesture) { case NuimoGesture.ButtonPress: var newState = SwitchGroupOnOff(); var matrix = GetPowerMatrix(newState); controller.DisplayLedMatrixAsync(matrix); break; case NuimoGesture.Rotate: var newBrightness = ChangeBrightness(nuimoGestureEvent.Value) / 255.0; var brightnessMatrix = ProgressBars.VerticalBar(newBrightness); controller.DisplayLedMatrixAsync(brightnessMatrix); break; case NuimoGesture.SwipeLeft: case NuimoGesture.SwipeRight: var newRoom = SwitchRoom(nuimoGestureEvent.Gesture); var matrixForRoom = MatrixForRoomClass(newRoom); controller.DisplayLedMatrixAsync(matrixForRoom); break; default: break; } }
public async void OnFocus(INuimoController nuimoController) { if (!IsInitialized) { nuimoController.DisplayLedMatrixAsync(NuimoBuiltinLedMatrix.Busy, 5); await SetupHue(); nuimoController.DisplayLedMatrixAsync(new NuimoLedMatrix()); } }
private async void DisplayMatrix_OnClick(object sender, RoutedEventArgs e) { try { var displayInterval = GetLedMatrixDisplayInterval(); var matrixString = GetLedMatrixString(); var options = GetLedMatrixOptions(); _nuimoController?.DisplayLedMatrixAsync(new NuimoLedMatrix(matrixString), displayInterval, options); } catch (FormatException) { await new MessageDialog("Display interval: Please enter a number between 0.00 and 25.5").ShowAsync(); } }
private void NextApp(INuimoController controller) { var currentApp = CurrentApp?.Value; if (currentApp != null) { controller.ThrottledGestureEventOccurred -= currentApp.OnGestureEvent; currentApp.OnLostFocus(controller); } else { //Set to Last so that when calling NextOrFirst, the first app will be loaded CurrentApp = Applications.Last; } var newAppNode = CurrentApp?.NextOrFirst(); var newApp = newAppNode?.Value; if (newApp != null) { controller.ThrottledGestureEventOccurred += newApp.OnGestureEvent; controller.DisplayLedMatrixAsync(newApp.Icon); newApp.OnFocus(controller); Debug.WriteLine($"Switched to {newApp.Name}"); } CurrentApp = newAppNode; }
private async Task ShowTimeoutAlert(INuimoController controller) { for (var i = 0; i < 10; i++) { var durationSeconds = 0.7; controller.DisplayLedMatrixAsync(Icons.Timer, durationSeconds, NuimoLedMatrixWriteOptions.WithoutWriteResponse); await Task.Delay(TimeSpan.FromSeconds(durationSeconds)); } }
public void OnGestureEvent(INuimoController sender, NuimoGestureEvent nuimoGestureEvent) { if (nuimoGestureEvent.Gesture == NuimoGesture.Rotate) { if (nuimoGestureEvent.Value > 0) { TestValue += 0.1; } else if (nuimoGestureEvent.Value < 0) { TestValue -= 0.1; } var progressMatrix = ProgressBars.VerticalBar(TestValue); sender.DisplayLedMatrixAsync(progressMatrix, 2, NuimoLedMatrixWriteOptions.WithFadeTransition | NuimoLedMatrixWriteOptions.WithoutWriteResponse); } if (nuimoGestureEvent.Gesture == NuimoGesture.ButtonPress) { sender.DisplayLedMatrixAsync(NuimoBuiltinLedMatrix.Busy); } Debug.WriteLine(nuimoGestureEvent.Gesture); }
private void ShowTime(INuimoController controller) { var timeDisplay = new NuimoLedMatrix(""); if (TimeLeft >= TimeSpan.FromHours(1)) { timeDisplay = timeDisplay.AddHours(TimeLeft.Hours); } if (TimeLeft >= TimeSpan.FromMinutes(1)) { timeDisplay = timeDisplay.AddMinutes(TimeLeft.Minutes); } else { timeDisplay = timeDisplay.AddSeconds(TimeLeft.Seconds); } controller?.DisplayLedMatrixAsync(timeDisplay, 2, NuimoLedMatrixWriteOptions.WithoutWriteResponse); Debug.WriteLine(TimeLeft); }