fix pinout
This commit is contained in:
parent
8d20b46a8c
commit
bd411ce2ba
1 changed files with 22 additions and 15 deletions
35
src/main.cpp
35
src/main.cpp
|
@ -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_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 <ESP8266WiFi.h>
|
||||
#include <WebSocketsClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <Base64.h>
|
||||
#include <FastLED.h>
|
||||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue