Volume Slider constantly changing without touching?
vegastech
Posts: 369
I just implemented my first active slider (I don't think I'll do this at a job other than my own home), and it works great when I select a section of the slider. A problem has come in where I dragged the slider up, and now it is constantly adjusting itself up and down regardless of what I try and do. I am watching my variable go up and down in debug mode. How do I get it to stop?!?! I don't recall adding any drag programming.
0
Comments
LEVEL_EVENT[dvJVCLT37X898Tp,2]
{
nTVVOL=LEVEL.VALUE
SEND_COMMAND vdvJVCLT37X898, "'PASSTHRU-!',$82,$80,'VL',itoa(nTVVOL*50/255),$0A"
SEND_LEVEL dvJVCLT37X898Tp,2,nTVVOL
}
I am doing a *50/255 because the TV has discrete volume from 1-50. This way I get the proper % on my bargraph.
Also, in regards to displaying a percentage you can use the '$P' escape sequence in the button text and it will calculate the percentage on the panel. You can then just set your min and max values to relate to the values that the device supports. This will remove unnessecary overhead from providing a control granularity higher than the parameter granularity.
You could also change the bargraph range low to 1 and range high to 50 so you don't need to do any math.
There are also different bargraph settings to allow drag or not. If you're going to use a bargraph to send volume level use should use the drag since it acts as a safety net preventing accidential ramping to full volume if the top of the bargraph is mistakenly tapped. It also provide a limit by stopping after the amount a range is reached. I personally like up and down buttons for ramping with a couple presets for volume control and leave the bargraphs for things like lights or camera PTZ.
And yes, remove the SEND_LEVEL from the Level Event; what you've done is create a feedback loop. If you get strings back from the device (unless of course it is IR) when the level changes without any input from the panel, parse the level value out of the string and send it back to the panel in a DATA_EVENT. Make sure to differentiate the responses from when the Level changes YOU send the unit, from when the Level changes are External (if there is a difference in the responses), otherwise you will be back to square one with your dancing bargraphs.
Example (arbitrary values used, no real protocol):
String to Unit: " SETLEVEL 60, $0d "
String from Unit " ACK-LEVELSET 60, $0d, $0a "
When sent from the AMX
String from Unit " LEVELSET60, $0d, $0a "
When changed on the Unit itself, e.g. thru a remote.
If there's a serial command to increment the level by say 1.0dB or 1%, that may be easier than sending a direct value. When a Level changes on a panel and you send that level to the unit, you could be sending a whole barrage of commands to the unit and its getting confused. E.g. going from 20 to 40 on the Bargraph might actually send at least 20 strings all at the same time to the Unit.
1. The presets work, but as I try to watch the array variable change/update in the watch bar, it is always set to 0, never changes. (I'm not sure how the presets are working.)
2. What button type do I need to use on my panel in order for the preset buttons to show the percentage once it is saved? I have it set to a general type button, and added $P for the text, but it doesn't work.
[code]
DEFINE_VARIABLE
NON_VOLATILE INTEGER nTVVOL
PERSISTENT INTEGER nVolPre[3]
BUTTON_EVENT[dvJVCLT37X898Tp,405] //vol preset 1
BUTTON_EVENT[dvJVCLT37X898Tp,406] //vol preset 2
BUTTON_EVENT[dvJVCLT37X898Tp,407] //vol preset 3
{
HOLD[20]: //If Button is Held for 2 seconds
{
nVolPre[BUTTON.INPUT.CHANNEL-404] = nTVVOL
SEND_COMMAND dvJVCLT37X898Tp,'ADBEEP' //double beeps panel
}
RELEASE:
{
//SEND_COMMAND vdvJVCLT37X898, "'PASSTHRU-!',$82,$80,'VL',itoa(nVolPre[1]),$0A"
SEND_LEVEL dvJVCLT37X898Tp, 2, nVolPre[BUTTON.INPUT.CHANNEL-404] //This sends the level to the touchpanel, which in turn sends the command to the tv to adjust volume. See the level event below for more info.
}
}
LEVEL_EVENT[dvJVCLT37X898Tp,2]
{
nTVVOL=LEVEL.VALUE
SEND_COMMAND vdvJVCLT37X898, "'PASSTHRU-!',$82,$80,'VL',itoa(nTVVOL),$0A"
}
[\code]
The '$P' escape sequence will only work on the volume control (or other button assigned that level code). To show the levels on your preset buttons you will need to use the '^TXT' command. All the info you need about it is in AMX PI.
--John
There's more you could do but at least this will keep the last button pushed for this device as your hold button and not the last button pushed system wide which could be any device from another TP.
2 seconds is a short amount of time for the hold to execute but it is possible that in that time someone else will push a button on another TP for any number of devices and your BIC value will then be something you don't want.
Here an option for condensing. Use a button array and use more of the indexing power.
yes, you will notice that any STACK_or LOCAL_VARs you try to put into a HOLD will not 'colour' correctly. It'll work (kinda) but isn't the Best Practice.
then when you want to address a value in the array use nPRESETS [room number] [preset value index]
You could set up constants for the room numbers to make is easier to read.
Or you could use a structure...over to you eric!
I'll post a fuller example later