Problem getting the Fade to Black LED to blink when FTB is activated

15 posts / 0 new
Last post
Offline

Location

Adelaide,
Australia
Joined: 19/02/2014
Posts: 59
Problem getting the Fade to Black LED to blink when FTB is activated

I am building a control panel for a TVS using the Skaarjoh sketches. With the code below the Fade to Black LED blinks during execution of the FTB, stays on when FTB is  activated and goes off when FTB is de-activated.

What is would like to have is the LED on during execution, blinking when activated and off when de-activated. just like it is on the software control panel.

No matter what I try with my limited skills I can't achieve this. Any help with this would be highly appreciated.

Cheers

Hessel Baartse

 if (AtemSwitcher.getFadeToBlackState())  {  // Setting button color. This is a more complex example which includes blinking during execution:

    if (AtemSwitcher.getFadeToBlackTime()>0 && (AtemSwitcher.getFadeToBlackFrameCount()!=AtemSwitcher.getFadeToBlackTime()))  {  // It's important to test if fadeToBlack time is more than zero because it's the kind of state from the ATEM which is usually not captured during initialization. Hopefull this will be solved in the future.

        // Blinking if Fade To Black is executing:

      if ((unsigned long)millis() & B10000000)  {

        digitalWrite(48, 0);  

      } 

      else {

        digitalWrite(48, 1); 

      }

    } 

    else {

      digitalWrite(48, 1);  // Sets color of button to RED if Fade To Black is activated

    }

  } 

  else {

    digitalWrite(48, 0);  // Dimmed background if no fade to black

  }

}

thos-berlin's picture
Offline

Location

berlin
Germany
Joined: 19/06/2012
Posts: 483
Change the code inside if/then/else-construct

I think, you only have to change the code inside the needed branches of your if/then/else-construct. So the following may work.... I hope, I did no mistake during copy-paste, but I marked the code for blinking, what you have to use instead of constant lightning,

if (AtemSwitcher.getFadeToBlackState()) { // Setting button color. This is a more complex example which includes blinking during execution:
if (AtemSwitcher.getFadeToBlackTime()>0 && (AtemSwitcher.getFadeToBlackFrameCount()!=AtemSwitcher.getFadeToBlackTime())) { // It's important to test if fadeToBlack time is more than zero because it's the kind of state from the ATEM which is usually not captured during initialization. Hopefull this will be solved in the future.
// Light if Fade To Black is executing:

digitalWrite(48, 1); // Sets color of button to RED
 
}
else { 

// The following part does the blinking using the internal timer
// -----------------------------------------------------------------------------
// Blinking, if Fade To Black is activated
if ((unsigned long)millis() & B10000000) {   // this part realizes the blinking  using the internal timer
digitalWrite(48, 0);
}
else {
digitalWrite(48, 1);
}

//  End of blinking part
// ---------------------------

 
}
}
else {
digitalWrite(48, 0); // Dimmed background if no fade to black
}
}

Thomas  S e e w a l d - thos-berlin (amateur)

Offline

Location

Adelaide,
Australia
Joined: 19/02/2014
Posts: 59
Thanks very much.

Thanks Thomas, much appreciated. It does the trick nicely. Goes to show that it helps when you know what you are doing.

Cheers

Offline

Location

Toronto
Canada
Joined: 19/08/2015
Posts: 3
Sorry to hijack an old

Sorry to hijack an old thread, but the question I have is very similar. The condition:

 

if (AtemSwitcher.getFadeToBlackTime()>0 && (AtemSwitcher.getFadeToBlackFrameCount()!=AtemSwitcher.getFadeToBlackTime())) {

}

 

Doesn't seem to do anything in my sketch. No matter the state of the FTB, it always results FALSE. I can get the LED to change color as the FTB is fading in or out (using .getFadeToBlackState(), however the above condition will not work. Is there any other way to check if the FTB is active?

 

Thanks!

