Neopixel with TinyClr 2.1-rc1

I try to play with neopixel (3 leds and 8 leds modules).
I try few board(FEZ duino, SC20100 Dev and SC20260D Dev).

I have a problem with number of leds: I should set number to 9 for both !?! Is it a bug ?
Have you same behaviour, or is it just me ?

My code is:

using System;
using System.Diagnostics;
using System.Threading;
using GHIElectronics.TinyCLR.Devices.Gpio;
using GHIElectronics.TinyCLR.Devices.Signals;
using GHIElectronics.TinyCLR.Drivers.Worldsemi.WS2812;
using GHIElectronics.TinyCLR.Native;
using GHIElectronics.TinyCLR.Pins;

namespace testWs2812
{
    class Program
    {
        static void Main()
        {
            var gpio = GpioController.GetDefault();
            var digitalSignalPin = DigitalSignalPin(gpio);
            var digitalSignal = new DigitalSignal(digitalSignalPin);

            var led = new WS2812Controller(digitalSignal, 9);
            led.Clear();
            led.Flush();

            var brightness = 1;
            var delay = 1000;

            while (true)
            {
                led.Clear();
                led.SetColor(1, brightness, brightness, 0); // Middle LED is Yellow
                led.Flush();
                Thread.Sleep(delay);

                led.Clear();
                led.SetColor(0, brightness, 0, 0); // First LED is Red
                led.Flush();
                Thread.Sleep(2 * delay);

                led.Clear();
                led.SetColor(2, 0, brightness, 0); // Third LED is Green
                led.Flush();
                Thread.Sleep(2 * delay);
            }
        }

        private static GpioPin DigitalSignalPin(GpioController gpio)
        {
            switch (DeviceInformation.DeviceName)
            {
                case "SC20260": // SC20260D Dev
                    return gpio.OpenPin(SC20260.Timer.DigitalSignal.Controller2.PB3);
                case "Mp3Reader": // FEZ Duino
                    return gpio.OpenPin(SC20100.Timer.DigitalSignal.Controller2.PB3);
                case "SC20100": // SC20100S Dev
                    return gpio.OpenPin(SC20100.Timer.DigitalSignal.Controller5.PA0);
                default:
                    Debug.WriteLine("Unknown device:" + DeviceInformation.DeviceName);
                    throw new Exception("Unknown board");
            }
        }
    }
}

what do you mean? 9? What happens when you set to 1?

When I set to 1 (and change all index to 0 in code), Led is yellow, yellow and red (with 8 leds module and 3 leds module).

If I just use first led, I can set numLed to 2 and it is working.

We have made PR in last release that is probably wrong. We will check and fix

There are 2 ways to control the LEDs. One used software and one hardware. Have you tried both?

I have tried both. I think the problem is with reset: even when it’s working, it takes few times before it’s working well: led have an eratic behaviour before that.

I was looking at this yesterday and it seems that there was a change in the protocol for WS2812 elements manufactured after 2017 that require a reset >280us. I think the current drivers has a 100us reset. Could you try copy the driver and bump up the reset time and see if that does the trick?

I’ve just tried Neopixel with SC13048Q Dev: it’s working very well !
Thanks to fix this bug.

4 Likes

Or is also memory efficient if you want to drive hundreds of LEDs

1 Like