Beispiel #1
0
 public async void OnButton(Nuimo nuimo, byte state)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         buttonOutput.Text = "Button state: " + state;
     });
 }
Beispiel #2
0
        // -------------- INuimoDelegate Methods ---------------------------//

        public async void OnBattery(Nuimo nuimo, byte level)
        {
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                batteryOutput.Text = "Battery: " + level + "%";
            });
        }
Beispiel #3
0
 public async void OnRotation(Nuimo nuimo, short steps)
 {
     angle += steps;
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         rotOutput.Text = "Angle: " + angle;
     });
 }
Beispiel #4
0
 public async void OnSwipe(Nuimo nuimo, byte direction)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         swipeTimer.Stop();
         swipeOutput.Text = "Swipe " + swipes[direction];
         swipeTimer.Start();
     });
 }
Beispiel #5
0
 public void RemoveNuimo(Nuimo nuimo)
 {
     if (nuimo != null)
     {
         var newOptions = _nuimoOptions;
         newOptions.WhitelistedNuimos.Remove(nuimo);
         StoreNewNuimoOptions(newOptions);
     }
 }
Beispiel #6
0
        public MainPage()
        {
            // If no Id is supplied, it will search for a Bluetooth device called nuimo.Name (default is 'Nuimo', but you can change that).
            nuimo = new Nuimo("d3b48a8b91ac");
            // e.g
            // nuimo.Name = "MyNewNuimoName";
            // Sadly, different Nuimo names are AFAIK not supported yet on the hardware.

            this.InitializeComponent();

            ApplicationView.PreferredLaunchViewSize      = new Size(480, 800);
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
        }
Beispiel #7
0
 public async void OnFly(Nuimo nuimo, byte direction, byte speed)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         swipeTimer.Stop();
         if (direction == 4) // Means close/far
         {
             swipeOutput.Text = "Hover distance: " + speed;
         }
         else
         {
             swipeOutput.Text = "Fly " + swipes[direction] + " (Speed " + speed + ").";
         }
         swipeTimer.Start();
     });
 }
        public IActionResult Delete([FromBody] Nuimo nuimo)
        {
            if (nuimo == null)
            {
                return(BadRequest("invalid nuimo object"));
            }

            if (!CheckDeviceId(nuimo.DeviceId))
            {
                return(BadRequest("invalid id"));
            }

            if (!IsKnownNuimo(nuimo.DeviceId))
            {
                return(NotFound($"Nuimo with device id {nuimo.DeviceId} is unknown."));
            }
            else
            {
                _nuimoOptionsWriter.RemoveNuimo(nuimo);
                return(Ok($"Nuimo with device id {nuimo.DeviceId} removed"));
            }
        }
        public IActionResult Post([FromBody] Nuimo nuimo)
        {
            if (nuimo == null)
            {
                return(BadRequest("invalid nuimo object"));
            }

            if (!CheckDeviceId(nuimo.DeviceId))
            {
                return(BadRequest("invalid id"));
            }

            if (!IsKnownNuimo(nuimo.DeviceId))
            {
                _nuimoOptionsWriter.AddNuimo(nuimo);
                return(Ok($"Nuimo {nuimo.Name} added"));
            }
            else
            {
                return(BadRequest($"{nuimo.Name} is already added."));
            }
        }