Beispiel #1
0
        public void Configure(DriverDetails driverDetails)
        {
            cmrgb = new CMRGBController();
            Debug.WriteLine(cmrgb.getVersion());

            var ring_leds = new LedChannel[15];

            for (int r = 0; r < 5; r++)
            {
                for (int x = 0; x < 15; x++)
                {
                    ring_leds[x] = AMDWraith.LedChannel.R_RAINBOW;
                }

                Debug.WriteLine(cmrgb
                                .assign_leds_to_channels(AMDWraith.LedChannel.OFF, AMDWraith.LedChannel.OFF, ring_leds)
                                .PrettyBytes());

                Thread.Sleep(500);

                for (int x = 0; x < 15; x++)
                {
                    ring_leds[x] = AMDWraith.LedChannel.OFF;
                }

                Debug.WriteLine(cmrgb.assign_leds_to_channels(AMDWraith.LedChannel.OFF, AMDWraith.LedChannel.OFF, ring_leds).PrettyBytes());
                Thread.Sleep(500);
            }

            leds = new ControlDevice.LedUnit[15];
            for (int i = 0; i < 15; i++)
            {
                leds[i] = new ControlDevice.LedUnit
                {
                    Color   = new LEDColor(0, 0, 0),
                    LEDName = "Ring " + (i + 1)
                };
            }

            pushRequested = true;
            new Thread(() =>
            {
                Thread.CurrentThread.IsBackground = true;
                ManagePOV();
            }).Start();
        }
Beispiel #2
0
        // color_source 0x20 takes supplied color for breathe mode
        public byte[] set_channel(
            LedChannel channel,
            LedMode mode,
            byte brightness,
            byte r,
            byte g,
            byte b,
            byte speed = 255,
            byte altr  = 0,
            byte altg  = 0,
            byte altb  = 0
            )
        {
            byte color_source = 32;
            var  pkt          = new_ffpacket(255, 81, 44, 1, 0, (byte)channel, speed, color_source, (byte)mode, 255, brightness, r, g, b, altr, altg, altb);

            return(this.send_packet(pkt));
            //headless_send_packet(pkt);
        }
Beispiel #3
0
        public static bool SetFrame(this CMRGBController cmrgb, LEDColor[] leds)
        {
            LEDColor[] lowres = new LEDColor[leds.Length];
            int        lrf    = 64;

            for (int i = 0; i < leds.Length; i++)
            {
                lowres[i] = new LEDColor((byte)(leds[i].Red / lrf), (byte)(leds[i].Green / lrf), (byte)(leds[i].Blue / lrf));
            }

            List <LEDColor> uniqueColours       = new List <LEDColor>();
            List <LEDColor> uniqueColoursLowRed = new List <LEDColor>();

            for (int i = 0; i < leds.Length; i++)
            {
                if (lowres[i].Red > 0 || lowres[i].Green > 0 || lowres[i].Blue > 0)
                {
                    if (uniqueColoursLowRed.All(x =>
                                                x.Red != lowres[i].Red || x.Blue != lowres[i].Blue || x.Green != lowres[i].Blue))
                    {
                        uniqueColoursLowRed.Add(lowres[i]);
                        uniqueColours.Add(leds[i]);
                    }
                }
            }

            var  ring_leds     = new LedChannel[15];
            bool resetRequired = true;

            List <LedChannel> chnList = new List <LedChannel> {
                LedChannel.R_STATIC
            };                                                                     //, LedChannel.R_BREATHE, LedChannel.R_SWIRL };//, LedChannel.R_BREATHE };
            List <LedMode> modeList = new List <LedMode> {
                LedMode.STATIC
            };                                                           //, LedMode.BREATHE , LedMode.R_SWIRL};//, LedMode.BREATHE };

            int chnListIndex = 0;

            for (int u = 0; u < uniqueColours.Count; u++)
            {
                LEDColor uc  = uniqueColours[u];
                LEDColor ucl = uniqueColoursLowRed[u];

                if (resetRequired)
                {
                    for (int x = 0; x < 15; x++)
                    {
                        ring_leds[x] = LedChannel.OFF;
                    }

                    resetRequired = false;
                }

                int speed = 1;
                if (chnList[chnListIndex] == LedChannel.R_SWIRL)
                {
                    speed = 255;
                }
                cmrgb.set_channel(chnList[chnListIndex], modeList[chnListIndex], 255, (byte)uc.Red, (byte)uc.Green, (byte)uc.Blue, (byte)speed);
                for (int i = 0; i < leds.Length; i++)
                {
                    if (lowres[i].Red == ucl.Red && lowres[i].Green == ucl.Green && lowres[i].Blue == ucl.Blue)
                    {
                        ring_leds[i] = chnList[chnListIndex];
                    }
                }


                chnListIndex++;

                if (chnListIndex == chnList.Count || u + 1 == uniqueColours.Count)
                {
                    chnListIndex  = 0;
                    resetRequired = true;
                    cmrgb.assign_leds_to_channels(AMDWraith.LedChannel.OFF, AMDWraith.LedChannel.OFF, ring_leds);
                }
            }

            return(!(uniqueColours.Count <= chnList.Count));
        }