Home AMX User Forum AMXForums Archive Threads Tips and Tricks
Options

itohex and volume

I am controlling a beyerdynamic mcsd 200 which has volume control . Sample volume commands are

03 0D 3B 01 vol 59
03 0D 00 01 vol 0
03 0D 01 01 vol 1
03 0D 02 01 vol 2 and so

now i have written a level event like this
LEVEL_EVENT[virtualTPBeyerdynamicMCSD200,1]
{
send_string dvBeyerdynamicMCSD200,"$03,$0D,itohex(level.value) ,$01"

}

itohex gives the proper hex value but the device doesnt take it but if i give the full string, the device takes .So i am forced to write switch case for each level.value, is there any other way ??

Comments

  • Options
    AMXJeffAMXJeff Posts: 450
    John Paul wrote: »
    I am controlling a beyerdynamic mcsd 200 which has volume control . Sample volume commands are

    03 0D 3B 01 vol 59
    03 0D 00 01 vol 0
    03 0D 01 01 vol 1
    03 0D 02 01 vol 2 and so

    now i have written a level event like this
    LEVEL_EVENT[virtualTPBeyerdynamicMCSD200,1]
    {
    send_string dvBeyerdynamicMCSD200,"$03,$0D,itohex(level.value) ,$01"

    }

    itohex gives the proper hex value but the device doesnt take it but if i give the full string, the device takes .So i am forced to write switch case for each level.value, is there any other way ??

    You are misunderstanding what ITOHEX does. ITOHEX takes an integer and converts it to an ASCII string.

    integer X = 59;

    // NOTICE THE SINGLE QUOTES

    ITOHEX(X) = '3B'

    // so this is what ITOHEX is doing here.
    send_string dvBeyerdynamicMCSD200,"$03,$0D,'3B' ,$01"

    You are trying to send this message.

    send_string dvBeyerdynamicMCSD200,"$03,$0D,$3B ,$01"

    ///////////////////////////////////////

    this is actually a very common misunderstanding among new programmers.

    all you really have to do is this...

    send_string dvBeyerdynamicMCSD200,"$03,$0D,level.value,$01"

    I know you are saying, but 59 is not in hex? What you need to realize is that 59 = $3B, no conversation to hex is needed. Matter of fact, the only thing that cares that it is not in hex is you. The serial port actually sends each byte in binary and the device you controlling receive each byte in binary. it is mearly just for display purposes in code.

    // these are the same
    send_string dvBeyerdynamicMCSD200,"$03,$0D,59,$01"

    send_string dvBeyerdynamicMCSD200,"$03,$0D,$3B,$01"
  • Options
    John PaulJohn Paul Posts: 143
    thanks Jeff, with 5 yrs of experience and i still dont know the basics, i suck , i ve to improve soon
  • Options
    ericmedleyericmedley Posts: 4,177
    John Paul wrote: »
    thanks Jeff, with 5 yrs of experience and i still dont know the basics, i suck , i ve to improve soon

    John Paul,
    don't sweat it! On this forum, if you show any weakness, you get cut to shreds. But, we're all pretty much in the same boat. We've all done goofy things and learned 'noob' stuff every day. I still learn stuff I never knew. That's why I come here.
  • Options
    AMXJeffAMXJeff Posts: 450
    ericmedley wrote: »
    John Paul,
    don't sweat it! On this forum, if you show any weakness, you get cut to shreds. But, we're all pretty much in the same boat. We've all done goofy things and learned 'noob' stuff every day. I still learn stuff I never knew. That's why I come here.

    DITTO... Was not ment to belittle, just to enlighten.
  • Options
    ericmedleyericmedley Posts: 4,177
    AMXJeff wrote: »
    DITTO... Was not ment to belittle, just to enlighten.
    Oh, I wasn't aiming at you... It was more a generalized response. You are always polite and a gentleman and scholar! :D
  • Options
    Thanks guys

    Sure i know you guys meant well
Sign In or Register to comment.