|
|
@ -8,22 +8,11 @@ const int universeSize = 512;
|
|
|
|
ArtnetReceiver artnet;
|
|
|
|
ArtnetReceiver artnet;
|
|
|
|
uint32_t universe0 = 0;
|
|
|
|
uint32_t universe0 = 0;
|
|
|
|
uint32_t universe1 = 1;
|
|
|
|
uint32_t universe1 = 1;
|
|
|
|
byte artnetdata[512];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ethernet stuff
|
|
|
|
// ethernet stuff
|
|
|
|
const IPAddress ip(10, 255, 255, 255);
|
|
|
|
const IPAddress ip(10, 255, 255, 255);
|
|
|
|
uint8_t mac[] = {0xAA, 0xDD, 0xBB, 0xAA, 0xDD, 0xBB};
|
|
|
|
uint8_t mac[] = {0xAA, 0xDD, 0xBB, 0xAA, 0xDD, 0xBB};
|
|
|
|
|
|
|
|
|
|
|
|
//ArtNet universe0 callback
|
|
|
|
|
|
|
|
void callback(byte* data, uint16_t size) {
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 512; ++i) {
|
|
|
|
|
|
|
|
artnetdata[i] = data[i];
|
|
|
|
|
|
|
|
//if (i == 0) analogWrite(30, data[i]);
|
|
|
|
|
|
|
|
//if (i == 1) analogWrite(8, data[i]);
|
|
|
|
|
|
|
|
//if (i == 2) analogWrite(9, data[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//NRF stuff
|
|
|
|
//NRF stuff
|
|
|
|
#include <SPI.h>
|
|
|
|
#include <SPI.h>
|
|
|
|
#include <RF24.h>
|
|
|
|
#include <RF24.h>
|
|
|
@ -34,13 +23,25 @@ RF24 radio (0, 1);
|
|
|
|
const uint16_t address = 0xADB0;
|
|
|
|
const uint16_t address = 0xADB0;
|
|
|
|
uint64_t datasend;
|
|
|
|
uint64_t datasend;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//RGB LED
|
|
|
|
|
|
|
|
const int statusLED[] = {23,22, 21}; //RGB
|
|
|
|
|
|
|
|
const int statusLEDlength = 3;
|
|
|
|
|
|
|
|
int statusLEDstat[3];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//define min interval to show error
|
|
|
|
|
|
|
|
unsigned long currentTime = millis();
|
|
|
|
|
|
|
|
unsigned long previousTime = 0;
|
|
|
|
|
|
|
|
const long waitTime = 100;
|
|
|
|
|
|
|
|
const long errorTime = 5000;
|
|
|
|
|
|
|
|
|
|
|
|
//setup
|
|
|
|
//setup
|
|
|
|
void setup() {
|
|
|
|
void setup() {
|
|
|
|
pinMode(12, OUTPUT);
|
|
|
|
for (int i=0; i < statusLEDlength; i++){
|
|
|
|
pinMode(13, OUTPUT);
|
|
|
|
pinMode(statusLED[i], OUTPUT);
|
|
|
|
pinMode(14, OUTPUT);
|
|
|
|
digitalWrite(statusLED[i], LOW);
|
|
|
|
|
|
|
|
}
|
|
|
|
pinMode(15, OUTPUT);
|
|
|
|
pinMode(10, OUTPUT);
|
|
|
|
|
|
|
|
digitalWrite(10, LOW);
|
|
|
|
|
|
|
|
|
|
|
|
//start DMX
|
|
|
|
//start DMX
|
|
|
|
DMX.begin(universeSize);
|
|
|
|
DMX.begin(universeSize);
|
|
|
@ -62,26 +63,27 @@ void setup() {
|
|
|
|
radio.disableCRC();
|
|
|
|
radio.disableCRC();
|
|
|
|
radio.stopListening();
|
|
|
|
radio.stopListening();
|
|
|
|
|
|
|
|
|
|
|
|
analogWrite(12, 20);
|
|
|
|
setRGB(0,0,255);
|
|
|
|
delay(100);
|
|
|
|
delay(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
void loop() {
|
|
|
|
//int timebegin = millis();
|
|
|
|
currentTime = millis();
|
|
|
|
|
|
|
|
if (artnet.parse()) { // check if artnet packet has come and execute callback
|
|
|
|
//get ArtNet package
|
|
|
|
previousTime = currentTime;
|
|
|
|
while(!artnet.parse());
|
|
|
|
setRGB(0,255,0);
|
|
|
|
digitalWrite(15, HIGH);
|
|
|
|
}else if(currentTime - previousTime >= errorTime){
|
|
|
|
/*if (artnet.parse()) { // check if artnet packet has come and execute callback
|
|
|
|
setRGB(255,0,0);
|
|
|
|
digitalWrite(31, HIGH);
|
|
|
|
}else if(currentTime - previousTime >= waitTime){
|
|
|
|
}*/
|
|
|
|
setRGB(0,0,255);
|
|
|
|
|
|
|
|
}
|
|
|
|
//uint64_t nrfpackage = artnetdata[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ArtNet universe0 callback
|
|
|
|
|
|
|
|
void callback(byte* artnetdata, uint16_t size) {
|
|
|
|
|
|
|
|
digitalWrite(10, HIGH);
|
|
|
|
//RGB PWM
|
|
|
|
//RGB PWM
|
|
|
|
analogWrite(12, artnetdata[0]);
|
|
|
|
//setRGB(artnetdata[0], artnetdata[1], artnetdata[2]);
|
|
|
|
analogWrite(13, artnetdata[1]);
|
|
|
|
|
|
|
|
analogWrite(14, artnetdata[2]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//DMX output
|
|
|
|
//DMX output
|
|
|
|
DMX.beginTransmission();
|
|
|
|
DMX.beginTransmission();
|
|
|
@ -89,7 +91,7 @@ void loop() {
|
|
|
|
DMX.write(i, artnetdata[i]);
|
|
|
|
DMX.write(i, artnetdata[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DMX.endTransmission();
|
|
|
|
DMX.endTransmission();
|
|
|
|
|
|
|
|
|
|
|
|
//send NRF
|
|
|
|
//send NRF
|
|
|
|
for (int i = 0; i < 20; i++) {
|
|
|
|
for (int i = 0; i < 20; i++) {
|
|
|
|
datasend = i; //package ID
|
|
|
|
datasend = i; //package ID
|
|
|
@ -99,11 +101,14 @@ void loop() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
radio.writeFast(&datasend, sizeof(datasend));
|
|
|
|
radio.writeFast(&datasend, sizeof(datasend));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
digitalWrite(10, LOW);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//int timeend = millis();
|
|
|
|
void setRGB(int r, int g, int b){
|
|
|
|
//int timeneeded = timeend - timebegin;
|
|
|
|
if (r != statusLEDstat[0]) analogWrite(statusLED[0], r);
|
|
|
|
|
|
|
|
if (g != statusLEDstat[1]) analogWrite(statusLED[1], g);
|
|
|
|
//if (timeneeded < 20) delay(20 - timeneeded);
|
|
|
|
if (b != statusLEDstat[2]) analogWrite(statusLED[2], b);
|
|
|
|
|
|
|
|
statusLEDstat[0] = r;
|
|
|
|
digitalWrite(15, LOW);
|
|
|
|
statusLEDstat[1] = g;
|
|
|
|
|
|
|
|
statusLEDstat[2] = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|