Skip to content

Commit

Permalink
initial commit for onair
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanato committed Dec 16, 2020
0 parents commit 32d10b9
Show file tree
Hide file tree
Showing 46 changed files with 19,662 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-react"]
}
77 changes: 77 additions & 0 deletions .github/workflows/test_build.yml
@@ -0,0 +1,77 @@
name: test_build

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- uses: actions/cache@v1
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn

- run: yarn build

- run: yarn test
env:
CI: true

build:
needs: [tests]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
strategy:
matrix:
node-version: [12.x]

steps:

- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- uses: actions/cache@v1
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn

- run: yarn build

- name: Generate .streamDeckPlugin
run: ./tools/mac/DistributionTool -b -i ./dist/dev.cpanato.onair.sdPlugin -o ./release/

- name: Upload .streamDeckPlugin artifact
uses: actions/upload-artifact@v1.0.0
with:
# Artifact name
name: dev.cpanato.onair.streamDeckPlugin
# Directory containing files to upload
path: ./release/
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
node_modules
.cache
dist
/.DS_Store
/images/.DS_Store
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Carlos Panato

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 38 additions & 0 deletions README.md
@@ -0,0 +1,38 @@
# OnAir Stream Deck

# How it works?

It uses an external Hardware (see `hardware` directory) to notify when you are `On Air`

in action: https://twitter.com/comedordexis/status/1268549324092387340

With any StreamDeck you just install the latest release and then configure the IP address from the hardware you setup and that is it


# How to setup the dev environment

1. Install all the dependencies

```bash
yarn
```

2. Build the project for the first time, the project uses [Parcel as bundler](https://parceljs.org/) to handle React and TypeScript

```bash
yarn build
```

3. Package the plugin

```bash
./tools/mac/DistributionTool -b -i ./dist/dev.cpanato.onair.sdPlugin -o ./release/
```

# References

- [Steam Deck SDK docs](https://developer.elgato.com/documentation/)

# Contributing

Feel free to send in any pull requests.
8 changes: 8 additions & 0 deletions hardware/README.md
@@ -0,0 +1,8 @@
# Hardware

To build the Hardware you can follow

https://learn.adafruit.com/3d-printed-iot-on-air-sign-for-twitch?view=all

The source code for the hardware is in the `onAir` directory.

2 changes: 2 additions & 0 deletions hardware/onAir/arduino_secrets.h
@@ -0,0 +1,2 @@
#define SECRET_SSID "WIFI_NAME"
#define SECRET_PASS "WIFI_PASSWORD"
149 changes: 149 additions & 0 deletions hardware/onAir/onAir.ino
@@ -0,0 +1,149 @@
/*
WiFi Web Server
A simple web server that shows the value of the analog input pins.
using a WiFi shield.
This example is written for a network using WPA encryption. For
WEP or WPA, change the WiFi.begin() call accordingly.
Circuit:
* WiFi shield attached
* Analog inputs attached to pins A0 through A5 (optional)
*/

#include <SPI.h>
#include <WiFi101.h>
#include <FastLED.h>


#include "arduino_secrets.h"
// Please enter your sensitive data in the Secret arduino_secrets.h
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0; // your network key Index number (needed only for WEP)

int onAir = 0;

// How many leds in your strip?
#define NUM_LEDS 15
#define DATA_PIN 12

// Define the array of leds
CRGB leds[NUM_LEDS];

int status = WL_IDLE_STATUS;

WiFiServer server(80);

void setup() {
WiFi.setPins(8,7,4,2);

FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
//Initialize serial and wait for port to open:
// Serial.begin(9600);
// while (!Serial) {
// ; // wait for serial port to connect. Needed for native USB port only
// }
colorWipe(0x0000FF, 50);

// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}

// attempt to connect to WiFi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection:
delay(10000);
}
server.begin();
// you're connected now, so print out the status:
// printWiFiStatus();
colorWipe(0x000000, 50);
}


void loop() {
// listen for incoming clients
WiFiClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();

// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();

if (onAir == 0) {
client.println("{\"status\": \"on\"}");
colorWipe(0x008000, 50);
onAir = 1;
} else if (onAir == 1) {
client.println("{\"status\": \"off\"}");
colorWipe(0x000000, 50);
onAir = 0;
}
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);

// close the connection:
client.stop();
}
}

void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<NUM_LEDS; i++) {
leds[i] = c;
}
FastLED.show();
delay(wait);
}


void printWiFiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
Binary file added images/categoryIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/categoryIcon@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/onair/.DS_Store
Binary file not shown.
Binary file added images/onair/actionDefaultImage.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/onair/actionDefaultImage@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/onair/actionFailImage.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/onair/actionFailImage@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/onair/actionIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/onair/actionIcon@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/onair/actionSuccessImage.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/onair/actionSuccessImage@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/pluginIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/pluginIcon@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions jest.config.js
@@ -0,0 +1,4 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom"
};
52 changes: 52 additions & 0 deletions manifest.json
@@ -0,0 +1,52 @@
{
"Actions": [
{
"Icon": "images/onair/actionIcon",
"Name": "OnAir Status",
"States": [
{
"Image": "images/onair/actionSuccessImage",
"TitleAlignment": "bottom",
"FontSize": "11"
},
{
"Image": "images/onair/actionFailImage",
"TitleAlignment": "bottom",
"FontSize": "11"
},
{
"Image": "images/onair/actionDefaultImage",
"TitleAlignment": "bottom",
"FontSize": "11"
}
],
"SupportedInMultiActions": false,
"Tooltip": "Show your On Air status",
"UUID": "dev.cpanato.onair"
}
],
"SDKVersion": 2,
"Author": "cpanato",
"PropertyInspectorPath": "pi/index.html",
"Category": "OnAir Status for Stream Deck",
"CategoryIcon": "images/categoryIcon",
"CodePath": "plugin/index.html",
"Description": "Show your On Air status.",
"Name": "On Air for StreamDeck",
"Icon": "images/pluginIcon",
"URL": "https://cpanato.dev",
"Version": "1.0.0",
"OS": [
{
"Platform": "mac",
"MinimumVersion": "10.11"
},
{
"Platform": "windows",
"MinimumVersion": "10"
}
],
"Software": {
"MinimumVersion": "4.1"
}
}

0 comments on commit 32d10b9

Please sign in to comment.