Changing parsed values from Hex to Dec
mkleynhans
Posts: 78
Hi there,
How to I change Hex values to true decimal for feedback?
I am parsing values from my av amp and they are being displayed as '0D' for 13, '1F' for
31 etc.
I want to display these as the standard decimal values and eventually use these values
for displaying volume feeback in percentage format.
Many thanks in advance.
Mike
How to I change Hex values to true decimal for feedback?
I am parsing values from my av amp and they are being displayed as '0D' for 13, '1F' for
31 etc.
I want to display these as the standard decimal values and eventually use these values
for displaying volume feeback in percentage format.
Many thanks in advance.
Mike
0
Comments
I have added the following code;
DATA_EVENT [dvOnkyo]{
string:
{
stack_var char cMsg[50]
SELECT
{
ACTIVE (find_string (data.text,'!1MVL',1)):
{
cString = data.text
cVolume = mid_string (cString,22,2)
cVolumeActual = HEXTOI(cVolume);
SEND_COMMAND dvtp, "'^TXT-100,0,',(cVolumeActual)"
}
}
}
}
but this seems to be sending things like / for 47, . for 46, - for 45 etc. etc so its converting them
to Chr on a Hex table and not Decimal..
Back to the drawing board, or in my case trawling forums and begging for help
-John
I think it's working properly. You're starting off with an ascii representation of a hex, something like '2F'. The HEXTOI() function is converting that to an integer value (47) and storing it as cVolume Actual. Then, you are displaying the ASCII code associated with 47 on your touchpanel. What you need to do us present the ASCII representation of the 47 and you do that with the ITOA() function:
SEND_COMMAND dvtp, "'^TXT-100,0,', ATOI(cVolumeActual)" Edit WRONG! should be: ITOA(cVolumeActual)
To display an integer in human readable form, use ITOA() To perform an arithmetic calculation on an integer, just do it.
as John says, check out the format() function. It presents a lot more control over what the resulting string looks like than does ITOA()
Try something like this - it should help you parse the remaining responses very easily.
-John
Thanks so much for the help, I would never have got the ,itoa(hextoi( bit.
It works like a thing of beauty )
I will keep reading the Netlinx Reference Guide and am looking forward to
my L2. Hopefully then wont have to keep bugging you guys for answers.
Next step for me is to get the level_event feeding back to the volume
bargraph!!
Thanks again,
Mike
How you send the level will matter on how the level is setup on your touch panel. By default, I believe the low value is zero and the high is 255. I prefer to set it to 0-100 while keeping track of my own variable. You'll soon find out that the response from the AVR, no matter it being serial or Ethernet, will be not be snappy. In fact, I believe you get a volume status change every half second, which depending on how quickly you send a volume up command could be anywhere between 2-3 volume steps up per half second. So, instead of your bargraph reading 51-52-53-54-55 as you volume up, if you depend on the feedback it will read something along the lines of 51-53-56, etc. and it will change slowly. To me this is unacceptable, especially if you have an actual bargraph, it will look too jittery.
*Note - this is true for Integra devices, I know Onkyos they are the same exact piece, so YMMV.
That all being said, I would store a volume variable and then send a direct volume command to the receiver. So instead of a MVLUP command, I'd use MVL2B, MVL2C, MVL2D, etc. etc. and update the bargraph based on my volume variable. You could rely on the volume feedback level for when the receiver powers up, but I usually set it to a specific turn on volume. This way, I always know where it's at.
Just my 2-cents.