コード例 #1
0
 public Task <bool> TurnOff()
 {
     using (var rpi = new WS281x(settings))
     {
         rpi.Reset();
         rpi.Dispose();
         return(Task.FromResult <bool>(true));
     }
 }
コード例 #2
0
        protected override void ProcessRecord()
        {
            if (ExplosionColor == Color.Empty)
            {
                ExplosionColor = Color.OrangeRed;
            }
            if (string.IsNullOrEmpty(Speed))
            {
                Speed = "Medium";
            }

            Settings settings = Settings.CreateDefaultSettings();

            settings.Channel = new Channel(NumberOfLeds, GpioPin, Brightness, Invert, StripType.WS2812_STRIP);
            WS281x controller = new WS281x(settings);

            int leftSideIterations = NumberOfLeds / 2;

            // If it's even, both sides will have the same amount of iterations, otherwise make right side have one more
            int rightSideIterations = (NumberOfLeds % 2 == 0) ? leftSideIterations : leftSideIterations + 1;
            int totalIterations = 0, leftSide = 0, rightSide = NumberOfLeds - 1;

            for (; totalIterations < rightSideIterations; ++totalIterations)
            {
                controller.SetLEDColor(leftSide++, LeftSideColor);
                controller.SetLEDColor(rightSide--, RightSideColor);
                controller.Render();
                Thread.Sleep(_speedTranslation[Speed]);
            }

            for (; totalIterations >= 0; --totalIterations)
            {
                controller.SetLEDColor(leftSide--, ExplosionColor);
                controller.SetLEDColor(rightSide++, ExplosionColor);
                controller.Render();
                Thread.Sleep(10);
            }

            //Thread.Sleep(_speedTranslation[Speed]);

            //controller.SetColorOnAllLEDs(ExplosionColor);
            //controller.Render();
            //for some reason it has to be explicitly disposed
            controller.Dispose();
        }
コード例 #3
0
        protected override void ProcessRecord()
        {
            Settings settings = Settings.CreateDefaultSettings();

            settings.Channel = new Channel(NumberOfLeds, GpioPin, Brightness, Invert, StripType.WS2812_STRIP);
            WS281x controller = new WS281x(settings);


            for (int i = 0; i < NumberOfLeds; ++i)
            {
                for (int j = 0; j < i; ++j)
                {
                    controller.SetLEDColor(j, Color.Empty);
                }
                controller.SetLEDColor(i, Color);
                controller.Render();
                Thread.Sleep(_speedTranslation[Speed]);
            }
            //"hack". turn the last led off
            controller.SetLEDColor(NumberOfLeds - 1, Color.Empty);
            controller.Render();
            //for some reason it has to be explicitly disposed
            controller.Dispose();
        }
コード例 #4
0
 public void Dispose()
 {
     controller.Dispose();
 }
コード例 #5
0
 protected override void ThreadFinished()
 {
     base.ThreadFinished();
     _device.Dispose();
 }
コード例 #6
0
 public void Dispose()
 {
     _controller = null;
     _device?.Dispose();
     _device = null;
 }
コード例 #7
0
 private static void Close()
 {
     app.End();
     rpi.Dispose();
     Environment.Exit(-1);
 }
コード例 #8
0
 public void Shutdown()
 {
     _ws281x?.Dispose();
 }
コード例 #9
0
ファイル: LedAgent.cs プロジェクト: d8ahazard/glimmr
 public void Dispose()
 {
     GC.SuppressFinalize(this);
     _ws281X?.Dispose();
 }
コード例 #10
0
 public void Dispose()
 {
     _device?.Reset();
     _device?.Dispose();
 }