Skip to content

Commit

Permalink
🚀 PLUS updates; Plugin Manager updates; Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
guido-visser committed Oct 8, 2020
1 parent 8d0216b commit 06e8274
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 42 deletions.
93 changes: 68 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,111 @@
![](working-example.gif)

## Features
* ⚡ Press on M5 button will toggle between 4 screens:
1. The actual status of the tally (a tally status change will default back to this screen)
2. Network screen, showing the current IP Address so you can access the Web UI
3. Show the actual tally input number that is set for the unit
4. The brightness screen. You can use BTN39 on this screen to toggle through the 9 different settings
* ⚡ Webserver for easy configuration
* ⚡ Access Point mode when not connected to a WiFi network
* ⚡ Data is saved to memory, will be remembered after device is turned off
* ⚡ Dedicated button to reconnect to vMix (BTN39, will reconnect to vMix except on the brightness screen)
* ⚡ Holding the same button at the end of trying to reconnect will reset the settings
* ⚡ Dark Web UI
* ⚡ Ability to adjust the brightness (either on the stick itself, or via the Web UI)
* ⚡ Battery indicator
* ⚡ Landscape & Portrait mode using accelerometer
* ⚡ Change tally number input on the fly. On the tally input number screen, double click the BTN39 to increase the number. Long click for reset to 1
* ⚡ Multi input support

- ⚡ Press on M5 button will toggle between 4 screens:
1. The actual status of the tally (a tally status change will default back to this screen)
2. Network screen, showing the current IP Address so you can access the Web UI
3. Show the actual tally input number that is set for the unit
4. The brightness screen. You can use BTN39 on this screen to toggle through the 9 different settings
- ⚡ Webserver for easy configuration
- ⚡ Access Point mode when not connected to a WiFi network
- ⚡ Data is saved to memory, will be remembered after device is turned off
- ⚡ Dedicated button to reconnect to vMix (BTN39, will reconnect to vMix except on the brightness screen)
- ⚡ Holding the same button at the end of trying to reconnect will reset the settings
- ⚡ Dark Web UI
- ⚡ Ability to adjust the brightness (either on the stick itself, or via the Web UI)
- ⚡ Battery indicator
- ⚡ Landscape & Portrait mode using accelerometer
- ⚡ Change tally number input on the fly. On the tally input number screen, double click the BTN39 to increase the number. Long click for reset to 1
- ⚡ Multi input support

---

## Getting started: Uploading the code to the stick

### Video tutorial

