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