Home AMX User Forum NetLinx Studio

put a level to hex value

Hello

Iam trying to put a level from 0 to 255 to use into a string that have to be in hex.

The value i have to send in hex is beteen -79 to +12.

I don't know how to do it, because it is all new for me.

Can someone tell me how i can do it.

txxs

Comments

  • TurnipTruckTurnipTruck Posts: 1,485
    If you want to send a decimal value in hex, you don't need to do anything special.
    SEND_STRING dvDevice,"nValue"
    

    If NValue =100, this will be interpreted as sending a hex 64... "$64" in AMX speak.
    SEND_STRING dvDevice,"FORMAT('%02X',nValue)"
    

    Sends literal hex. The device will receive '64'
  • ericmedleyericmedley Posts: 4,177
    Germt wrote: »
    Hello

    Iam trying to put a level from 0 to 255 to use into a string that have to be in hex.

    The value i have to send in hex is beteen -79 to +12.

    I don't know how to do it, because it is all new for me.

    Can someone tell me how i can do it.

    txxs

    Let's see if my math skills still work...

    $-79 to $12 is $8C steps, I think... (140 decimal)
    255=$FF. (fader goes from 0 to 255)

    So incoming volume = nvol

    nvol=nvol+79 // (make it a positive scale)

    fader_value=(nvol / $8C) * $FF




    Now you can change the touch panels fader range in TPD4 as well. That uses less math. I personally like to leave my faders default on the panel. the math doesn't scare me and it keeps me honest.
Sign In or Register to comment.