コード例 #1
0
        public LedDevice(LedData ld, ColorService cs) : base(cs)
        {
            _data = ld;
            Id    = _data.Id;

            _agent = cs.ControlService.GetAgent("LedAgent");

            // We only bind and create agent for LED device 0, regardless of which one is enabled.
            // The agent will handle all the color stuff for both strips.
            if (Id == "1")
            {
                return;
            }

            Log.Debug("LED device created.");
            cs.ColorSendEventAsync += SetColors;
        }
コード例 #2
0
        public async Task Discover(CancellationToken ct, int timeout)
        {
            DataUtil.DeleteDevice("2");

            if (!SystemUtil.IsRaspberryPi())
            {
                DataUtil.DeleteDevice("0");
                DataUtil.DeleteDevice("1");
                Log.Debug("No, really, this is not a pi, we shouldn't be creating GPIO stuff here.");
                return;
            }

            var ld0 = new LedData {
                Id = "0", Brightness = 255, GpioNumber = 18, Enable = true
            };
            var ld1 = new LedData {
                Id = "1", Brightness = 255, GpioNumber = 19
            };

            await ControlService.AddDevice(ld0);

            await ControlService.AddDevice(ld1);
        }
コード例 #3
0
ファイル: LedAgent.cs プロジェクト: d8ahazard/glimmr
        private void LoadStrips(LedData d0, LedData d1)
        {
            var settings   = Settings.CreateDefaultSettings();
            var stripType0 = d0.StripType switch {
                1 => StripType.SK6812W_STRIP,
                2 => StripType.WS2811_STRIP_RBG,
                0 => StripType.WS2812_STRIP,
                _ => StripType.WS2812_STRIP
            };

            var stripType1 = d1.StripType switch {
                1 => StripType.SK6812W_STRIP,
                2 => StripType.WS2811_STRIP_RBG,
                0 => StripType.WS2812_STRIP,
                _ => StripType.WS2812_STRIP
            };

            _controller0 = settings.AddController(ControllerType.PWM0, d0.LedCount, stripType0, (byte)d0.Brightness);
            _controller1 = settings.AddController(ControllerType.PWM1, d1.LedCount, stripType1, (byte)d1.Brightness);
            _colors1     = ColorUtil.EmptyColors(d0.LedCount);
            _colors2     = ColorUtil.EmptyColors(d1.LedCount);
            _ws281X      = new WS281x(settings);
        }