Why Doesnt my send level not work
Gfull
Posts: 19
I was wondering if i'm changing the volume on the processor and parsing the data out to an variable (in this case cVolume), shouldn't this update my bargraph if i use the send level in an active statement.
The Parsing does work i can see cvolume update with the right info instantly whenever i hit volume up or down.
dTP[2] is 10002:1:0
The Bargraph is set to passive with a range of 0-255, level port 1, level code 1
Another thing i'm not sure about is how to convert the values in cVolume which range from hex 0C (+12db) to hex B0 (-80) to something that i can display in the bargraph with a range of 0-255 or 0-100.
Any help will be appreciated
DATA_EVENT [dvSerial_MC8]
{
ONLINE:
{
send_command dvSerial_MC8, "'SET BAUD 19200,O,8,1'"
send_command dvSerial_MC8, "'HSOFF'"
send_command dvSerial_MC8, "'XOFF'"
send_command dvSerial_MC8, "'CHARD-0'"
}
STRING:
{
LOCAL_VAR CHAR cTRASH[100]
LOCAL_VAR CHAR cStatus_Buffer[100]
SELECT
{
ACTIVE(FIND_STRING(cMC8_Buffer,"$F1,$07,$05,$04,$14,$01,$06",1)):
{
cStatus_Buffer=REMOVE_STRING(cMC8_Buffer,"$F2",FIND_STRING(cMC8_Buffer,"$F1,$07,$05,$04,$14,$01,$06",1))
cVOLUME=MID_STRING(cStatus_Buffer,8,1)
SEND_LEVEL dTP[2],1,ATOI(cVOLUME)
}
}
CLEAR_BUFFER cMC8_Buffer
}
}
The Parsing does work i can see cvolume update with the right info instantly whenever i hit volume up or down.
dTP[2] is 10002:1:0
The Bargraph is set to passive with a range of 0-255, level port 1, level code 1
Another thing i'm not sure about is how to convert the values in cVolume which range from hex 0C (+12db) to hex B0 (-80) to something that i can display in the bargraph with a range of 0-255 or 0-100.
Any help will be appreciated
DATA_EVENT [dvSerial_MC8]
{
ONLINE:
{
send_command dvSerial_MC8, "'SET BAUD 19200,O,8,1'"
send_command dvSerial_MC8, "'HSOFF'"
send_command dvSerial_MC8, "'XOFF'"
send_command dvSerial_MC8, "'CHARD-0'"
}
STRING:
{
LOCAL_VAR CHAR cTRASH[100]
LOCAL_VAR CHAR cStatus_Buffer[100]
SELECT
{
ACTIVE(FIND_STRING(cMC8_Buffer,"$F1,$07,$05,$04,$14,$01,$06",1)):
{
cStatus_Buffer=REMOVE_STRING(cMC8_Buffer,"$F2",FIND_STRING(cMC8_Buffer,"$F1,$07,$05,$04,$14,$01,$06",1))
cVOLUME=MID_STRING(cStatus_Buffer,8,1)
SEND_LEVEL dTP[2],1,ATOI(cVOLUME)
}
}
CLEAR_BUFFER cMC8_Buffer
}
}
0
Comments
The sign bit is the most significant bit. If it is 1 the value is negative and 0 for positive. If positive the value is directly representing the integer. If negative, subtract 1 and do a binary not. Then the value represents the unsigned integer of the negative value.
Just tried and no i don't see any level events happening in device notifications. Still don't see why the send level isn't working.
Can you put up the DEV array for dTP[2] ?
Also, you might put a boink in the Select/Active statement to see if the condition is genuinely ever met.
I will put send_command dv_panel,'adbee' sometimes or send_string(o),'it happened' or something of that nature.
You can't send the value in cvolume because it's not an integer equivalent. -80db is $B0 = 176 and $0C is +12.
Sure... its down below and i tried a test statement earlier
dvTP1 = 10001:1:0
dvTP2 = 10002:1:0
dev dTP[] = {dvTP1,dvTP2}
Here is the full string that comes back whenever you change the volume
F1,7,5,4,14,1,6,F6,F2
The only value that changes is position 8 (F6) regardless if its a negative value or not
i hope you can forgive my limited understanding of 2's compliment and all.. but i only see one byte changing
And i thought that by using Atoi it would change the value to a signed integer or do i have to do slong atoi
What is the current range of the bar graph in the touchpanel? All negative values will be greater than 128.
11111111 = -1
00000001 = 1 so
$B0 = 10110000 but because the 8th bit is on, it's a negative number.
So subtract 1 from $B0 and you get $AF = 10101111 Ones complement is 01010000
Which is 80 without the sign.
range low =0
range high =255
Here's how you program it.
Our range would be 92 (80 + 12)
If (cVolume band $80) //negative value
{
cVolume = 80 - (bnot (cVolume -1))
}
else
{
cVolume = 80 + cVolume
}
BarVolume = (cVolume*255)/92
Something like this. I'm sure there's typos.
Thanks KB I'll give it a shot
I'm getting warnings on using a char in a math operation.. and i cant parse the data to a integer.. is there a way to convert a char to an integer and achieve the same results
I seem to remember using ITOHEX and HEXTOI, but I think there was a problem getting a 'real' volume number back - i.e. it was fine getting e.g. $0A and converting it to an Integer 10. But then I couldn't relate that to the actual dB value as I couldn't then convert that ASCII 10 into -55, I got a 'NO CONVERSION FOR DOUBLE PRECISION' warning from the notifications whether my variable was a SINTEGER, a FLOAT, or a DOUBLE.
That generally means a CHAR array, not a simple CHAR ... you can do math on simple CHARs. If you have it in double quotes, it will be treated like string (CHAR array) of size one, so that is something to look for as well.