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

LXSAMD21DMX with Adafruit_NeoPixel issue on Seeed XIAO #11

Open
Shuptuu opened this issue Mar 14, 2024 · 1 comment
Open

LXSAMD21DMX with Adafruit_NeoPixel issue on Seeed XIAO #11

Shuptuu opened this issue Mar 14, 2024 · 1 comment

Comments

@Shuptuu
Copy link

Shuptuu commented Mar 14, 2024

Hi,
Looks like there's an incompatibility between LXSAMD21DMX and Adafruit_NeoPixel on Seeed Xiao Samd21.
They're both independently working but together, LXSAMD21DMX is not able to get slot values. DMX messages are received, but all slot values are stuck to 0 as soon as there's a call to strip.show(). (if you comment the strip.show() line, values are correctly received)
Could it be they're using the same timer?

Code used:

#include <LXSAMD21DMX.h>
#include <Adafruit_NeoPixel.h>

#define DMX_INPUT_PIN  D3
#define LED_PIN       A1

#define LED_COUNT     53
// NeoPixel brightness, 0 (min) to 255 (max)
#define BRIGHTNESS 50 // Set BRIGHTNESS to about 1/5 (max = 255)

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_RGBW + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

int got_dmx = 0;

void setup() {
  Serial.begin(115200);
  Serial.println("Hello!");

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(BRIGHTNESS);

  strip.setPixelColor(0,strip.Color(100,100,100,100));  // just to check Neopixel is ok
  strip.show();
  

  SAMD21DMX.setDataReceivedCallback(&gotDMXCallback);
  SAMD21DMX.startInput();

  
}

// ***************** input callback function *************

void gotDMXCallback(int slots) {
  got_dmx = slots;
}

void loop() {
  if (got_dmx){
    for (int i=0;i<LED_COUNT;i++){
      int startid=i*4+1;
      strip.setPixelColor(i, strip.Color(SAMD21DMX.getSlot(startid), SAMD21DMX.getSlot(startid+1), SAMD21DMX.getSlot(startid+2), SAMD21DMX.getSlot(startid+3)));
    }
    strip.show();
    Serial.println(SAMD21DMX.getSlot(1));
    got_dmx = 0;
  }
}
@Shuptuu
Copy link
Author

Shuptuu commented Mar 15, 2024

Adding a delay(100) just after the strip.show() seems to fix the problem...

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

1 participant