GET command question

Discussion in 'C-Gate Developers' started by Roti, Dec 3, 2010.

  1. Roti

    Roti

    Joined:
    Jun 5, 2006
    Messages:
    33
    Likes Received:
    0
    Hi. Sorry if this is a dumb question.

    When using RAMP to a light group, you can specify the level as either 8-bit (0-255) or % (0-100).

    When reading a level back from a group with GET, it seems you can only get the 8-bit (0-255) level back.

    Is it possible to read back a % value instead by using GET differently ?

    I've written code around it by multiplying/dividing by 2.55 and rounding, but it creates occasional minor irregularities in a dynamic GUI which are a bit annoying if you're a perfectionist.

    Thanks
     
    Roti, Dec 3, 2010
    #1
  2. Roti

    MHeaton

    Joined:
    Apr 22, 2008
    Messages:
    104
    Likes Received:
    1
    Location:
    London
    The correct algorithm to convert from the integer to 255 is

    this.label = '' + ((100.0 * (level + 2)/255.0)-0.5).toFixed(0) + '%';

    (in JavaScript here)
     
    MHeaton, Dec 3, 2010
    #2
  3. Roti

    Mark

    Joined:
    Oct 28, 2004
    Messages:
    196
    Likes Received:
    1
    Location:
    Grenoble, France
    PercentToLevel

    There are logic functions to convert between percent and level:
    PC := LevelToPercent(Level);
    Level := PercentToLevel(PC);

    Mark.
     
    Mark, Dec 3, 2010
    #3
  4. Roti

    Roti

    Joined:
    Jun 5, 2006
    Messages:
    33
    Likes Received:
    0
    Thanks
     
    Roti, Dec 4, 2010
    #4
  5. Roti

    Roti

    Joined:
    Jun 5, 2006
    Messages:
    33
    Likes Received:
    0
    Thanks for help above. Another related question.

    When using the RAMP command, I've always used an absolute (0-255) 8 bit integer. I recently tried using a % value (0-100) as outlined in the C-Gate Manual but get a syntax error whenever I try it (in script or via telnet).

    eg

    ramp 254/56/10 255 0
    works fine

    ramp 254/56/10 100% 0
    give an error "(400 Syntax Error: Invalid integer parameter : (level)"

    Is there something very basic I'm doing wrong here, or has the ability to give ramp level as a % been removed ?

    Thanks.
     
    Roti, Dec 23, 2010
    #5
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.