|
|
@ -6,15 +6,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
//Ethernet
|
|
|
|
//Ethernet
|
|
|
|
byte mac[] = {0xAA, 0xDD, 0xBB, 0x10, 0x01, 0x01};
|
|
|
|
byte mac[] = {0xAA, 0xDD, 0xBB, 0x10, 0x01, 0x01};
|
|
|
|
IPAddress ip(192, 168, 0, 20);
|
|
|
|
IPAddress ip(192, 168, 178, 30);
|
|
|
|
|
|
|
|
|
|
|
|
//IP of the ATEM switcher
|
|
|
|
//IP of the ATEM switcher
|
|
|
|
ATEM AtemSwitcher(IPAddress(192, 168, 0, 50), 56417);
|
|
|
|
ATEM AtemSwitcher(IPAddress(192, 168, 178, 20), 56417);
|
|
|
|
|
|
|
|
|
|
|
|
//tally LEDs
|
|
|
|
//tally LEDs
|
|
|
|
const int tallyLED[] = {2,3};
|
|
|
|
const int tallyLED[] = {2,3,4,5};
|
|
|
|
const int tallyLEDlength = 2;
|
|
|
|
const int tallyLEDlength = 4;
|
|
|
|
boolean tallyLEDstat[2];
|
|
|
|
boolean tallyLEDstat[4];
|
|
|
|
|
|
|
|
|
|
|
|
//init NRF
|
|
|
|
//init NRF
|
|
|
|
RF24 radio (7, 8);
|
|
|
|
RF24 radio (7, 8);
|
|
|
@ -37,12 +37,15 @@ void setup(){
|
|
|
|
|
|
|
|
|
|
|
|
//start Serial
|
|
|
|
//start Serial
|
|
|
|
Serial.begin(9600);
|
|
|
|
Serial.begin(9600);
|
|
|
|
|
|
|
|
Serial.println("start serial");
|
|
|
|
|
|
|
|
|
|
|
|
//connect to the switcher
|
|
|
|
//connect to the switcher
|
|
|
|
|
|
|
|
Serial.println("connect to ATEM");
|
|
|
|
AtemSwitcher.serialOutput(true);
|
|
|
|
AtemSwitcher.serialOutput(true);
|
|
|
|
AtemSwitcher.connect();
|
|
|
|
AtemSwitcher.connect();
|
|
|
|
|
|
|
|
|
|
|
|
//start NRF
|
|
|
|
//start NRF
|
|
|
|
|
|
|
|
Serial.println("start NRF");
|
|
|
|
radio.begin();
|
|
|
|
radio.begin();
|
|
|
|
radio.openWritingPipe(address);
|
|
|
|
radio.openWritingPipe(address);
|
|
|
|
radio.setPALevel(RF24_PA_MIN);
|
|
|
|
radio.setPALevel(RF24_PA_MIN);
|
|
|
@ -59,11 +62,11 @@ void loop(){
|
|
|
|
//check for new packages
|
|
|
|
//check for new packages
|
|
|
|
AtemSwitcher.runLoop();
|
|
|
|
AtemSwitcher.runLoop();
|
|
|
|
|
|
|
|
|
|
|
|
previousTime = currentTime;
|
|
|
|
|
|
|
|
currentTime = millis();
|
|
|
|
currentTime = millis();
|
|
|
|
|
|
|
|
if (dataChanged() || currentTime - previousTime >= intervalTime){
|
|
|
|
if (dataChanged() || currentTime - previousTime >= intervalTime)
|
|
|
|
|
|
|
|
sendNRF();
|
|
|
|
sendNRF();
|
|
|
|
|
|
|
|
previousTime = currentTime;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sendNRF(){
|
|
|
|
void sendNRF(){
|
|
|
@ -72,24 +75,27 @@ void sendNRF(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
datasend = datasend << (8 - tallyLEDlength);
|
|
|
|
datasend = datasend << (8 - tallyLEDlength);
|
|
|
|
datasend = (datasend << 8) + getChecksum(datasend & 0xFF);
|
|
|
|
datasend = (datasend << 8) + getChecksum(datasend & 0xFF);
|
|
|
|
|
|
|
|
Serial.print(" datasend: ");
|
|
|
|
|
|
|
|
Serial.println(datasend, BIN);
|
|
|
|
|
|
|
|
|
|
|
|
radio.writeFast(&datasend, sizeof(datasend));
|
|
|
|
radio.writeFast(&datasend, sizeof(datasend));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean dataChanged(){
|
|
|
|
boolean dataChanged(){
|
|
|
|
boolean changed = false;
|
|
|
|
boolean changed = false;
|
|
|
|
|
|
|
|
//Serial.println("tally: ");
|
|
|
|
for (int i=0; i < tallyLEDlength; i++){
|
|
|
|
for (int i=0; i < tallyLEDlength; i++){
|
|
|
|
if (AtemSwitcher.getProgramTally(i+1) == tallyLEDstat[i]){
|
|
|
|
if (AtemSwitcher.getProgramTally(i+1) != tallyLEDstat[i]){
|
|
|
|
tallyLEDstat[i] = AtemSwitcher.getProgramTally(i+1);
|
|
|
|
tallyLEDstat[i] = AtemSwitcher.getProgramTally(i+1);
|
|
|
|
digitalWrite(tallyLED[i], !AtemSwitcher.getProgramTally(i+1));
|
|
|
|
digitalWrite(tallyLED[i], tallyLEDstat[i]);
|
|
|
|
changed = true;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return changed;
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t getChecksum(uint8_t data){
|
|
|
|
byte getChecksum(byte data){
|
|
|
|
uint8_t checksum = 0;
|
|
|
|
byte checksum = 0;
|
|
|
|
for (int i=8; i<8; i++) checksum += (data >> i) & 1;
|
|
|
|
for (int i=8; i<8; i++) checksum += (data >> i) & B1;
|
|
|
|
return checksum;
|
|
|
|
return checksum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|