[![Video Tutoral](http://img.youtube.com/vi/uB_OkMGLoto/0.jpg)](http://www.youtube.com/watch?v=uB_OkMGLoto "How to update the firmware of the M5Stick C to the Tally Light project")

### Step 1
1.1 Follow the tutorial on the [M5Stack website](https://docs.m5stack.com/#/en/arduino/arduino_development).

1.2 Copy the libraries that are used by this project (found in the `libs` folder) to your system. The default path is: `%userprofile%\Documents\Arduino\libraries`
1.1 Follow the tutorial on the [M5Stack website](https://docs.m5stack.com/#/en/arduino/arduino_development).

1.2 Copy the libraries that are used by this project (found in the `libs` folder) to your system. The default path is: `%userprofile%\Documents\Arduino\libraries`

### Step 2

Upload to your device.

##### When using the original M5Stick-C

You don't have to change the code! 🎉

##### When using M5Stick-C PLUS

Change the very first line in `a_GLOBAL.ino` to `#define C_PLUS 1` (change the `0` to a `1`)
That's it!

### Step 3

Follow the instructions on the LCD.

### Step 4

Enjoy 😄

---

## Configuring the stick

1. Once the code is uploaded to the stick, wait until it's in AP (Access Point) mode.
2. Grab a phone and connect to the `vMix-M5Stick-Tally` wifi network, the password is: `12345678`.
3. Open your browser and go to: `http://192.168.4.1`, this will open up the Web UI.
1. Enter the SSID of the wifi network you want to connect to.
2. Enter the password that corresponds to the SSID.
3. Enter the IP Address of the PC that's running vMix.
4. Specify the input number that the stick must listen to. (This is the little number in the top left corner of every input)
1. Enter the SSID of the wifi network you want to connect to.
2. Enter the password that corresponds to the SSID.
3. Enter the IP Address of the PC that's running vMix.
4. Specify the input number that the stick must listen to. (This is the little number in the top left corner of every input)
4. Hit the save button.
5. The stick will restart with the given information.

---

## Plugins

Officially supported plugin:

- LED HAT (for the HEX and NEOFLASH HATs) Big thanks to [Dirwin Clemens](https://github.com/Dirwinc)

For more information see [Plugins.md](https://github.com/guido-visser/vMix-M5Stick-Tally-Light/tree/master/src/a_GLOBAL/plugins/Plugins.md)

---

### Forks

Since M5Stack has a lot of different products, some wonderful people forked my code to use it on those different products. Below is a list of products supported by the community:

##### [M5Stack ATOM](https://github.com/MarkGaretz/ATOM-Matrix-Tally-Light) by Mark Garetz

##### [M5Stack CORE](https://gitlab.com/ptellep/m5stack-tally-for-vmix) by Peter Tellep

---

## TODO
* [ ] Configuration tutorial
* [x] Written
* [ ] Video

- [ ] Configuration tutorial
- [x] Written
- [ ] Video

### Good to know

This is my very first C-project, if you have any suggestions on how to improve the code, please let me know.

#### Thanks

A massive thanks to [Thomas Mout](https://github.com/ThomasMout) for creating [Arduino vMix Tally](https://github.com/ThomasMout/Arduino-vMix-tally). This project is based on his.

#### Support the project

This project is completely free to use in any environment (commerically or non-commerically). However, if you like it and use it regularly, please consider buying me a coffee 😄

<a href="https://www.buymeacoffee.com/guidovisser" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" width="217" height="51" alt="Buy Me A Coffee" style="border-radius: 5px" ></a>
18 changes: 9 additions & 9 deletions src/a_GLOBAL/a_GLOBAL.ino
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#include <WiFi.h>
#define C_PLUS 1

#if C_PLUS == 1
#include <M5StickCPlus.h>
#else
#include <M5StickC.h>
//#include <M5StickCPlus.h>
#endif
#include <WiFi.h>
#include <PinButton.h>
#include <WebServer.h>
#include <Preferences.h>
#include "k_PLUGINMANAGER.h";

/*
Set the variable below to 1 when using the M5StickC-Plus
When you use the PLUS, comment the #include <M5StickC.h> line at the top of this file by adding // to the front of the line
and uncomment the #include <M5StickCPlus.h> file by removing //
*/
bool C_PLUS = 0;

#define LED_BUILTIN 10

Preferences preferences;
Expand All @@ -25,3 +23,5 @@ String M_TALLY = "";
int VMIX_PORT = 8099; //USES THE TCP API PORT, THIS IS FIXED IN VMIX
int TALLY_NR = 1;
int BRIGHTNESS = 12; //100%

String semver = "2.0.0";
14 changes: 9 additions & 5 deletions src/a_GLOBAL/c_MAIN.ino
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,18 @@ void start()
loadSettings();
screenRotation = screenRotation == 1 || screenRotation == 3 ? screenRotation : 3;
M5.Lcd.setRotation(screenRotation);

String prod = "vMix M5Stick-C Tally";
String author = "by Guido Visser";

M5.Lcd.setTextSize(1);
M5.Lcd.setTextColor(WHITE, BLACK);
M5.Lcd.setCursor(0, 0);
M5.Lcd.println("v2.0.0");
M5.Lcd.println(semver);
M5.Lcd.setCursor(lcdCoordX(20), lcdCoordY(20));
M5.Lcd.println("vMix M5Stick-C Tally");
M5.Lcd.println(prod);
M5.Lcd.setCursor(lcdCoordX(35), lcdCoordY(40));
M5.Lcd.println("by Guido Visser");
M5.Lcd.println(author);

delay(2000);

Expand Down Expand Up @@ -223,14 +227,14 @@ void renderCurrentScreen(){

int lcdCoordX(int x){
if(C_PLUS){
return x * 2.2;
return x * 1.5;
} else {
return x;
}
}
int lcdCoordY(int y){
if(C_PLUS){
return y * 2;
return y * 1.6875;
} else {
return y;
}
Expand Down
4 changes: 2 additions & 2 deletions src/a_GLOBAL/e_WIFI.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ void startWiFi()
//WiFi.softAP(ssid, password);

M5.Lcd.println();
M5.Lcd.setCursor(25, 60);
M5.Lcd.setCursor(lcdCoordX(25), lcdCoordY(60));
M5.Lcd.println("Waiting for WiFi...");
M5.Lcd.setCursor(38, 70);
M5.Lcd.setCursor(lcdCoordX(38), lcdCoordY(70));
//while (WiFi.status() != WL_CONNECTED) {
int tries = 0;
boolean wifi_connected = true;
Expand Down
5 changes: 4 additions & 1 deletion src/a_GLOBAL/g_NETWORKSCREEN.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ void showNetworkScreen() {
if(screenRotation == 0 || screenRotation == 2){
screenRotation = 3;
M5.Lcd.setRotation(3);
}
}
if(C_PLUS){
M5.Lcd.setTextSize(2);
}
M5.Lcd.println("SSID:");
M5.Lcd.println(WIFI_SSID);
M5.Lcd.println();
Expand Down
83 changes: 83 additions & 0 deletions src/a_GLOBAL/plugins/Plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Plugins

## Existing plugins

### LED HEX

There are 2 HATs that already work with the provided `LED_HEX.h` plugin. To make use of this plugin, remove the comment marks `//` from the lines in `k_PLUGINMANAGER.h`.

##### HEX HAT

You don't have to change the `LED_HEX.h` file. 🎉

##### NEOFLASH HAT

Change the `NUM_LEDS` variable to `126`
Change the `DATA_PIN` variable to `26`

---

## Develop a plugin

To make use of the HATs that M5Stack develops, I've created a way to develop plugins, so that you can add functionality to the stick if you want to. Create a file in the `/plugins` directory, and make sure it's a `.h` file. As an example, we'll call our example plugin: `Example.h`.

### Basic plugin

```C++
class Example{

public:
Example(){

}

void onLive() {

}

void onPre() {

}

void onSafe() {

}

void onClear() {

}
};
```

It's pretty self-explanatory: The `onLive`, `onPre`, `onSafe` and `onClear` methods are called whenever the state of the tally changes.
When it switches to LIVE, the `onLive` function is called, the same counts for the other functions.

### Hook into the code

When you created a plugin, you need to open the `k_PLUGINMANAGER.h` file, and initialize the plugin class you've created:

```
#include "plugins/Example.h";
class PluginManager {
public:
PluginManager(){}
Example examplePlugin;
void onLive(){
examplePlugin.onLive();
}
void onPre() {
examplePlugin.onPre();
}
void onSafe() {
examplePlugin.onSafe();
}
};
```

Do this for every plugin you have. I know, it's not ideal. I'm still looking for a good and more efficient alternative to add plugins, but this is what I have so far... Suggestions are more than welcome 😄

If something is not clear, please feel free to report an issue, so that I can improve this documentation.

0 comments on commit 06e8274

Please sign in to comment.