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

        public async void OnBattery(Nuimo nuimo, byte level)
        {
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                batteryOutput.Text = "Battery: " + level + "%";
            });
        }
Esempio n. 3
0
 public async void OnRotation(Nuimo nuimo, short steps)
 {
     angle += steps;
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         rotOutput.Text = "Angle: " + angle;
     });
 }
Esempio n. 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();
     });
 }
Esempio n. 5
0
 public void RemoveNuimo(Nuimo nuimo)
 {
     if (nuimo != null)
     {
         var newOptions = _nuimoOptions;
         newOptions.WhitelistedNuimos.Remove(nuimo);
         StoreNewNuimoOptions(newOptions);
     }
 }
Esempio n. 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;
        }
Esempio n. 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();
     });
 }
Esempio n. 8
0
        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"));
            }
        }
Esempio n. 9
0
        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."));
            }
        }