Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility between digiusb and Adafruit NeoPixel #4

Open
Honos2014 opened this issue Mar 31, 2015 · 5 comments
Open

Incompatibility between digiusb and Adafruit NeoPixel #4

Honos2014 opened this issue Mar 31, 2015 · 5 comments

Comments

@Honos2014
Copy link

Hello there,
I can drive a NeoPixel with the digispark with no problem.
I can use the digiUSB with ease and everything is fine.
But I cannot use both.

include <Adafruit_NeoPixel.h>

//#include <DigiUSB.h>
For the NeoPixel to work I cannot include the DigiUSB lib...
When I compiled the program with both libs it uses 58% of the ram.

Any suggestion?
Thank you

@digistump
Copy link
Collaborator

Please try the WS2812 library also included with the Digistump IDE -
NeoPixel is a ram hog and so are the USB based libraries - the WS2812
library uses very little ram and should work along side the USB

On Tue, Mar 31, 2015 at 5:24 AM, Honos2014 notifications@github.com wrote:

Hello there,
I can drive a NeoPixel with the digispark with no problem.
I can use the digiUSB with ease and everything is fine.
But I cannot use both.

#include
//#include
For the NeoPixel to work I cannot include the DigiUSB lib...
When I compiled the program with both libs it uses 58% of the ram.

Any suggestion?
Thank you


Reply to this email directly or view it on GitHub
#4.

@Honos2014
Copy link
Author

I did managed to make it run with both NeoPixel and DigiCDC. Ram doesn't seems to be the issue.
I did not find the WS2812 library, yet. I'll try when I do find it.
In the meantime, I was wondering about the setup of one of my PC being the culprit...
I will copy the all thing and test that also.
Thank you for your assistance. I'll let you know the result.

@Honos2014
Copy link
Author

I have found the ws2812 lib. Testing it...
--EDIT- Here is the code I found -----
#include <WS2811.h>
DEFINE_WS2811_FN(WS2811RGB, PORTB, 1)
RGB_t rgb[1]; //1 for 1 pixel

void setup() {
pinMode(1,OUTPUT);
}

void loop() {
setPixel(0,255,0,0); //set first pixel (zero indexed) to red
updatePixels(); //show the change
}

void setPixel(i,r,g,b){
rgb[r].r=r;
rgb[g].g=g;
rgb[b].b=b;
}

void updatePixels(){
WS2811RGB(rgb, ARRAYLEN(rgb));
}
--- It does not compile
The variables passed in setPixel are undefined... no int, uint8_t
When I define them as uint8_t the program compiles but the the Neopixel (connected to pin 1) doesnt light up, but instead the LED on the board do.

Note: In the folder of WS2812 there is a ws2812.h but no ws2812.c

@sowbug
Copy link

sowbug commented Sep 28, 2015

This happens to me, too. The repro steps are simple:

  1. Create a copy of the strandtest example from the Adafruit Neopixel library.
  2. Upload. Confirm it works fine.
  3. Anywhere in the strandtest file, even at the very end, add #include <DigiUSB.h>.
  4. Upload. Note that nothing works anymore.

I thought that the mere inclusion of a .h meant that DigiUSB.h was redefining something that conflicted with the NeoPixel library. But then I noticed that the .h externs an instance of the DigiUSBDevice class, which contains two monstrously large ring buffers. An an experiment I tried changing #define RING_BUFFER_SIZE 128 to #define RING_BUFFER_SIZE (64), restarted the Arduino application to get it to notice library changes, and found that both libraries now worked together. At this point I searched the web, found this page, and confirmed what @digistump already said earlier in this issue.

For my application, I'm using just one WS2812, so expect that I've already shrunk the NeoPixel instance as much as I can.

I don't yet understand the ramifications of a smaller ring buffer. I bet it has to do with dropped characters if my application doesn't read the buffer frequently enough (on either side). I think this is OK in my case, but it might be annoying in other cases.

TL;DR: try shrinking the DigiUSB ring buffer sizes if you're getting conflicts.

@AidenRay
Copy link

In case anyone finds this still relevant, I had the same issue.
By using the WS2812 library, and reducing the ring buffer size to 64, the problem was solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants