#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;
}
}