Skip to content

Commit

Permalink
Add led brightness setting
Browse files Browse the repository at this point in the history
  • Loading branch information
AronHetLam committed Sep 6, 2022
1 parent f7d631b commit 7053f69
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 9 deletions.
72 changes: 63 additions & 9 deletions ATEM_tally_light/ATEM_tally_light.ino
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ struct Settings {
IPAddress switcherIP;
uint16_t neopixelsAmount;
uint8_t neopixelStatusLEDOption;
uint8_t NeopixelBrightness;
uint8_t neopixelBrightness;
uint8_t ledBrightness;
};

Settings settings;
Expand Down Expand Up @@ -199,7 +200,7 @@ void setup() {
numStatusLEDs = 0;
}

FastLED.setBrightness(settings.NeopixelBrightness);
FastLED.setBrightness(settings.neopixelBrightness);
setSTRIP(LED_OFF);
setStatusLED(LED_BLUE);
FastLED.show();
Expand Down Expand Up @@ -383,6 +384,7 @@ void setLED2(uint8_t color) {

//Set the color of a LED using the given pins
void setLED(uint8_t color, int pinRed, int pinGreen, int pinBlue) {
#if ESP32
switch (color) {
case LED_OFF:
digitalWrite(pinRed, 0);
Expand Down Expand Up @@ -412,18 +414,66 @@ void setLED(uint8_t color, int pinRed, int pinGreen, int pinBlue) {
case LED_PINK:
digitalWrite(pinRed, 1);
digitalWrite(pinGreen, 0);
#if ESP32
digitalWrite(pinBlue, 1);
#else
analogWrite(pinBlue, 0xff);
#endif
break;
case LED_WHITE:
digitalWrite(pinRed, 1);
digitalWrite(pinGreen, 1);
digitalWrite(pinBlue, 1);
break;
}
#else
uint8_t ledBrightness = settings.ledBrightness;
void (*writeFunc)(uint8_t, uint8_t);
if(ledBrightness >= 0xff) {
writeFunc = &digitalWrite;
ledBrightness = 1;
} else {
writeFunc = &analogWriteWrapper;
}

switch (color) {
case LED_OFF:
digitalWrite(pinRed, 0);
digitalWrite(pinGreen, 0);
digitalWrite(pinBlue, 0);
break;
case LED_RED:
writeFunc(pinRed, ledBrightness);
digitalWrite(pinGreen, 0);
digitalWrite(pinBlue, 0);
break;
case LED_GREEN:
digitalWrite(pinRed, 0);
writeFunc(pinGreen, ledBrightness);
digitalWrite(pinBlue, 0);
break;
case LED_BLUE:
digitalWrite(pinRed, 0);
digitalWrite(pinGreen, 0);
writeFunc(pinBlue, ledBrightness);
break;
case LED_YELLOW:
writeFunc(pinRed, ledBrightness);
writeFunc(pinGreen, ledBrightness);
digitalWrite(pinBlue, 0);
break;
case LED_PINK:
writeFunc(pinRed, ledBrightness);
digitalWrite(pinGreen, 0);
writeFunc(pinBlue, ledBrightness);
break;
case LED_WHITE:
writeFunc(pinRed, ledBrightness);
writeFunc(pinGreen, ledBrightness);
writeFunc(pinBlue, ledBrightness);
break;
}
#endif
}

void analogWriteWrapper(uint8_t pin, uint8_t value) {
analogWrite(pin, value);
}

//Set the color of the LED strip, except for the status LED
Expand Down Expand Up @@ -605,7 +655,9 @@ void handleRoot() {
html += (String)MODE_ON_AIR + "\"";
if (settings.tallyModeLED2 == MODE_ON_AIR)
html += "selected";
html += ">On Air</option></select></td></tr><tr><td>Amount of Neopixels:</td><td><input type=\"number\"size=\"5\"min=\"0\"max=\"1000\"name=\"neoPxAmount\"value=\"";
html += ">On Air</option></select></td></tr><tr><td> Led brightness: </td><td><input type=\"number\"size=\"5\"min=\"0\"max=\"255\"name=\"ledBright\"value=\"";
html += settings.ledBrightness;
html += "\"required/></td></tr><tr><td><br></td></tr><tr><td>Amount of Neopixels:</td><td><input type=\"number\"size=\"5\"min=\"0\"max=\"1000\"name=\"neoPxAmount\"value=\"";
html += settings.neopixelsAmount;
html += "\"required/></td></tr><tr><td>Neopixel status LED: </td><td><select name=\"neoPxStatus\"><option value=\"";
html += (String) NEOPIXEL_STATUS_FIRST + "\"";
Expand All @@ -620,7 +672,7 @@ void handleRoot() {
if (settings.neopixelStatusLEDOption == NEOPIXEL_STATUS_NONE)
html += "selected";
html += ">None</option></select></td></tr><tr><td> Neopixel brightness: </td><td><input type=\"number\"size=\"5\"min=\"0\"max=\"255\"name=\"neoPxBright\"value=\"";
html += settings.NeopixelBrightness;
html += settings.neopixelBrightness;
html += "\"required/></td></tr><tr><td><br></td></tr><tr><td>Network name(SSID): </td><td><input type =\"text\"size=\"30\"maxlength=\"30\"name=\"ssid\"value=\"";
html += getSSID();
html += "\"required/></td></tr><tr><td>Network password: </td><td><input type=\"password\"size=\"30\"maxlength=\"30\"name=\"pwd\"pattern=\"^$|.{8,32}\"value=\"";
Expand Down Expand Up @@ -684,12 +736,14 @@ void handleSave() {
settings.tallyModeLED1 = val.toInt();
} else if (var == "tModeLED2") {
settings.tallyModeLED2 = val.toInt();
} else if (var == "ledBright") {
settings.ledBrightness = val.toInt();
} else if (var == "neoPxAmount") {
settings.neopixelsAmount = val.toInt();
} else if (var == "neoPxStatus") {
settings.neopixelStatusLEDOption = val.toInt();
} else if (var == "neoPxBright") {
settings.NeopixelBrightness = val.toInt();
settings.neopixelBrightness = val.toInt();
} else if (var == "tNo") {
settings.tallyNo = val.toInt() - 1;
} else if (var == "ssid") {
Expand Down
9 changes: 9 additions & 0 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ <h2>&nbsp;Settings:</h2>
</select>
</td>
</tr>
<tr>
<td>Led brightness: </td>
<td>
<input type="number" size="5" min="0" max="255" name="ledBright" value="@" required/>
</td>
</tr>
<tr>
<td><br></td>
</tr>
<tr>
<td>Amount of Neopixels:</td>
<td>
Expand Down

5 comments on commit 7053f69

@congminh3366
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, how can I contact you?

@AronHetLam
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@congminh3366 post an issue here on the GitHub page, that way others can benefit from my answers to your question as well 🙂
https://github.com/AronHetLam/ATEM_tally_light_with_ESP8266/issues

@congminh3366
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a problem when the upload is done the signal light doesn't come on. Can you assist me?

@AronHetLam
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to assist, but please follow this link and post a new issue there: https://github.com/AronHetLam/ATEM_tally_light_with_ESP8266/issues

When you do so, please include some more details, such as selected settings in Arduino IDE, if you're able to get logs or not after upload, what WiFi module you use, how the led is wired etc.

@congminh3366
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I tried following your instructions, but turning off all 6 esp8266 only shows blue, even though "setup tally light"

Please sign in to comment.