Skip to content

Instantly share code, notes, and snippets.

@imorrish
Created July 5, 2018 03:52
Show Gist options
  • Select an option

  • Save imorrish/716173c0a2c76cc4440b313ab04c73f7 to your computer and use it in GitHub Desktop.

Select an option

Save imorrish/716173c0a2c76cc4440b313ab04c73f7 to your computer and use it in GitHub Desktop.
ATEM program tally using PowerShell and Arduino
$host.ui.RawUI.WindowTitle = “Arise Tally Monitor”
$stayActive = $true
#Wait for ATEM to be online
Do{
Start-Sleep -Seconds 10
}
Until(Test-Connection -ComputerName "10.1.1.240" -Quiet)
add-type -path 'C:\vise\SwitcherLib.dll'
$Global:atem = New-Object SwitcherLib.Switcher("10.1.1.240")
$atem.Connect()
$me=$atem.GetMEs()
$Global:me1=$me[0]
$Global:me2=$me[1]
add-type -path 'C:\vise\Solid.Arduino.dll'
$connection = New-Object Solid.Arduino.SerialConnection("COM3",[Solid.Arduino.SerialBaudRate]::Bps_57600)
$Global:session = New-Object Solid.Arduino.ArduinoSession($connection, 2000)
#Tally lights default to all on so you can unplug ones you don't want on if system fails
$session.SetDigitalPin(11,$true)
$session.SetDigitalPin(12,$true)
$session.SetDigitalPin(13,$true)
$Global:activeME = $me2
$Global:Program = $activeME.Program
$Global:Preview = $activeME.Preview
$Global:Program = 0
$timer = New-Object System.Timers.Timer
$timer.Interval = 100
$timer.AutoReset = $true
$sourceIdentifier = "TimerJob"
$timerAction = {
if($Global:me1.Program -eq 10020 -And $Global:activeME -eq $Global:me1){
$Global:activeME = $Global:me2
New-BurntToastNotification -Text "ATEM ME1 Un isolated"
}
elseif($Global:me1.Program -ne 10020 -And $Global:activeME -eq $Global:me2){
$Global:activeME = $Global:me1
New-BurntToastNotification -Text "ATEM ME1 isolated"
}
$CurrentProgram = $Global:activeME.Program
if($Global:Program -ne $Global:activeME.Program){
if($Global:Program -gt 1 -And $Global:Program -lt 5){
#turn off current LED
$Global:session.SetDigitalPin($Global:Program + 9,$true)
}
if($CurrentProgram -gt 1 -And $CurrentProgram -lt 5){
#turn on new program led
$Global:session.SetDigitalPin($CurrentProgram + 9,$false)
}
$Global:Program = $Global:activeME.Program
}
}
Unregister-Event $sourceIdentifier -ErrorAction SilentlyContinue
$timer.stop()
$start = Register-ObjectEvent -InputObject $timer -SourceIdentifier $sourceIdentifier -EventName Elapsed -Action $timeraction
$timer.start()
# $activeME.Program=6000
if ($host.name -ne 'Windows PowerShell ISE Host') # or -notmatch 'ISE'
{
Do{Start-Sleep -Milliseconds 100}
while($stayActive)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment