Example #1
0
        public void ApplyConfig(List <Color> colours,
                                ushort stepDuration,
                                bool breathingEnabled,
                                FlashingSpeed flashingSpeed)
        {
            _lighting.BatchBegin();

            foreach (byte index in Range(1, 8))
            {
                Color c = colours[index - 1];
                c.R /= 0x11; // Colour must be passed with 12-bit depth
                c.G /= 0x11;
                c.B /= 0x11;
                _lighting.SetColour(index, c);
            }

            _lighting.SetStepDuration(stepDuration);

            // Since breathing mode can't be enabled if flashing was previously enabled
            // we need to set the new flashing speed setting before trying to change breathing mode state
            _lighting.SetFlashingSpeed((Lighting.FlashingSpeed)flashingSpeed);

            _lighting.SetBreathingModeEnabled(breathingEnabled);

            _lighting.BatchEnd();
        }
Example #2
0
        private void Police_Mode_DoWork(object sender, DoWorkEventArgs e)
        {
            System.Windows.Media.Color colour;
            MSI = new Lighting(Allowed);
            int i = 0;

            while (Police)
            {
                if (i == 0)
                {
                    Convert2MSI(P_C1, out colour);
                    PoliceBTN.BackColor = P_C1;
                    i = 1;
                }
                else
                {
                    Convert2MSI(P_C2, out colour);
                    PoliceBTN.BackColor = P_C2;
                    i = 0;
                }

                MSI.BatchBegin();
                foreach (byte index in Range(1, 8))
                {
                    MSI.SetColour(index, colour);
                }
                MSI.BatchEnd();
                System.Threading.Thread.Sleep((100 / P_Speed_value) * 50);
            }
        }
Example #3
0
        public void ApplyConfig(
            byte r,
            byte g,
            byte b,
            bool breathingEnabled)
        {
            _lighting.BatchBegin();

            r /= 0x11; // Colour must be passed with 12-bit depth
            g /= 0x11;
            b /= 0x11;

            foreach (byte index in Range(1, 8))
            {
                _lighting.SetColour(index, r, g, b);
            }

            _lighting.SetStepDuration(511);

            // Since breathing mode can't be enabled if flashing was previously enabled
            // we need to set the new flashing speed setting before trying to change breathing mode state
            _lighting.SetFlashingSpeed((Lighting.FlashingSpeed)Lighting.FlashingSpeed.Disabled);

            _lighting.SetBreathingModeEnabled(breathingEnabled);

            _lighting.BatchEnd();
        }
Example #4
0
 public void BatchEnd()
 {
     if (!_lighting.BatchEnd())
     {
         throw new ScriptRuntimeException("BatchEnd was called without a matching BatchBegin");
     }
 }
Example #5
0
        public void ApplyConfig(List <Color> colours,
                                ushort stepDuration,
                                bool breathingEnabled,
                                bool invertedRChannel,
                                bool invertedGChannel,
                                bool invertedBChannel,
                                FlashingSpeed flashingSpeed)
        {
            _lighting.BatchBegin();

            foreach (byte index in Range(1, 8))
            {
                Color c = colours[index - 1];
                c.R /= 0x11; // Colour must be passed with 12-bit depth
                c.G /= 0x11;
                c.B /= 0x11;

                if (invertedRChannel) // if inverting colour channels, transform colours from
                // colour picker appropriately (which are never inverted)
                {
                    c.R = (byte)(0x0F - c.R);
                }

                if (invertedGChannel)
                {
                    c.G = (byte)(0x0F - c.G);
                }

                if (invertedBChannel)
                {
                    c.B = (byte)(0x0F - c.B);
                }

                _lighting.SetColour(index, c);
            }

            _lighting.SetStepDuration(stepDuration);

            // Since breathing mode can't be enabled if flashing was previously enabled
            // we need to set the new flashing speed setting before trying to change breathing mode state
            _lighting.SetFlashingSpeed((Lighting.FlashingSpeed)flashingSpeed);

            _lighting.SetBreathingModeEnabled(breathingEnabled);

            _lighting.SetRChannelInverted(invertedRChannel);
            _lighting.SetGChannelInverted(invertedGChannel);
            _lighting.SetBChannelInverted(invertedBChannel);

            _lighting.BatchEnd();
        }
Example #6
0
        public static void setLEDs(Color color)
        {
            color.R /= 0x11; // Colour must be passed with 12-bit depth
            color.G /= 0x11;
            color.B /= 0x11;

            lock (LEDLock) {
                light.BatchBegin();
                foreach (byte i in Enumerable.Range(1, 8))
                {
                    light.SetColour(i, color);
                }
                light.BatchEnd();
            }
        }
