AronHetLam / ATEM_tally_light_with_ESP8266

Wireless tally light for use with ATEM switchers, which connects over WiFi, using an ESP WiFi module.
GNU General Public License v3.0
153 stars 39 forks source link

Feature request: make the led blink if the voltage drops below 3.7v #126

Closed deluc closed 4 months ago

deluc commented 4 months ago

Hey, I added the battery shield to the tally light so I don't have to use a cable to power them. The power shield provides the battery voltage to the a0 pin on the d1mini. Would it be possible to add a function to make the led blink if the voltage drops below 3.7 volts? So I will know if the power on the tally is low. Thanks!

AronHetLam commented 4 months ago

You're in luck

Earlier someone else added that, so there is some code for it at the bottom of the main program file. I haven't used it myself, but I think it should work if you uncomment it. There are a few other places with battery related code that's commented out.

https://github.com/AronHetLam/ATEM_tally_light_with_ESP8266/blob/master/ATEM_tally_light%2FATEM_tally_light.cpp#L987-L1019

deluc commented 4 months ago

Looks great, thank you, I will try it :)

AronHetLam commented 4 months ago

Sounds good 👍 Then I'll close this for now.

deluc commented 4 months ago

So I uncommented every bit that (I think) was part of the battery related code, but if I upload it to the esp my led is not blinking after the voltage drops below 3,6V. Sadly I'm not that good with code to trouble shoot it. Do you have any idea what could be the problem? Here is the uncommented code: ATEM_tally_light.cpp ATEM_tally_light.hpp

AronHetLam commented 4 months ago

Are you using regular Leads only, or an LED strip such as neopixels through data pin 7? Looks like the battery code sets the status LED, which would be an LED on a LED strip.

If you need it to blink the regular LEDs, you could make the battery loop set a global variable for when it should be on, and when it should be off. Then use that variable in the setLED function to turn off the LED when needed. It could also be in setLED1 or setLED2 if you only want one of them to blink.

I hope that makes sense 🙂

deluc commented 4 months ago

I'm just using a single LED on Port D0, D1, D2. Sadly it doesn't make sense to me, because my coding skills are like 1/100 :D. So I guess I will not be using this feature. Would be great if you could implement it some time and to enable it via GUI. Seeing the voltage of all connected Tallys on the GUI of my master Tally would also be great. But thank you for ur help :)

AronHetLam commented 4 months ago

I took another look. Try this https://pastecode.io/s/jzxcispd

I added the following to the setLED method

    If (lowLedOn) {
        color = LED_YELLOW;
    }

It should blink the leds yellow when low battery, temporarily overwriting tally light color.

AronHetLam commented 4 months ago

Also, you might want to move the call to batteryLoop() down to the end of the loop function. Currently the battery code is only run while connected to a switcher. By moving it down right below

    //Handle web interface
    server.handleClient();

The battery code will always run.

deluc commented 4 months ago

Thanks so much! I moved the code exactly as you said (line 438 to line 469). It looks like this:

    //Handle web interface
    server.handleClient();
    batteryLoop();

But then the LED turns red all the time.