def _onAir():
    state = request.args.get('state')
    if state=="on":
        clock.setInd(0, 1)
    else:
        clock.setInd(0, 0)
    return ""
def _timer():
    global timerState
    global timeRemaining
    global sumupTime
    global durationTime
    
    state = request.args.get('state')
    
    if state=="start":     
        if timeRemaining <= 0:
            durationTime = int(request.args.get('duration')) * 60
            sumupTime = int(request.args.get('sumup')) * 60
            timeRemaining = durationTime
        timerState = True
        
    elif state=="stop":
        timerState = False
        
    elif state=="clear":
        timerState = False

        timeRemaining = 0

        clock.setInd(1, 0)			# Clear Indicators
        clock.setInd(2, 0)
        clock.setInd(3, 0)	        
    return ""
def indicators_timer():
    global timeRemaining
    global timerState
    global sumupTime

    while True:
        if timerState == True:
            timeRemaining -= 1
            
            if timeRemaining > sumupTime:
                clock.setInd(1, 1)			# "Talk"
                clock.setInd(2, 0)
                clock.setInd(3, 0)	
            elif timeRemaining <= sumupTime and timeRemaining > 0:				
                clock.setInd(1, 0)			# "Sum-up"
                clock.setInd(2, 1)
                clock.setInd(3, 0)
            elif timeRemaining <= 0:
                clock.setInd(1, 0)			# "Stop"
                clock.setInd(2, 0)
                clock.setInd(3, 1)
                timerState = False
                 
        time.sleep(1)