Pango Script "if / then"

Discussion in 'PangoScript, Universe and Midi Templates' started by tobias2016, Feb 25, 2016.

  1. tobias2016

    tobias2016 Member

    Hi there,

    is it possible to paste a if/then code for another action?
    I want, when i rotate a encoder wheel that a button show a color in different % cases.

    For example:
    Encoder B0 30 XX -> Button 90 20 XX
    Encoder = 0% -> Off
    Encoder = 25% -> red
    Encode = 50% -> yellow

    thanks for your answers
     
  2. hitekvoop

    hitekvoop Well-Known Member

    I know an ugly way to do it... Sure wish I knew all the programming constructs and operators, etc available in pangoscript, is there a doc available that explains things like conditionals, etc?

    Anyway, here's my ugly hack job, someone please come along and make it better so I can learn.

    1. Create a Wheel in the universe and give it <somename>, set min value 0, max value 100

    2. In the pangoscript section of the midi input settings for your encoder, add:
    Code:
    <universe>.<somename>.Value=extvalue(0,100)
    
    3. Create a new pangoscript in the right side tab area like:
    Code:
    CodeName "mycode"
    AutoStart
    if (<universe>.<somename>.Value < 25) midiout 90 20 <off>
    if ((<universe>.<somename>.Value >=25)  & (<universe>.<somename>.Value<50)) midiout 90 20 <red>
    if (<universe>.<somename>.Value >= 50) midiout 90 20 <yellow>
    restart
    
     
  3. tobias2016

    tobias2016 Member

    Thanks for your answer you are right vergy ugly :)
    So you spoke, there are a documentation about pango script? do you mean the 2 site doc in the help topic? :D or a really help file...
     
    Last edited: Feb 27, 2016
  4. tobias2016

    tobias2016 Member

    I found another way :)

    DmxOut 1, param(3)*2
    if (param(3)*2 = 0) MidiOut 0x90, 0x00, 0x00
    if (param(3)*2 > 1) MidiOut 0x90, 0x00, 0x40
     
  5. hitekvoop

    hitekvoop Well-Known Member

    Ah, sweet! That makes sense. I guess I can grab any passed value with param()? never knew ;) Thanks!
     
  6. neutrino

    neutrino Well-Known Member

    Can someone explain how this code works please.
    I'm not sure of the param(3)*2 part

    Cheers
    Rich

     
  7. tobias2016

    tobias2016 Member

    Hey Rich,

    Midi sends Channel Data from 1 to 127
    DMX sends Chanel Data from 1 to 255

    param(3)*2 use the third (3) byte of Midi multiplication with (2) = 254
    so you can use 254 steps and not 127

    this is good for dmx lamps which have a complex dmx table in one channnel
    (RGB,Strobe,Macro,etc.)
     
  8. neutrino

    neutrino Well-Known Member

    Thanks for the explanation, now it makes sense.

    Cheers
    Rich
     

Share This Page