Created
December 6, 2021 04:16
-
-
Save hasanbasri1993/d5f1a478979f59916647b17411723309 to your computer and use it in GitHub Desktop.
tally light for atem switcher using esp8266
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***************** | |
Tally light ESP8266 for Blackmagic ATEM switcher | |
https://forum.livevideotech.today/t/wifi-tally-for-atem-mini-on-the-cheap/760/9 | |
Version 1.5 | |
A wireless (WiFi) tally light for Blackmagic Design | |
ATEM video switchers, based on the Wemos D1 Mini ESP8266 development | |
board with WS2812B RGB Shield and the Arduino IDE. | |
Based on the work of Kasper Skårhøj: | |
https://github.com/kasperskaarhoj/SKAARHOJ-Open-Engineering | |
and OneGuyOneBlog | |
https://oneguyoneblog.com/2020/06/13/tally-light-esp32-for-blackmagic-atem-switcher/ | |
******************/ | |
//library for Wifi | |
#include <ESP8266WiFi.h> | |
//libraries for ATEM https://github.com/kasperskaarhoj/SKAARHOJ-Open-Engineering | |
#include <SkaarhojPgmspace.h> | |
#include <ATEMbase.h> | |
#include <ATEMstd.h> | |
//library for RGB Shield. | |
#include <Adafruit_NeoPixel.h> //https://github.com/adafruit/Adafruit_NeoPixel | |
//--- YOU WILL WANT TO CHANGE THESE SIX VARIABLES --- | |
const char* ssid = "YOUR SSID"; // The wifi network you would like to connect to | |
const char* password = "**********"; // Password of the wifi network | |
int led_brightness = 25; // Percentage of LED brightness | |
int cameraNumber = 1; // Camera Input number on your ATEM Switcher | |
IPAddress clientIp(192, 168, 1, 202); // IP address of the ESP8266 | |
IPAddress switcherIp(192, 168, 1, 200); // IP address of the ATEM switcher | |
//--- Nothing beyond this point needs changing unless you want to develop the code. --- | |
ATEMstd AtemSwitcher; | |
#define PIN 4 | |
#define LED_NUM 7 | |
int PreviewTallyPrevious = 1; | |
int ProgramTallyPrevious = 1; | |
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800); | |
void setup() { | |
leds.begin(); // This initializes the NeoPixel library. | |
Serial.begin(115200); | |
Serial.println("Serial is up"); | |
// Start the Ethernet, Serial (debugging) and UDP: | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
led_set(0, 0, led_brightness);//blue | |
delay(500); | |
Serial.println("Connecting to WiFi.."); | |
} | |
Serial.println("Connected to the WiFi network"); | |
led_set(led_brightness, led_brightness, led_brightness);//white | |
// Initialize a connection to the switcher: | |
AtemSwitcher.begin(switcherIp); | |
AtemSwitcher.serialOutput(true); | |
AtemSwitcher.connect(); | |
} | |
void led_set(uint8 R, uint8 G, uint8 B) { | |
for (int i = 0; i < LED_NUM; i++) { | |
leds.setPixelColor(i, leds.Color(R, G, B)); | |
leds.show(); | |
} | |
} | |
void loop() { | |
// Check for packets, respond to them etc. Keeping the connection alive! | |
AtemSwitcher.runLoop(); | |
int ProgramTally = AtemSwitcher.getProgramTally(cameraNumber); | |
int PreviewTally = AtemSwitcher.getPreviewTally(cameraNumber); | |
if ((ProgramTallyPrevious != ProgramTally) || (PreviewTallyPrevious != PreviewTally)) { // changed? | |
if ((ProgramTally && !PreviewTally) || (ProgramTally && PreviewTally) ) { // only program, or program AND preview | |
led_set(led_brightness, 0, 0);//red | |
} else if (PreviewTally && !ProgramTally) { // only preview | |
led_set(0, led_brightness, 0);//green | |
} else if (!PreviewTally || !ProgramTally) { // neither | |
led_set(0, 0, 0);//off | |
} | |
} | |
ProgramTallyPrevious = ProgramTally; | |
PreviewTallyPrevious = PreviewTally; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment