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; }
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; } }
private void RemoveDelegates(INuimoController nuimoController) { nuimoController.GestureEventOccurred -= OnNuimoGestureEventAsync; nuimoController.FirmwareVersionRead -= OnFirmwareVersion; nuimoController.ConnectionStateChanged -= OnConnectionState; nuimoController.BatteryPercentageChanged -= OnBatteryPercentage; nuimoController.LedMatrixDisplayed -= OnLedMatrixDisplayed; }
public AvailableNuimoDevice(INuimoController controller) { Controller = controller; Controller.BatteryPercentageChanged += ControllerOnBatteryPercentageChanged; Controller.ConnectionStateChanged += Controller_ConnectionStateChanged; Controller.FirmwareVersionRead += Controller_FirmwareVersionRead; Controller.GestureEventOccurred += Controller_GestureEventOccurred; }
private void OnNuimoGestureEvent(INuimoController nuimoController, NuimoGestureEvent nuimoGestureEvent) { Debug.WriteLine("Event: " + nuimoGestureEvent.Gesture + ", " + nuimoGestureEvent.Value); if (nuimoGestureEvent.Gesture == NuimoGesture.SwipeDown) { NextApp(nuimoController); } }
public async void OnFocus(INuimoController nuimoController) { if (!IsInitialized) { nuimoController.DisplayLedMatrixAsync(NuimoBuiltinLedMatrix.Busy, 5); await SetupHue(); nuimoController.DisplayLedMatrixAsync(new NuimoLedMatrix()); } }
private async Task HandleNewNuimoController(INuimoController nuimoController) { AddDelegates(nuimoController); while (!await nuimoController.ConnectAsync()) { } nuimoController.HeartBeatInterval = TimeSpan.FromSeconds(2); NextApp(nuimoController); }
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)); } }
private async void _pairedNuimoManager_NuimoFound(INuimoController nuimoController) { var isWhiteListed = _options.WhitelistedNuimos.Any( whitelistItem => whitelistItem.DeviceId.Substring(23, 35) .Equals(nuimoController.Identifier, StringComparison.OrdinalIgnoreCase)); if (isWhiteListed) { await HandleNewNuimoController(nuimoController); } }
private void SetUnset(INuimoController controller) { if (TimerIsRunning) { StopCountdown(); } else { Timer = new Timer(ProcessCountdownTick, controller, TimeSpan.Zero, TimeSpan.FromSeconds(1)); TimerIsRunning = true; } }
public void OnGestureEvent(INuimoController sender, NuimoGestureEvent nuimoGestureEvent) { switch (nuimoGestureEvent.Gesture) { case NuimoGesture.Rotate: ChangeTime(nuimoGestureEvent.Value); ShowTime(sender); break; case NuimoGesture.ButtonPress: SetUnset(sender); break; } }
private void AddDelegates(INuimoController controller) { if (controller == null) { return; } controller.FirmwareVersionRead += OnFirmwareVersion; controller.HardwareVersionRead += OnHardwareVersion; controller.ColorRead += OnColorRead; controller.BatteryPercentageChanged += OnBatteryPercentage; controller.LedMatrixDisplayed += OnLedMatrixDisplayed; controller.GestureEventOccurred += OnNuimoGestureEvent; controller.ConnectionStateChanged += OnConnectionState; controller.HeartbeatReceived += OnHeartbeatReceived; }
public void OnGestureEvent(INuimoController sender, NuimoGestureEvent nuimoGestureEvent) { switch (nuimoGestureEvent.Gesture) { case NuimoGesture.ButtonPress: PlayPause(); break; case NuimoGesture.Rotate: ChangeVolume(nuimoGestureEvent.Value); break; case NuimoGesture.SwipeLeft: Previous(); break; case NuimoGesture.SwipeRight: Next(); break; } }
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); }
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 async void ConnectButton_OnClick(object sender, RoutedEventArgs e) { if (_nuimoControllers == null) { return; } var oldNuimoController = _nuimoController; if (oldNuimoController != null) { RemoveDelegates(oldNuimoController); } _nuimoController = _nuimoControllers.ElementAt(PairedNuimosComboBox.SelectedIndex); AddDelegates(_nuimoController); switch (_nuimoController.ConnectionState) { case NuimoConnectionState.Disconnected: await _nuimoController.ConnectAsync(); break; case NuimoConnectionState.Connected: await _nuimoController.DisconnectAsync(); break; } }
private void OnHardwareVersion(INuimoController nuimoController, string hardwareVersion) { Debug.WriteLine(hardwareVersion); }
public void OnLostFocus(INuimoController sender) { HasFocus = false; }
public void OnFocus(INuimoController sender) { HasFocus = true; }
private void Controller_ConnectionStateChanged(INuimoController arg1, NuimoConnectionState arg2) { NuimoHub.AllClients.ConnectionStateChanged(arg1.Identifier, arg2); }
private void OnColorRead(INuimoController nuimoController, NuimoColor color) { Debug.WriteLine(color); }
private void ControllerOnBatteryPercentageChanged(INuimoController nuimoController, int i) { Battery = i; NuimoHub.AllClients.BatteryPercentageChanged(nuimoController.Identifier, i); }
private void Controller_GestureEventOccurred(INuimoController arg1, NuimoGestureEvent arg2) { NuimoHub.AllClients.ConnectionStateChanged(arg1.Identifier, arg2); }
private void OnLedMatrixDisplayed(INuimoController nuimoController) { Debug.WriteLine("LED matrix displayed"); }
private void OnBatteryPercentage(INuimoController nuimoController, int batteryPercentage) { Debug.WriteLine("Battery percentage: " + batteryPercentage); }
private void OnConnectionState(INuimoController nuimoController, NuimoConnectionState nuimoConnectionState) { Debug.WriteLine("Connection state: " + nuimoConnectionState); }
private void Controller_FirmwareVersionRead(INuimoController arg1, string arg2) { NuimoHub.AllClients.ConnectionStateChanged(arg1.Identifier, arg2); }
private void OnHeartbeatReceived(INuimoController nuimoController, object heartbeatObject) { Debug.WriteLine("Heartbeat received"); }
public void OnFocus(INuimoController sender) { //throw new NotImplementedException(); }
private void OnFirmwareVersion(INuimoController nuimoController, string firmwareVersion) { Debug.WriteLine(firmwareVersion); }