itohex and volume
John Paul
Posts: 143
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 ??
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 ??
0
Comments
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"
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.
Sure i know you guys meant well