advice on levels
Spire_Jeff
Posts: 1,917
Ok, here's my problem. I have two touchpanels. Both have control over multiple rooms with different receivers. I have a single active bargraph button on each one. The volume level being displayed is dependant on the room selected. I have worked almost all of the bugs out of the system, but I have two small issues and I'm hoping someone here has a little more experience with levels.
First issue is when I'm using the hard buttons to step the volume. If I move the volume more than one step at a time, the volume will sort of flutter (ie, the volume will go 35, 36,37,38,37,38,37,38,39,40,39,40,41).
Second issue is when I adjust the volume on the bargraph. Sometimes, the bargraph moves to the position I want and when I let go, the bargraph jumps back to the original setting. This seems to only happen if I do relatively quick changes, if I hold a position for a second or so it seems to take every time.
I think both of these issues are linked in someway to the updating of the bargraph by the processor, but I'm wondering if anyone has any tips when dealing with levels.
Also, all of the devices are not directly controlled with levels. I have to send discrete levels in the level event.
here are some snippets of code in case this helps:
Here is the code that handles the two devices that seem to be most problematic.
Thanks,
Jeff
First issue is when I'm using the hard buttons to step the volume. If I move the volume more than one step at a time, the volume will sort of flutter (ie, the volume will go 35, 36,37,38,37,38,37,38,39,40,39,40,41).
Second issue is when I adjust the volume on the bargraph. Sometimes, the bargraph moves to the position I want and when I let go, the bargraph jumps back to the original setting. This seems to only happen if I do relatively quick changes, if I hold a position for a second or so it seems to take every time.
I think both of these issues are linked in someway to the updating of the bargraph by the processor, but I'm wondering if anyone has any tips when dealing with levels.
Also, all of the devices are not directly controlled with levels. I have to send discrete levels in the level event.
here are some snippets of code in case this helps:
LEVEL_EVENT[dvTP1_2,1] { nVOL_CHANGE_IN_PROGRESS = 1 SWITCH(nCURRENT_ROOM[1]) { CASE 3: CASE 4: { CANCEL_WAIT 'REF50_VOL' IF(LEVEL.VALUE <99) nVOL_TO_REF50 = LEVEL.VALUE ELSE nVOL_TO_REF50 = 99 WAIT 2 'REF50_VOL' { SEND_STRING dvBK_REF50,"'(0,S,P1=FF,1=',ITOHEX(nVOL_TO_REF50),';)'" nVOL_CHANGE_IN_PROGRESS = 0 } } CASE 7: { CANCEL_WAIT 'INTEG_VOL' IF(LEVEL.VALUE <99) nVOL_TO_INTEG = LEVEL.VALUE ELSE nVOL_TO_INTEG = 99 WAIT 2 'INTEG_VOL' { SEND_COMMAND vdvINTEGRA,"'VOLUME=',ITOA(nVOL_TO_INTEG)" nVOL_CHANGE_IN_PROGRESS = 0 } } DEFAULT: { CANCEL_WAIT 'CT610_VOL' nVOL_TO_CT610[1][1] = nCURRENT_ZONE[1] nVOL_TO_CT610[1][2] = (LEVEL.VALUE/5)*2 WAIT 2 'CT610_VOL' { SEND_COMMAND vdvBK_CT610,"'ZONE',ITOA(nVOL_TO_CT610[1][1]),':VOL=',ITOA(nVOL_TO_CT610[1][2])" nVOL_CHANGE_IN_PROGRESS = 0 } } } }
Here is the code that handles the two devices that seem to be most problematic.
DATA_EVENT[dvBK_REF50] { STRING: { STACK_VAR INTEGER nZONE STACK_VAR INTEGER nVOL STACK_VAR INTEGER x IF(FIND_STRING(DATA.TEXT,'(0,R,P',1)) { REMOVE_STRING(DATA.TEXT,',P',1) nZONE = ATOI(DATA.TEXT) IF(FIND_STRING(DATA.TEXT,'=FF',1)) { IF(FIND_STRING(DATA.TEXT,',1=',1)) { REMOVE_STRING(DATA.TEXT,',1=',1) IF(FIND_STRING(DATA.TEXT,',',1)) nVOL = HEXTOI(REMOVE_STRING(DATA.TEXT,',',1)) ELSE nVOL = HEXTOI(REMOVE_STRING(DATA.TEXT,';',1)) IF(nVOL>98) nVOL = 99 FOR(x=1;x<= NUMBER_OF_TOUCHPANELS;x++) { IF((nCURRENT_ROOM[x] = 3 OR nCURRENT_ROOM[x] = 4) && !(nVOL_CHANGE_IN_PROGRESS)) SEND_LEVEL dvTP_AV[x],1,nVOL } } } } } } DATA_EVENT[vdvINTEGRA] { STRING: { STACK_VAR INTEGER nZONE STACK_VAR INTEGER nVOL STACK_VAR INTEGER x IF(FIND_STRING(DATA.TEXT,'VOLUME=',1)) { REMOVE_STRING(DATA.TEXT,'VOLUME=',1) nVOL = ATOI(DATA.TEXT) FOR(x=1;x<= NUMBER_OF_TOUCHPANELS;x++) { IF(nCURRENT_ROOM[x] = 7 && !(nVOL_CHANGE_IN_PROGRESS)) SEND_LEVEL dvTP_AV[x],1,nVOL } } } }
Thanks,
Jeff
0
Comments
I had a little bit of grief recently with active bargraphs (it was actually a scrollbar, but same thing from the NetLinx perspective). When I moved around, I'd sometimes get erratic behavior. I understood what was going on though.
My interface has the following elements: Scroll up (one page), scroll down (one page), scroll to end, scroll to start, or allow level feedback. (In your case, you can "scroll up" or "scroll down" by adjusting volume incrementally.)
I believe that the problem you're having is that the level handler is firing when you do the SEND_LEVEL event. In my case, that caused unintended code execution (for the event), causing timing issues, particularly when "scrolling" quickly.
In my case, I had a module that was doing the SEND_LEVEL event, and mainline was capturing the LEVEL_EVENT via a handler. So what I did was this:
1. When I did the SEND_LEVEL event, I set a channel on the vd used for module communications,
2. Modified the LEVEL_EVENT handler to check if the channel was set on the vd. If so, clear the chanel and otherwise do nothing, like this:
This is horribly simplified, but you get the gist. In your case, you could just set a variable after you do the SEND_LEVEL and then clear it in the level handler.
Try this, let me know if it solves your problem. I believe it will.
Makes my ears and my boss much happier.
Jeff