Atltvhead
Published © MIT

Wearable IRL Stream Deck

Control your obs live stream with a wearable, wireless, stream deck

AdvancedWork in progressOver 3 days686
Wearable IRL Stream Deck

Things used in this project

Hardware components

SPARKFUN THING PLUS
ESP32
×1
GATERON ks-9
BUTTONS
×15
Diymore Double 18650 V8 Lithium Battery Shield Micro USB 5V/3A 3V/1A Power Bank
POWER REG
×1
18650 V8 Lithium Battery
BATTERY
×2
PC WITH DOCKER
PERSONAL COMPUTER
×1
SPARE CELLPHONE
DISPLAY
×1
Adafruit LM6DSOX
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Code snippet #8

Plain text
 This function is called once everything is connected (Wifi and MQTT)
// WARNING : YOU MUST IMPLEMENT IT IF YOU USE EspMQTTClient
void onConnectionEstablished()
{
  // Subscribe to "mytopic/test" and display received message to Serial
  client.subscribe("stream_status", [](const String & payload) {
    Serial.println(payload);
  });
  // Subscribe to "mytopic/test" and display received message to Serial
  client.subscribe("obs_webS_Connection", [](const String & payload) {
    Serial.println(payload);
  });
  // Subscribe to "mytopic/test" and display received message to Serial
  //client.subscribe("viewer_click", [](const String & payload) {
  //  Serial.println(payload);
  //});

  // Subscribe to "mytopic/wildcardtest/#" and display received message to Serial
  //client.subscribe("mytopic/wildcardtest/#", [](const String & topic, const String & payload) {
  //  Serial.println("(From wildcard) topic: " + topic + ", payload: " + payload);
  //});

  // Publish a message to "mytopic/test"
  client.publish("controller_glove", "alive"); // You can activate the retain flag by setting the third parameter to true

  // Execute delayed instructions
  //client.executeDelayed(5 * 1000, []() {
  //  client.publish("mytopic/wildcardtest/test123", "This is a message sent 5 seconds later");
  //});
}

Code snippet #9

Plain text
void loop()
{
  client.loop(); 
  button_handler();
}

Code snippet #1

C/C++
struct Button {
  const uint8_t PIN;
  uint32_t numberKeyPresses;
  bool pressed;
};

Button button1 = {13, 0, false};
Button button2 = {12, 0, false};
Button button3 = {27, 0, false};
Button button4 = {33, 0, false};
Button button5 = {15, 0, false};
Button button6 = {32, 0, false};
Button button7 = {14, 0, false};
Button button8 = {22, 0, false};
Button button9 = {23, 0, false};
Button button10 = {21, 0, false};
Button button11 = {17, 0, false};
Button button12 = {16, 0, false};
Button button13 = {19, 0, false};
Button button14 = {18, 0, false};
Button button15 = {5, 0, false};

int button_debounce = 250;
int button_double_delay = 300;

Code snippet #2

C/C++
void IRAM_ATTR isr() {
  static unsigned long last_interrupt_time = 0;
   unsigned long interrupt_time = millis();
 // If interrupts come faster than 350ms, assume it's a bounce and ignore
 if (interrupt_time - last_interrupt_time > button_debounce)
 {
  button1.numberKeyPresses += 1;
  button1.pressed = true;
 }
 
 last_interrupt_time = interrupt_time;
}

Code snippet #4

Plain text
void button_handler(){
  Binterrupt_time = millis();
  if(Binterrupt_time - Blast_interrupt_time > button_double_delay){
    if (button1.pressed || button2.pressed || button3.pressed || button4.pressed || button5.pressed || button6.pressed || button7.pressed || button8.pressed || button9.pressed || button10.pressed || button11.pressed || button12.pressed || button13.pressed || button14.pressed || button15.pressed) {
     

      //doc["b1B"]=button1.pressed;
      doc["b1"]=button1.numberKeyPresses;
      //doc["b2B"]=button12.pressed;
      doc["b2"]=button2.numberKeyPresses;
      //doc["b3B"]=button3.pressed;
      doc["b3"]=button3.numberKeyPresses;
      //doc["b4B"]=button4.pressed;
      doc["b4"]=button4.numberKeyPresses;
      //doc["b5B"]=button5.pressed;
      doc["b5"]=button5.numberKeyPresses;
      //doc["b6B"]=button6.pressed;
      doc["b6"]=button6.numberKeyPresses;
      //doc["b7B"]=button7.pressed;
      doc["b7"]=button7.numberKeyPresses;
      //doc["b8B"]=button8.pressed;
      doc["b8"]=button8.numberKeyPresses;
      //doc["b9B"]=button9.pressed;
      doc["b9"]=button9.numberKeyPresses;
      //doc["b10B"]=button10.pressed;
      doc["b10"]=button10.numberKeyPresses;
      //doc["b11B"]=button11.pressed;
      doc["b11"]=button11.numberKeyPresses;
      //doc["b12B"]=button12.pressed;
      doc["b12"]=button12.numberKeyPresses;
      //doc["b13B"]=button13.pressed;
      doc["b13"]=button13.numberKeyPresses;
      //doc["b14B"]=button14.pressed;
      doc["b14"]=button14.numberKeyPresses;
      //doc["b15B"]=button15.pressed;
      doc["b15"]=button15.numberKeyPresses;
      
      char buf[256];
      size_t n = serializeJson(doc, buf);
      
      client.publish("button_glove", buf, n);
      //Serial.println(n);
      button1.pressed = false;
      button2.pressed = false;
      button3.pressed = false;
      button4.pressed = false;
      button5.pressed = false;
      button6.pressed = false;
      button7.pressed = false;
      button8.pressed = false;
      button9.pressed = false;
      button10.pressed = false;
      button11.pressed = false;
      button12.pressed = false;
      button13.pressed = false;
      button14.pressed = false;
      button15.pressed = false;

      
      
    }
  Blast_interrupt_time = Binterrupt_time;
  } 
}

Code snippet #5

C/C++
#include "EspMQTTClient.h"
#include <Arduino.h>
#include <ArduinoJson.h>

const int capacity = JSON_OBJECT_SIZE(15); 
StaticJsonDocument<capacity> doc;

Code snippet #6

C/C++
EspMQTTClient client(
  SSID2,
  PASSWORD2,
  MQTTBROKER,  // MQTT Broker server ip
  "TestESP32",     // Client name that uniquely identify your device
  1883              // The MQTT port, default to 1883. this line can be omitted
);

Code snippet #7

Plain text
// Optionnal functionnalities of EspMQTTClient : 
  client.enableDebuggingMessages(); // Enable debugging messages sent to serial output
  client.enableHTTPWebUpdater(); // Enable the web updater. User and password default to values of MQTTUsername and MQTTPassword. These can be overrited with enableHTTPWebUpdater("user", "password").
  client.enableLastWillMessage("TestClient/lastwill", "I am going offline");  // You can activate the retain flag by setting the third parameter to true
  client.setMaxPacketSize(256);

Github

https://github.com/ATLTVHEAD/OBS_IRL_CONTROLLER

Github file

https://github.com/ATLTVHEAD/OBS_IRL_CONTROLLER/tree/main/CAD

Github

https://github.com/lebaston100/node-red-contrib-obs-ws

Credits

Atltvhead
3 projects • 10 followers
Contact

Comments

Please log in or sign up to comment.