maplerainresearch / MRR_ESPA

A basic 3D printer control board based on ESP32
Other
52 stars 18 forks source link

Addressable RGB LED aka NeoPixel #4

Open vivian-ng opened 4 years ago

vivian-ng commented 4 years ago

The MRR ESPA has been tested with NeoPixels. See this blog post for more details.

One issue is that the ESP32 runs on RTOS, and the Adafruit_NeoPixel library used by Marlin results in timing issues. ESP32: timing error every 1ms corrupts LED pixel data ESP32 Feather Causing Specific Neopixels to get Stuck

There are libraries out there that seem to solve this issue, such as the WS2812FX library. Getting NeoPixels to work with the MRR ESPx boards may entail rewriting the features/leds portion in the Marlin code to use the WS2812FX library, which seems to be close enough to the current Adafruit_NeoPixel library that porting should not be that much of an issue. One possibility is a kind of "wrapper" like the one mentioned here.

Maybe someone will be able to do the "porting" and report back any success. But as it is now, it does kind of work if you have only a few NeoPixels, and are willing to live with the first pixel being green on boot.

vivian-ng commented 4 years ago

For the time being, I read somewhere (forgot where) that calling show() a second time can help. So I modified the show() method in neopixel.h to:

  static inline void show() {
    adaneo1.show();
    adaneo1.show();
    #if PIN_EXISTS(NEOPIXEL2)
      #if MULTIPLE_NEOPIXEL_TYPES
        adaneo2.show();
        adaneo2.show();
      #else
        adaneo1.setPin(NEOPIXEL2_PIN);
        adaneo1.show();
        adaneo1.show();
        adaneo1.setPin(NEOPIXEL_PIN);
      #endif
    #endif
  }

It did help a bit. At least on boot up, after the initial test sequence (if it is enabled in Configuration.h), there is no residual light that remains on. But there are still times when changing colors resulted in one of the pixel/LED being a different color. Still, it is better than nothing. Not a solution, though.