Exemplo n.º 1
0
        private async Task RunAlphaDetectedTask(CancellationToken cancelToken)
        {
            var timer = new System.Diagnostics.Stopwatch();

            timer.Start();

            try
            {
                while (!cancelToken.IsCancellationRequested)
                {
                    if (EnableLights)
                    {
                        await GpioPinManager.LightStringMaster.SetLevel(Math.Min(timer.Elapsed.Seconds, 5));
                    }

                    if (EnableMotor && timer.Elapsed.Seconds > 0)
                    {
                        GpioPinManager.HapticMotorEnable(true);
                        if (timer.Elapsed.Seconds < 5)
                        {
                            await Task.Delay(100 *timer.Elapsed.Seconds, cancelToken);

                            GpioPinManager.HapticMotorEnable(false);
                            await Task.Delay(1000 - (100 * timer.Elapsed.Seconds), cancelToken);
                        }
                    }

                    await Task.Delay(1);
                }
            }
            catch (OperationCanceledException)
            { }
        }
Exemplo n.º 2
0
 private void checkBoxHapticMotor_CheckedChanged(object sender, EventArgs e)
 {
     EnableMotor = checkBoxHapticMotor.Checked;
     if (!EnableMotor)
     {
         GpioPinManager.HapticMotorEnable(false);
     }
 }
Exemplo n.º 3
0
        async Task StopAlphaDetected()
        {
            if (AlphaCancelTokenSource != null)
            {
                AlphaCancelTokenSource.Cancel();
                await AlphaDetectedTask;
                GpioPinManager.HapticMotorEnable(false);
                AlphaCancelTokenSource = null;

                await StartLightSequence();
            }
        }