fix pinout

This commit is contained in:
Franzi 2021-12-05 15:14:11 +01:00
parent 8d20b46a8c
commit bd411ce2ba
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -1,14 +1,6 @@
#include <ESP8266WiFi.h>
#include <WebSocketsClient.h>
#include <ArduinoJson.h>
#include <FastLED.h>
#include <Base64.h>
// BEGIN CONFIGURATION
#define LED_COUNT 19 #define LED_COUNT 19
#define LED_BRIGHTNESS 100 #define LED_BRIGHTNESS 100
#define LED_PIN D4 #define LED_PIN 12
#define WIFI_SSID "" #define WIFI_SSID ""
#define WIFI_PASS "" #define WIFI_PASS ""
@ -17,10 +9,18 @@
#define OBS_PORT 4444 #define OBS_PORT 4444
//#define OBS_PASS "" //#define OBS_PASS ""
#define OBS_SOURCE "" #define OBS_SOURCE "ATEM"
#define FASTLED_ESP8266_RAW_PIN_ORDER
// END CONFIGURATION // END CONFIGURATION
#include <ESP8266WiFi.h>
#include <WebSocketsClient.h>
#include <ArduinoJson.h>
#include <Base64.h>
#include <FastLED.h>
CRGB leds[LED_COUNT]; CRGB leds[LED_COUNT];
WebSocketsClient webSocket; WebSocketsClient webSocket;
@ -35,21 +35,25 @@ bool is_currently_live = false;
bool is_currently_preview = false; bool is_currently_preview = false;
void set_program() { void set_program() {
Serial.println("[Tally] PROGRAM");
fill_solid(leds, LED_COUNT, CRGB::Red); fill_solid(leds, LED_COUNT, CRGB::Red);
FastLED.show(); FastLED.show();
} }
void set_preview() { void set_preview() {
Serial.println("[Tally] PREVIEW");
fill_solid(leds, LED_COUNT, CRGB::Green); fill_solid(leds, LED_COUNT, CRGB::Green);
FastLED.show(); FastLED.show();
} }
void set_idle() { void set_idle() {
Serial.println("[Tally] IDLE");
fill_solid(leds, LED_COUNT, CRGB::Black); fill_solid(leds, LED_COUNT, CRGB::Black);
FastLED.show(); FastLED.show();
} }
void set_error() { void set_error() {
Serial.println("[Tally] ERROR");
fill_solid(leds, LED_COUNT, CRGB::Purple); fill_solid(leds, LED_COUNT, CRGB::Purple);
FastLED.show(); FastLED.show();
} }
@ -73,11 +77,16 @@ void handleWebSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
case WStype_CONNECTED: case WStype_CONNECTED:
Serial.printf("[WS] connected to %s\n", payload); Serial.printf("[WS] connected to %s\n", payload);
// Find out if we need authentication // Find out if we need authentication
#ifdef OBS_PASS
webSocket.sendTXT("{\"request-type\":\"GetAuthRequired\",\"message-id\":\"1\"}"); webSocket.sendTXT("{\"request-type\":\"GetAuthRequired\",\"message-id\":\"1\"}");
#else
webSocket.sendTXT("{\"request-type\":\"GetCurrentScene\",\"message-id\":\"1\"}");
webSocket.sendTXT("{\"request-type\":\"GetPreviewScene\",\"message-id\":\"2\"}");
#endif
break; break;
case WStype_TEXT: { case WStype_TEXT: {
Serial.printf("[WS] %s", payload); Serial.printf("[WS] %s\n", payload);
StaticJsonDocument<5000> doc; StaticJsonDocument<5000> doc;
DeserializationError error = deserializeJson(doc, payload); DeserializationError error = deserializeJson(doc, payload);
@ -131,8 +140,6 @@ void handleWebSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
} else if (doc.containsKey("message-id") && (doc["message-id"]) == "2") { } else if (doc.containsKey("message-id") && (doc["message-id"]) == "2") {
if (strcmp(doc["status"], "ok") == 0) { if (strcmp(doc["status"], "ok") == 0) {
Serial.println("[OBS] authentication successful"); Serial.println("[OBS] authentication successful");
webSocket.sendTXT("{\"request-type\":\"GetCurrentScene\",\"message-id\":\"3\"}");
webSocket.sendTXT("{\"request-type\":\"GetPreviewScene\",\"message-id\":\"4\"}");
} else { } else {
Serial.println("Authenticated FAILED"); Serial.println("Authenticated FAILED");
set_error(); set_error();
@ -145,6 +152,7 @@ void handleWebSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
for (uint8_t i = 0; i < doc["sources"].size(); i++) { for (uint8_t i = 0; i < doc["sources"].size(); i++) {
if (strcmp(doc["sources"][i]["name"], OBS_SOURCE) == 0) { if (strcmp(doc["sources"][i]["name"], OBS_SOURCE) == 0) {
Serial.println("[OBS] Source found in current event");
my_source_in_current_event = true; my_source_in_current_event = true;
} }
} }
@ -205,7 +213,6 @@ void setup() {
set_error(); set_error();
delay(500); delay(500);
set_idle(); set_idle();
delay(200);
Serial.printf("[Tally] connecting to wifi ssid: %s\n", WIFI_SSID); Serial.printf("[Tally] connecting to wifi ssid: %s\n", WIFI_SSID);
@ -217,7 +224,7 @@ void setup() {
Serial.print("."); Serial.print(".");
} }
Serial.println(); Serial.println();
Serial.print("[Tally] connected to wifi, ip address"); Serial.print("[Tally] connected to wifi, ip address ");
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
Serial.println("[Tally] connecting to OBS"); Serial.println("[Tally] connecting to OBS");