Example #7
0
        private void Music_Sync(object sender, DoWorkEventArgs e)
        {
            MSI = new Lighting(Allowed);
            double i = 0;

            while (Music)
            {
                int r = 0, g = 0, b = 0;
                var fftBuffer = new float[(int)FftSize.Fft128];
                if (_lineSpectrum.SpectrumProvider.GetFftData(fftBuffer, this))
                {
                    double bass = 0.0;
                    for (int z = 0; z < 8; z++)
                    {
                        bass += (fftBuffer[z] * 4);
                    }

                    bass += Sens;
                    if (bass > 1.0)
                    {
                        bass = 1.0;
                    }
                    else if (bass < 0.0)
                    {
                        bass = 0.0;
                    }

                    if (M_Rainbow)
                    {
                        HsvToRgb(i, 1, bass, out r, out g, out b);
                    }
                    else if (M_GR)
                    {
                        double val = bass * 255.0;
                        r = Convert.ToInt32(val);
                        g = 255 - Convert.ToInt32(val);
                        b = 0; // For better color effect
                    }
                    else if (M_OC)
                    {
                        r = Convert.ToInt32(OC_C.R * bass);
                        g = Convert.ToInt32(OC_C.G * bass);
                        b = Convert.ToInt32(OC_C.B * bass);
                    }
                }
                Color bcolor = Color.FromArgb(r, g, b);
                System.Windows.Media.Color colour;
                Convert2MSI(bcolor, out colour);

                Image image    = Visualizer_Image.Image;
                var   newImage = _lineSpectrum.CreateSpectrumLine(Visualizer_Image.Size, Color.FromArgb(r, g, b), Color.FromArgb(r, g, b), Color.FromArgb(0, 30, 30, 35), true);
                Music_Apply.BackColor = Color.FromArgb(r, g, b);

                if (newImage != null)
                {
                    Visualizer_Image.Image = newImage;
                    if (image != null)
                    {
                        image.Dispose();
                    }
                }

                MSI.BatchBegin();
                foreach (byte index in Range(1, 8))
                {
                    MSI.SetColour(index, colour);
                }
                MSI.BatchEnd();

                System.Threading.Thread.Sleep(50);
                if (i == 360)
                {
                    i = 0;
                    i = i + 1;
                }
                else
                {
                    i += 1;
                }
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            Lighting light;

            try
            {
                light = new Lighting(false);
                FastGetPixel fgp     = new FastGetPixel();
                int          swidth  = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size.Width;
                int          sheight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size.Height;
                while (true)
                {
                    fgp.LockWindowImage(0, 0, swidth, sheight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

                    int r = 0;
                    int g = 0;
                    int b = 0;
                    int d = 0;

                    for (int j = 0; j < sheight; j += 50)
                    {
                        for (int i = 0; i < swidth; i += 50)
                        {
                            System.Drawing.Color c1 = fgp.GetLockedPixel(i, j);
                            r += c1.R;
                            g += c1.G;
                            b += c1.B;
                            d++;
                        }
                    }

                    light.BatchBegin();

                    for (byte j = 1; j < 9; j++)
                    {
                        light.SetColour(j, Color.FromRgb((byte)(r / d / 0x11), (byte)(g / d / 0x11), (byte)(b / d / 0x11)));
                    }

                    light.BatchEnd();
                    fgp.Clear();
                    Thread.Sleep(10);
                }
            }
            catch (Lighting.Exception exc)
            {
                if (exc.GetErrorCode() == Lighting.ErrorCode.MotherboardModelNotSupported)
                {
                    Console.WriteLine("Your motherboard is not on the list of supported motherboards. " +
                                      "Attempting to use this program may cause irreversible damage to your hardware and/or personal data. " +
                                      "Are you sure you want to continue?");
                }
                else if (exc.GetErrorCode() == Lighting.ErrorCode.MotherboardVendorNotSupported)
                {
                    Console.WriteLine("Your motherboard's vendor was not detected to be MSI. MSIRGB only supports MSI motherboards. " +
                                      "To avoid damage to your hardware, MSIRGB will shutdown. " + Environment.NewLine + Environment.NewLine +
                                      "If your motherboard's vendor is MSI, " + "" +
                                      "please report this problem on the issue tracker at: https://github.com/ixjf/MSIRGB");
                }
                else if (exc.GetErrorCode() == Lighting.ErrorCode.DriverLoadFailed)
                {
                    Console.WriteLine("Failed to load driver. This could be either due to some program interfering with MSIRGB's driver, " +
                                      "or it could be a bug. Please report this on the issue tracker at: https://github.com/ixjf/MSIRGB");
                }
                else if (exc.GetErrorCode() == Lighting.ErrorCode.LoadFailed)
                {
                    Console.WriteLine("Failed to load. Please report this on the issue tracker at: https://github.com/ixjf/MSIRGB");
                }
                Console.ReadKey();
            }
        }