BlinkStick Pro doesn't work with my Adafruit Neopixel 8x8 Matrix

Hi folks,

I’m currently trying out my Adafruit 8x8 NeoPixel Matrix with my shiny new BlinkStick Pro, but I can’t get it to work. I soldered the wires, and everything seems okish - 5v to 5v, Gnd to Gnd, and DIn goes to the ‘R’ Pin. So - maybe I did some stupid stuff, cause I felt a bit lost, but I don’t know. I fired up the BlinkStick Client, and started the test function. Nothing happened - and again: Nothing happened. At some point, suddenly the first pixel lit up quite bright, and I couldn’t switch it off, so I disconnect the matrix and the stick.

If I connect the Stick, I see some lights on the Matrix flashing shortly and randomly in blue color - however, after realizing that I have to put the stick into the WS2812 mode, I tried the new api and compiled it by myself. I tried the “IndexedColorFrame”, and it runs through the code quite normally - but there is nothing happening on the Matrix itself.

I’m a little bit lost here right now - please help… :frowning:

//Edit: I should add that I’m using the official .NET implementation of the library.

Could you please upload the picture of your wiring? A good place to start is the command line tool I have for debugging. This will be released as a proper installer some time later.

https://www.blinkstick.com/system/releases/windows/blinkstick-command-line.zip

Just extract anywhere on your computer and use cmd.exe as it’s easier to type in commands there. This requires .NET 4.0, but works if you already have .NET 4.5.

Plug in BlinkStick and first run:

blinkstick --info

If it returns correct information about BlinkStick, then run:

blinkstick --set-mode 2

It should blink the first LED on the matrix very briefly.

After that run

blinkstick --index 3 --set-color red

And let me know if the 3rd LED lights up red.

1 Like

\O/ It’s working!!

So - I started some debugging on the example.

There are actually two problems. Let’s take the “IndexedColors” Demo as an example. First of all, the SetMode call actually gets called before the device is opened, therefore it fails silently. (An Exception would be nice. :slight_smile: ). So, when I first ran the info parameter in your debug application, it showed the device being still in mode “0”, which explained why I didn’t see anything on the matrix. It was in the wrong mode all the time.

However, that’s only half of it. On the other hand, the “SetMode” call itself throws an exception, which is thrown by HidSharp:

(I’ll try to translate the Exception - one of Microsofts biggest mistakes: Localized exceptions and stacktraces… head → wall)

Original:

Ausnahmefehler: System.IO.IOException: SetFeature failed. ---> System.ComponentModel.Win32Exception: Der Vorgang wurde erfolgreich beendet 
--- Ende der internen Ausnahmestapelüberwachung ---
bei HidSharp.Platform.Windows.WinHidStream.SetFeature(Byte[] buffer, Int32 offset, Int32 count)
bei HidSharp.HidStream.SetFeature(Byte[] buffer)
bei BlinkStickDotNet.BlinkStick.SetMode(Byte mode)
bei BlinkStick.CLI.MainClass.Main(String[] args)

In English:

Exception: System.IO.IOException: SetFeature failed. ---> System.ComponentModel.Win32Exception: The operation completed successfully. 
--- End of internal Stacktrace ---
at HidSharp.Platform.Windows.WinHidStream.SetFeature(Byte[] buffer, Int32 offset, Int32 count)
at HidSharp.HidStream.SetFeature(Byte[] buffer)
at BlinkStickDotNet.BlinkStick.SetMode(Byte mode)
at BlinkStick.CLI.MainClass.Main(String[] args)

Now, digging into the code of HidSharp, the method HidD_SetFeature is implemented as it should by the msdn, returning a boolean. And obviously, the method returns false, although it sets the mode correctly on the device (it does that.) - that’s a bit weird. However, I’ve modified the SetMode-Routine, so that it actually ignores Win32Exception with a NativeErrorCode being 0 (which means there hasn’t been a Win32 Error at all).

    public void SetMode(byte mode)
    {
        if (connectedToDriver)
        {
            try
            {
                stream.SetFeature(new byte[2] { 4, mode });
            }
            catch (IOException exception)
            {
                Win32Exception win32Exception = exception.InnerException as Win32Exception;

                if (win32Exception != null && win32Exception.NativeErrorCode == 0) return;

                throw;
            }
        }
    }

You might want to have a look at that, though, because I don’t quite understand why it returns false, although everything is fine. Hm.

I should have found that by myself, but I didn’t look at the code - I doubted my soldering skills more.^^

Thank you for your fast reply and your help. :smiley:

//Edit: Wrong code… sigh

You are right, I fixed the setMode bug in the examples and thanks for the tip to ignore the native error code 0. I’ll have a look at it. May have to add this to every feature request.

Happy coding! :smile:

1 Like