From bd411ce2badd5261b11ac7d99571f0c5048e1ac8 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 5 Dec 2021 15:14:11 +0100 Subject: [PATCH] fix pinout --- src/main.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 537293f..efd09c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,14 +1,6 @@ -#include -#include -#include -#include -#include - -// BEGIN CONFIGURATION - #define LED_COUNT 19 #define LED_BRIGHTNESS 100 -#define LED_PIN D4 +#define LED_PIN 12 #define WIFI_SSID "" #define WIFI_PASS "" @@ -17,10 +9,18 @@ #define OBS_PORT 4444 //#define OBS_PASS "" -#define OBS_SOURCE "" +#define OBS_SOURCE "ATEM" + +#define FASTLED_ESP8266_RAW_PIN_ORDER // END CONFIGURATION +#include +#include +#include +#include +#include + CRGB leds[LED_COUNT]; WebSocketsClient webSocket; @@ -35,21 +35,25 @@ bool is_currently_live = false; bool is_currently_preview = false; void set_program() { + Serial.println("[Tally] PROGRAM"); fill_solid(leds, LED_COUNT, CRGB::Red); FastLED.show(); } void set_preview() { + Serial.println("[Tally] PREVIEW"); fill_solid(leds, LED_COUNT, CRGB::Green); FastLED.show(); } void set_idle() { + Serial.println("[Tally] IDLE"); fill_solid(leds, LED_COUNT, CRGB::Black); FastLED.show(); } void set_error() { + Serial.println("[Tally] ERROR"); fill_solid(leds, LED_COUNT, CRGB::Purple); FastLED.show(); } @@ -73,11 +77,16 @@ void handleWebSocketEvent(WStype_t type, uint8_t * payload, size_t length) { case WStype_CONNECTED: Serial.printf("[WS] connected to %s\n", payload); // Find out if we need authentication +#ifdef OBS_PASS 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; case WStype_TEXT: { - Serial.printf("[WS] %s", payload); + Serial.printf("[WS] %s\n", payload); StaticJsonDocument<5000> doc; 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") { if (strcmp(doc["status"], "ok") == 0) { Serial.println("[OBS] authentication successful"); - webSocket.sendTXT("{\"request-type\":\"GetCurrentScene\",\"message-id\":\"3\"}"); - webSocket.sendTXT("{\"request-type\":\"GetPreviewScene\",\"message-id\":\"4\"}"); } else { Serial.println("Authenticated FAILED"); 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++) { if (strcmp(doc["sources"][i]["name"], OBS_SOURCE) == 0) { + Serial.println("[OBS] Source found in current event"); my_source_in_current_event = true; } } @@ -205,7 +213,6 @@ void setup() { set_error(); delay(500); set_idle(); - delay(200); Serial.printf("[Tally] connecting to wifi ssid: %s\n", WIFI_SSID); @@ -217,7 +224,7 @@ void setup() { Serial.print("."); } Serial.println(); - Serial.print("[Tally] connected to wifi, ip address"); + Serial.print("[Tally] connected to wifi, ip address "); Serial.println(WiFi.localIP()); Serial.println("[Tally] connecting to OBS");