Offline

Location

Leeds
United Kingdom
Joined: 12/07/2015
Posts: 81
ATEMext.h

Probably not ideal as this potentially means re-writing some your code but you asked if there was ANY other way :)

If you use the more up to date ATEMext.h instead of ATEMstd.h then you can use:

AtemSwitcher.getFadeToBlackStateInTransition(0)

and

AtemSwitcher.getFadeToBlackStateFullyBlack(0)

ATEM 2 M/E 4K, ATEM 1 M/E 4K, HyperDeck Studio Pro 4K, DeckLink Mini Recorder

Custom SKAARHOJ based controller

 

Offline

Location

Toronto
Canada
Joined: 19/08/2015
Posts: 3
Ext VS Std
bradders wrote:

If you use the more up to date ATEMext.h instead of ATEMstd.h

 

Oh wow. I wasn't aware that the library I was using was outdated. I did a quick search , and it seems there's not nearly as many resources on this new library. Before I try and attempt to convert my code, is there any significant advantage to switcing over?

 

Thank you!

 

 

Offline

Location

Copenhagen
Denmark
Joined: 03/09/2012
Posts: 35
Have a look at

http://skaarhoj.com/fileadmin/BMDPROTOCOL.html to learn more about the new libraries. 

On the site is also a small explenation of the different libraries.

Have fun :-)

Bjørn E. Thorup // Engineering and Marketing, http://skaarhoj.com

Offline

Location

Toronto
Canada
Joined: 19/08/2015
Posts: 3
Thanks!

I just wanted to give a quick thanks to bradders and BjornT. I was able to upgrade my code to the newer AtemExt library in an afternoon, and all the functionality now works, including the previously mentioned problems with the FTB status.

 

Thanks again!

Offline

Location

London,
United Kingdom
Joined: 15/09/2015
Posts: 6
Still Stuck

Hi

Wonder if anyone can help ?  Im a bit stuck - 

Is there an example with the new library that shows the FTB staying flashing when FTB is pressed -- No matter what I try I cannot get it to stay illuminated -- I can get it to flash when active but thats all.  Also when I use the new library I get lots of memory errors and cannot really get the examples 

For example with ATEMext installed library and ATEMextMonitor as the example - When I compile I get this error which I have to be honest Im clueless about. 

ATEMextMonitor.cpp.o: In function `setup':
/Users/paulbaird/ATEMextMonitor.ino:56: undefined reference to `freeMemory'
collect2: error: ld returned 1 exit status
Multiple libraries were found for "Streaming.h"
 Used: /Users/paulbaird/Documents/Arduino/libraries/ATEMmax
 Not used: /Users/paulbaird/Documents/Arduino/libraries/Arduino-Library-for-ATEM-Switchers-master
Multiple libraries were found for "ATEMext.h"
 Used: /Users/paulbaird/Documents/Arduino/libraries/ATEMext
 Not used: /Users/paulbaird/Documents/Arduino/libraries/Arduino-Library-for-ATEM-Switchers-master
Error compiling.
 
 

BTW - Fantastic resource I have some functions working like T-Bar with a real T-Bar.  - So very happy to have found it.   Just struggling to get the new library working

 

 

 

Offline

Location

Leeds
United Kingdom
Joined: 12/07/2015
Posts: 81
FTB Flashing

Below is part of the program I use on my system.  This lights the LED when FTB is in transition and flashes when it's fully black.

I used the "elapsedMillis.h" library which you'll need to download and install. Also note that my LED is connected so LOW is on and HIGH is off.

I hope this helps!!

 

Before "void setup()"

#include <elapsedMillis.h>

 

elapsedMillis timer1;

const int FTBLED = 40;                   // Pin that FTBLED is attached to

unsigned int flashInterval = 200;     // Speed of flashing LEDs

 

In "void loop()"

