Example #1
0
        public void SetDeviceOverride(ControlDevice controlDevice, CustomDeviceSpecification deviceSpec)
        {
            WLEDControlDevice csd = controlDevice as WLEDControlDevice;

            List <ControlDevice.LedUnit> leds = new List <ControlDevice.LedUnit>();

            for (int i = 0; i < deviceSpec.LedCount; i++)
            {
                ControlDevice.LedUnit newLed = new ControlDevice.LedUnit();
                newLed.Data           = new ControlDevice.LEDData();
                newLed.Data.LEDNumber = i;
                leds.Add(newLed);
            }

            controlDevice.LEDs = leds.ToArray();
        }
Example #2
0
        public void AddController(WLEDConfigModel.WLEDController controller)
        {
            WLEDControlDevice wled = new WLEDControlDevice();

            wled.Name            = controller.Name;
            wled.DeviceType      = DeviceTypes.LedStrip;
            wled.Driver          = this;
            wled.Has2DSupport    = false;
            wled.LedCount        = controller.LedCount;
            wled.ConnectedTo     = controller.ControllerType.ToUpper();
            wled.OverrideSupport = OverrideSupport.Self;
            if (wled.ConnectedTo == "ESP32")
            {
                wled.ProductImage = (Bitmap)System.Drawing.Image.FromStream(Esp32Stream);
            }
            else if (wled.ConnectedTo == "ESP8266")
            {
                wled.ProductImage = (Bitmap)System.Drawing.Image.FromStream(Esp8266Stream);
            }
            else
            {
                wled.ProductImage = (Bitmap)System.Drawing.Image.FromStream(GenericStream);
            }
            wled.Endpoint = new IPEndPoint(IPAddress.Parse(controller.IP), Int32.Parse(controller.Port));

            List <ControlDevice.LedUnit> deviceLeds = new List <ControlDevice.LedUnit>();

            for (int i = 0; i < controller.LedCount; i++)
            {
                ControlDevice.LedUnit newLed = new ControlDevice.LedUnit();
                newLed.Data           = new ControlDevice.LEDData();
                newLed.Data.LEDNumber = i;
                deviceLeds.Add(newLed);
            }

            wled.LEDs = deviceLeds.ToArray();
            DeviceAdded?.Invoke(wled, new Events.DeviceChangeEventArgs(wled));
            deviceList.Add(wled);
            var helloWorld = new List <byte>()
            {
                0x02, 0xFF, 0x00, 0xFF, 0x00
            };

            wled.Socket.SendTo(helloWorld.ToArray(), wled.Endpoint);
        }
Example #3
0
        public void Push(ControlDevice controlDevice)
        {
            WLEDControlDevice wledDevice = (WLEDControlDevice)controlDevice;

            var send_bytes = new List <byte>()
            {
                0x02, 0x1E
            };

            for (int i = 0; i < wledDevice.LEDs.Length; i++)
            {
                byte r = (byte)wledDevice.LEDs[i].Color.Red;
                send_bytes.Add(r);
                byte g = (byte)wledDevice.LEDs[i].Color.Green;
                send_bytes.Add(g);
                byte b = (byte)wledDevice.LEDs[i].Color.Blue;
                send_bytes.Add(b);
            }

            wledDevice.Socket.SendTo(send_bytes.ToArray(), wledDevice.Endpoint);
        }