Color swapped LEDs

Steven, is this also going to correct the errors/crashes I’m receiving when using the module?

Thanks Gus,
i guess the Check-in by MikeIssa, to CodePlex let me to think the fixes were for the current Color Swap…
see SnapShot below:

What crash? Error?

See screenshot in reply 17.

Did you plug the socket correctly? I mean you used x socket not * socket on led?

The fix has been posted to Codeplex. All calls should now work.

http://gadgeteer.codeplex.com/SourceControl/changeset/view/13996#138454

@ ianlee74: Which socket on the module do you have the cable plugged into? The one labled " X Y * " or " * "? If it is plugged into the " * ", it will cause the exception you are experiencing. If that doesnt fix it, I will see what else I can do.

I will double check that tonight when I get home. That would make sense.

:-[ working now… Thx!

Regarding the Codeplex files… Is there any way to download the files using TFS or do we have to download a zip file everytime to get the latest versions?

You can use SVN

Hi Gus,
Thanks for the fixes…
i looked at the code ad was kind of wondering why not just do this to fix the issue:



//add the following: from your code...

        private bool m_bSwapGreenBlue = false;

       public void SwapGreenBlueValues()
        {
            m_bSwapGreenBlue = !m_bSwapGreenBlue;
        }
        public bool GetGreenBlueSwap()
        {
            return m_bSwapGreenBlue;
        }

//and replace the old functions with the following: notice the m_bSwapGreenBlue ? color1.G : color1.B
//this will be the only change to the code, no need for all the other changes...

        // Fully changes the mode, timespans and colors
        private void SendCommand(Color color1, TimeSpan blinkTime1, Color color2, TimeSpan blinkTime2, Mode mode)
        {
            long time1 = blinkTime1.Ticks / 1000;
            long time2 = blinkTime2.Ticks / 1000;

            // send the parameters with mode off to avoid side effects of previous mode
            WriteParams((byte)(DaisyLinkOffset + Registers.Configuration), (byte)Mode.Off, 0x00, color1.R, m_bSwapGreenBlue ? color1.B : color1.G, m_bSwapGreenBlue ? color1.G : color1.B, color2.R, m_bSwapGreenBlue ? color2.B : color2.G, m_bSwapGreenBlue ? color2.G : color2.B,
                (byte)(time1 >> 0), (byte)(time1 >> 8), (byte)(time1 >> 16), (byte)(time1 >> 24),
                (byte)(time2 >> 0), (byte)(time2 >> 8), (byte)(time2 >> 16), (byte)(time2 >> 24));

            // now activate the correct mode
            WriteParams((byte)(DaisyLinkOffset + Registers.Configuration), (byte)mode, 0x1);
        }


        // Writes color1 and changes the mode
        private void SendCommand(Color color, Mode mode)
        {
            // send the parameters with mode off to avoid side effects of previous mode
            WriteParams((byte)(DaisyLinkOffset + Registers.Configuration), (byte)Mode.Off, 0x0, color.R, m_bSwapGreenBlue ? color.B : color.G, m_bSwapGreenBlue ? color.G : color.B);
            // now activate the correct mode
            WriteParams((byte)(DaisyLinkOffset + Registers.Configuration), (byte)mode, 0x1);
        }



        // Writes color1 without changing the mode, unless the mode is off in which case it becomes constant
        private void SendCommand(Color color)
        {
            Mode currentMode = (Mode)Read((byte)(DaisyLinkOffset + Registers.Configuration));
            if (currentMode == Mode.Off)
            {
                WriteParams((byte)(DaisyLinkOffset + Registers.Configuration), (byte)Mode.Constant, 0x1, color.R, m_bSwapGreenBlue ? color.B : color.G, m_bSwapGreenBlue ? color.G : color.B);
            }
            else
            {
                WriteParams((byte)(DaisyLinkOffset + Registers.Color1), color.R, m_bSwapGreenBlue ? color.B : color.G, m_bSwapGreenBlue ? color.G : color.B);
            }
        }

//this produces the same results with less changes in code...

just kind of wondering if I’ve missed something doing like i did above?

thanks.

I am not the one who fixed it. I will pass this on to Steven.

cool thanks…

@ Jay Jay: Thats a way easier fix than what I did! I just did something quick that would be easy to read, easy to find and replace when there is a new fix. Never thought of doing it that way.

Glad i could help… :wink: