Lua script RGB

Discussion in 'C-Bus Automation Controllers' started by peterauto, Jan 30, 2022.

  1. peterauto

    peterauto

    Joined:
    Jan 30, 2022
    Messages:
    1
    Likes Received:
    0
    Hi guys,

    I have a customer that wants their dmx lights to run through the NAC on a scene. They require just a loop scene of the transition of the rgb colours.

    I am unfamiliar with lua language to a large degree.

    Does anyone have a basic script template of a loop scene for rgb that I can play around with?

    Thanks!
     
    peterauto, Jan 30, 2022
    #1
  2. peterauto

    Northy

    Joined:
    Apr 8, 2018
    Messages:
    9
    Likes Received:
    1
    Hi peterauto.

    I did something similar several years ago with RGB LED strip controlled via DALI. I created 7 x Scenes (Off, Red, Yellow, Green, Cyan, Blue, Purple) mixing the RGB colours and fade times, and the Script Triggers the scenes. It's been while since I looked at that code and am a bit rusty on LUA myself but this may be of some help.

    The 1st LUA Script below is a simple version. The only thing is with this is that it will run this script is running it will need to complete all colours in order when you want it to stop.


    Cbus LUA Script for RGB Auto Colour Change

    while (GetCBusState(0,56,1) == true) do

    SetTriggerLevel(0,255) -- Red

    os.sleep(30)

    SetTriggerLevel(0,204) -- Yellow

    os.sleep(30)

    SetTriggerLevel(0,242) -- Green

    os.sleep(30)

    SetTriggerLevel(0,178) -- Cyan

    os.sleep(30)

    SetTriggerLevel(0,229) -- Blue

    os.sleep(30)

    SetTriggerLevel(0,191) -- Purple

    os.sleep(30)

    end


    The 2nd is a little more complicated but will stop the script when the colour changing script is stopped anyway part though the script.

    --This sets the timer. Variable input determines the seconds this will pause the script for.

    -- If a scene change occurs a true is returned within 1 second. Otherwise will take variable

    -- seconds to run.

    function RGBTimer(seconds)

    local i = 0
    while (i < seconds) do

    os.sleep(1)

    i = i + 1

    if (GetCBusState(0,56,7) == false) then

    return true

    end

    end

    return false

    end

    while (GetCBusState(0,56,7) == true) do

    SetTriggerLevel(9,255) -- Red

    local x = RGBTimer(4)

    if (x == true) then

    break

    end

    SetTriggerLevel(9,204) -- Yellow

    x = RGBTimer(4)

    if (x == true) then

    break
    end

    SetTriggerLevel(9,242) -- Green

    x = RGBTimer(4)

    if (x == true) then

    break
    end

    SetTriggerLevel(9,178) -- Cyan

    x = RGBTimer(4)

    if (x == true) then

    break
    end

    SetTriggerLevel(9,229) -- Blue

    x = RGBTimer(4)
    if (x == true) then

    break

    end

    SetTriggerLevel(9,191) -- Purple

    x = RGBTimer(4)

    if (x == true) then

    break
    end


    end
     
    Northy, Feb 6, 2022
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.