// Fade To Black LED
  if (AtemSwitcher.getFadeToBlackStateFullyBlack(0) || AtemSwitcher.getFadeToBlackStateInTransition(0))  {
    if (AtemSwitcher.getFadeToBlackStateFullyBlack(0)){
      if (timer1 > flashInterval) {
        timer1 = 0;                                                   // reset the timer
        int FTBLEDpin = digitalRead(FTBLED);     // read the current state
        digitalWrite(FTBLED, !FTBLEDpin);           // write the opposite state
      }
    }
    else {
      digitalWrite(FTBLED, LOW);                    // LED ON
    }
  }
  else {
    digitalWrite(FTBLED, HIGH);                     // LED OFF
  }

ATEM 2 M/E 4K, ATEM 1 M/E 4K, HyperDeck Studio Pro 4K, DeckLink Mini Recorder

Custom SKAARHOJ based controller

 

Offline

Location

Vanløse
Denmark
Joined: 08/10/2011
Posts: 102
Thanks for sharing,

Thanks for sharing, bradders,

 

When I need a flashing light, I usually go with something like 

 

digitalWrite(LED, millis()&256?true:false)

This would blink around twice a second. If you use the value 512 instead, it would be slower. If you used 768 instead, it would blink asymmetrically. Try it out. Maybe even "digitalWrite(LED, millis()&256)" works. However, I would that if you do "millis()256>0?true:false" then it won't work, you would then need to put parenthesis around like "(millis()&256)>0?true:false". This is all arduino stuff and from top of my head.

I like the simplicity of the above solution. You need to stick to using numbers link 256, 512 etc which has just a single "1" in it's binary representation, but that is ok with me. The only drawback I have experienced is that you cannot control the timing of the first blink. Say you want your FTB button to start lighting up the moment the transition starts; you have no guarantee for that with my solution because "millis()&256" could be false for half a second when the transition starts.

 

Well, try it and see what you like.

 

- kasper

Offline

Location

London,
United Kingdom
Joined: 15/09/2015
Posts: 6
Many thanks

Hi,

Firstly many thanks for this I can see some light

 -  I realise that I need to use the new library to make use of the functions AtemSwitcher.getFadeToBlackStateInTransition(0)

However when install that ATEMext library and use the ATEMextMonitor example I get a compile error. 

ATEMextMonitor.cpp.o: In function `setup':
/Users/paulbaird/ATEMextMonitor.ino:56: undefined reference to `freeMemory'
collect2: error: ld returned 1 exit status
Error compiling.
 
 
My C is OK - Just OK so Im a little lost as to what it could be . ?. 
 
Can I also ask a dumb question .. 
 
Is it possible to use the T-BAR example   (Which I believe uses the atem.h library)    yet add in the Atemext library to that example ?
 
Thanks for looking at this - I wish my C ability was as good as you guys - But its 20 years since I did much coding so to say Im rusty is an understatement ..
 

Offline

Location

Leeds
United Kingdom
Joined: 12/07/2015
Posts: 81
Libraries

Have you definitely installed all of the libraries from https://github.com/kasperskaarhoj/SKAARHOJ-Open-Engineering ?

Including "MemoryFree.h"?

ATEM 2 M/E 4K, ATEM 1 M/E 4K, HyperDeck Studio Pro 4K, DeckLink Mini Recorder

Custom SKAARHOJ based controller

 

Offline

Location

London,
United Kingdom
Joined: 15/09/2015
Posts: 6
Libraries

Thanks - Well I thought I had -  But nope .. 

I downloaded the ZIP - then I pulled the extracted files to the folder where I keep everything - but they were in a sub folder -  Hence the IDE could not find the correct files - When I move them to the root - It works

 

Thanks

 

Offline

Location

roma,
Italy
Joined: 11/08/2017
Posts: 5
HI. I'm trying to make a

HI. I'm trying to make a t-bar with the arduino anologic port and a 10k slider. can someone help me? Do you have a sketch to give me a bookcase?