0

HELP ME PLEASE flash leds under the looping



Hello there, I am newbe with BrightSign Script and usage, so I need Some HELP for BrightSign HD1010. I would like to create a video and along the playing I want some leds to flash up every 5 seconds where do I have to start? How I have to modificate this script to work? p = CreateObject("roMessagePort") tmr = CreateObject("roMessagePort") gpio = CreateObject("roGpioControlPort") gpio.SetPort(p) gpio.EnableOutput(0) gpio.EnableOutput(1) gpio.EnableOutput(2) gpio.EnableOutput(3) gpio.EnableOutput(4) gpio.EnableOutput(5) gpio.EnableOutput(6) gpio.EnableOutput(7) imag.png:gpios(1;2;5) event_loop: imag.png:gpios(1;2;5) gpio.SetOutputState(butn+1,1) print "LED FLASHES ";gpioPort sleep(500) gpio.SetOutputState(butn+1,0) sleep(500) gpio.SetOutputState(butn+2,1) print "LED FLASHES ";gpioPort sleep(500) gpio.SetOutputState(butn+2,0) goto event_loop THX

15 comments

  • 0
    Avatar
    RokuLyndon


    imag.png:gpios(1;2;5)


    THis gpios command you're trying to use only works in a csv file.


    To flash leds during playback, you need to add timer events to the video itself. If you look in the object reference guide, at roaudioevent and rovideoevent there's also a section that talks about adding timerevents to a video, and then listening for them to occur.
  • 0
    Avatar
    darksigns


    thank you Lyndon for your kind HELP!
  • 0
    Avatar
    darksigns


    The problem is that if I make a simple autorun.brs with one single line: print "hello" nothing happens,

    and this would be the script to display an image and than flas a led is the code good because I can't try it nothing happens if I take it into the HD210

    print "BrightSign LED Test"
    p = CreateObject("roMessagePort")
    gpio = CreateObject("roControlPort")  
    gpio.SetPort(p)
    gpio.EnableOutput(1)
    DisplayFile("vista.jpg")
    wait (100)    
    gpio.SetOutputState(1,1)
    print "Led1 Flash ON"
    msg = wait (500, tmr)
    gpio.SetOutputState(1,0)
    print "Led1 Flash OFF"
  • 0
    Avatar
    darksigns


    how can I see if there is an error in the script?
    is there any debug mode?
  • 0
    Avatar
    darksigns


    print "TEST LED SCRIPT"
    wait(100)
    v = CreateObject("roVideoPlayer")
    p = CreateObject("roMessagePort")
    v.SetPort(p)
    gpio.SetPort(p)
    ok = v.AddEvent(2, 2000)  
    ok = v.AddEvent(5, 5000)
    ok = v.AddEvent(10, 10000)
    ok = v.AddEvent(100, 100000)
    ok = v.PlayFile("america.ts")
    loop:
    msg = wait(0,p)        
    If msg.GetInt() = 8 then stop    
    If msg.GetInt() <> 12 Goto loop
    If msg.GetInt() = 12 and AddEvent = 2 then Goto led1
    If msg.GetInt() = 12 and AddEvent = 5 then Goto led2
    If msg.GetInt() = 12 and AddEvent = 10 then Goto led3
    If msg.GetInt() = 12 and AddEvent = 100 then Goto led4
    led1:
    gpio.SetOutputState(0,1)
    print "LED1 ON"
    wait(100)
    gpio.SetOutputState(0,0)
    print "LED1 OFF"
    EndIf
    Goto loop
    led2:
    gpio.SetOutputState(1,1)
    print "LED2 ON"
    wait(100)
    gpio.SetOutputState(1,0)
    print "LED2 OFF"
    EndIf
    Goto loop
    led3:
    gpio.SetOutputState(2,1)
    print "LED3 ON"
    wait(100)
    gpio.SetOutputState(2,0)
    print "LED3 OFF"
    EndIf
    Goto loop
    led4:
    gpio.SetOutputState(3,1)
    print "LED4 ON"
    wait(100)
    gpio.SetOutputState(3,0)
    print "LED4 OFF"
    EndIf
    Goto loop
    EndIf
    EndIf
  • 0
    Avatar
    darksigns


    Hello Lyndon, I have dreamed my code last night:
    but something wrong yet,
    code:
    v = CreateObject("roVideoPlayer")
    p = CreateObject("roMessagePort")
    v.SetPort(p)
    gpio.SetPort(p)
    ok = v.AddEvent(2, 2000)  
    ok = v.AddEvent(5, 5000)
    ok = v.AddEvent(10, 10000)
    ok = v.AddEvent(100, 100000)
    ok = v.PlayFile("america.ts")
    loop:
    msg = wait(0,p)        
    If msg.GetInt() = 8 then stop    
    If msg.GetInt() <> 12 Goto loop
    If msg.GetInt() = 12 and AddEvent = 2 then Goto led1
    If msg.GetInt() = 12 and AddEvent = 5 then Goto led2
    If msg.GetInt() = 12 and AddEvent = 10 then Goto led3
    If msg.GetInt() = 12 and AddEvent = 100 then Goto led4
    led1:
    gpio.SetOutputState(0,1)
    print "LED1 ON"
    wait(100)
    gpio.SetOutputState(0,0)
    print "LED1 OFF"
    End If
    Goto loop
    led2:
    gpio.SetOutputState(1,1)
    print "LED2 ON"
    wait(100)
    gpio.SetOutputState(1,0)
    print "LED2 OFF"
    End If
    Goto loop
    led3:
    gpio.SetOutputState(2,1)
    print "LED3 ON"
    wait(100)
    gpio.SetOutputState(2,0)
    print "LED3 OFF"
    End If
    Goto loop
    led4:
    gpio.SetOutputState(3,1)
    print "LED4 ON"
    wait(100)
    gpio.SetOutputState(3,0)
    print "LED4 OFF"
    End If
    Goto loop
    End If
    End If
    could you plese advise me where is the wrong statment?
  • 0
    Avatar
    RokuLyndon


    I am working on this but need to finish testing. There's a bug i this script but this is what it's going to look like...

    debug = true

    if debug print "BrightSign LED Test"
    p = CreateObject("roMessagePort")
    gpio = CreateObject("roGpioControlPort")
    v=createobject("roVideoPlayer")
    v.SetPort(p)

    REM Setting GPIOs for output
    if debug print "Setting GPIOs 1-4 for output"
    gpio.EnableOutput(1)
    gpio.EnableOutput(2)
    gpio.EnableOutput(3)
    gpio.EnableOutput(4)

    REM Add events
    REM We might need tomove these to after start
    if debug print "Adding timecode events for playback trigger"
    v.AddEvent(1, 6000)
    v.AddEvent(2, 12000)
    v.AddEvent(3, 18000)
    v.AddEvent(4, 24000)


    start:
    if debug print "Starting video..."
    v.PlayFile("film.ts")


    Listen:
    if debug print "Listening for timecode events"
    msg = wait(0,p)
    if type(msg) = "roVideoEvent" then
    if debug print "Video event ";msg.GetInt()
    if msg.GetInt() = 12 then
    if debug print "Timecode event ";msg.GetData()
    if msg.GetData() > 0 and msg.GetData() <5 then
    gpio.SetOutputState(msg.GetData(), true)
    if debug print "Turning GPIO";str(msg.GetData());"on."
    endif
    sleep(100)
    gpio.SetOutputState(msg.GetData(), false)
    if debug print "Turning GPIO off."

    elseif msg.GetInt() = 8 then
    if debug print "Video finished, restarting"
    goto start
    endif
    endif
    goto listen
  • 0
    Avatar
    darksigns


    Thank you Lyndon
    I tried the script and it seems it works:))))
    I moved the sugessted part after the start:

    and I figured out an interesting thing!!!

    if I boot roku without card I cant mount it after and therefor dir command can't find it
    if I take my scrips and the film to the card, at the boot roku starts the film and can't command roku till I reboot it
    if I make a blank autorun.brs  than I can command my script and see debug console:))))))))

    THANK YOU FOR YOUR KIND HELP IN THIS AND I HOPE IT WILL HELP ANYBODY ELSE TOO!!!!!!!!!!!!
  • 0
    Avatar
    RokuLyndon


    The numbers in the add event need to be updated to reflect the correct amount of time. They're missing one zero. So, 6000 is only 6 seconds. Change it to 60000 for the whole minute.
  • 0
    Avatar
    darksigns


    Thank You,
    I would like to ask one more thing please chek the script if i would like to wait until an input comes from gpio(5) I made the changing and it waits but the film plays once first and then it waits for input. could you please tell me what is wrong? here is your script with my lines:

    debug = true

    if debug print "BrightSign LED Test"
    p = CreateObject("roMessagePort")
    gpio = CreateObject("roGpioControlPort")
    v=createobject("roVideoPlayer")
    v.SetPort(p)

    REM Setting GPIOs for output
    if debug print "Setting GPIOs 1-4 for output and 5 for input"
    gpio.EnableOutput(1)
    gpio.EnableOutput(2)
    gpio.EnableOutput(3)
    gpio.EnableOutput(4)
    gpio.EnableInput(5)

    start:
    if debug print "Starting video..."
    v.PlayFile("film.ts")

    REM Add events
    REM We might need tomove these to after start
    if debug print "Adding timecode events for playback trigger"
    v.AddEvent(1, 1000)
    v.AddEvent(2, 2000)
    v.AddEvent(3, 3000)
    v.AddEvent(4, 4000)

    Listen:
    if debug print "First Listening for input and than Listening for timecode events"
    msg = wait(0,p)
    if gpio.IsInputActive(5) = true then
    if type(msg) = "roVideoEvent" then
    if debug print "Video event ";msg.GetInt()
    if msg.GetInt() = 12 then
    if debug print "Timecode event ";msg.GetData()
    if msg.GetData() > 0 and msg.GetData() <5 then
    gpio.SetOutputState(msg.GetData(), true)
    if debug print "Turning GPIO";str(msg.GetData());"on."
    endif
    sleep(50)
    gpio.SetOutputState(msg.GetData(), false)
    if debug print "Turning GPIO off."

    elseif msg.GetInt() = 8 then
    if debug print "Video finished, restarting"
    goto start
    endif
    endif
    endif
    goto listen
  • 0
    Avatar
    RokuLyndon


    I don't understand.

    DO you  mean you don't want to play the video until input 5 has been pressed? Or, you want to play, but you don't want to use the timecode triggers until input 5 has been pressed?

    if you can outline the behavior you want, I can change it.
  • 0
    Avatar
    darksigns


    Oh sorry, YES
    I mean I want to wait till an input on gpio 5 comes then the video would start and the leds would flash same as in the first code.
  • 0
    Avatar
    darksigns


    debug = true

    if debug print "BrightSign LED Test"
    p = CreateObject("roMessagePort")
    gpio = CreateObject("roGpioControlPort")
    v=createobject("roVideoPlayer")
    v.SetPort(p)

    REM Setting GPIOs for output
    if debug print "Setting GPIOs 1-4 for output and 5 for input"
    gpio.EnableOutput(1)
    gpio.EnableOutput(2)
    gpio.EnableOutput(3)
    gpio.EnableOutput(4)
    gpio.EnableInput(5)

    if gpio.IsInputActive(5) = true then<<------Must I take this code here to test if sensor on gpio(5) is active?

    start:
    if debug print "Starting video..."
    v.PlayFile("film.ts")

    REM Add events
    REM We might need tomove these to after start
    if debug print "Adding timecode events for playback trigger"
    v.AddEvent(1, 1000)
    v.AddEvent(2, 2000)
    v.AddEvent(3, 3000)
    v.AddEvent(4, 4000)

    Listen:
    if debug print "First Listening for input and than Listening for timecode events"
    msg = wait(0,p)
    if gpio.IsInputActive(5) = true then
    if type(msg) = "roVideoEvent" then
    if debug print "Video event ";msg.GetInt()
    if msg.GetInt() = 12 then
    if debug print "Timecode event ";msg.GetData()
    if msg.GetData() > 0 and msg.GetData() <5 then
    gpio.SetOutputState(msg.GetData(), true)
    if debug print "Turning GPIO";str(msg.GetData());"on."
    endif
    sleep(50)
    gpio.SetOutputState(msg.GetData(), false)
    if debug print "Turning GPIO off."

    elseif msg.GetInt() = 8 then
    if debug print "Video finished, restarting"
    goto start
    endif
    endif
    endif
    goto listen
  • 0
    Avatar
    RokuLyndon


    IsInputActive() actually checks if the button is being held down. THis is what you need:

    -we create a playback variable that's set to false by default
    -We add gpio.SetPort(p) so we can listen for button inputs
    -We skip over start and go to listening
    -Under listen, we check if there's a button press, and if the playback hasn't been enabled yet, meaning no button 5 press, we enable it, and then go to start. We then ignore button 5 after that.


    debug = true

    if debug print "BrightSign LED Test"
    p = CreateObject("roMessagePort")
    gpio = CreateObject("roGpioControlPort")
    gpio.SetPort(p)
    v=createobject("roVideoPlayer")
    v.SetPort(p)

    REM Setting GPIOs for output
    if debug print "Setting GPIOs 1-4 for output"
    gpio.EnableOutput(1)
    gpio.EnableOutput(2)
    gpio.EnableOutput(3)
    gpio.EnableOutput(4)
    gpio.EnableInput(5)


    REM Variable
    playback_enabled=false


    REM Add events
    REM We might need tomove these to after start
    if debug print "Adding timecode events for playback trigger"
    v.AddEvent(1, 6000)
    v.AddEvent(2, 12000)
    v.AddEvent(3, 18000)
    v.AddEvent(4, 24000)


    REM
    REM Skip to Listening for button input, don't start yet
    REM
    goto listen


    start:
    if debug print "Starting video..."
    v.PlayFile("film.ts")


    Listen:
    if debug print "Listening for timecode events"
    msg = wait(0,p)


    if type(msg) = "roVideoEvent" then
    if debug print "Video event ";msg.GetInt()

    if msg.GetInt() = 12 then
    if debug print "Timecode event ";msg.GetData()
    if msg.GetData() > 0 and msg.GetData() <5 then
    gpio.SetOutputState(msg.GetData(), true)
    if debug print "Turning GPIO";str(msg.GetData());"on."
    endif
    sleep(100)
    gpio.SetOutputState(msg.GetData(), false)
    if debug print "Turning GPIO off."

    elseif msg.GetInt() = 8 then
    if debug print "Video finished, restarting"
    goto start

    endif


    elseif type(msg) = "roGpioButton" and playback_enabled = false then
    if msg.GetInt() = 5 then
    playback_enabled=true
    goto start
    endif

    endif


    goto listen
  • 0
    Avatar
    darksigns


    THANK YOU I will try it on monday:)
Please sign in to leave a comment.