Hold Button Event Issues by using own module
ajish.raju
Posts: 185
I am trying to do a hold event from a module and i am not able to work. But if i write the code without a module, it works perfectly. What am i doing wrong here. Please see my code examples.
1. Without module
2. With module
1. Without module
BUTTON_EVENT [dvSFLivingTP,btSerial_Plasma_6] { HOLD[2,REPEAT]: { SWITCH(get_last(btSerial_Plasma_6)) { CASE 41:send_string dvSFLivingSerial_Plasma_3,"'LEFT00', $0D,$0A"// INCREASE VOLUME CASE 42:send_string dvSFLivingSerial_Plasma_3,"'RGHT00', $0D,$0A"// DECREASE VOLUME } } Release: { SWITCH(get_last(btSerial_Plasma_6)) { CASE 41:send_string dvSFLivingSerial_Plasma_3,"'LEFT00', $0D,$0A"// INCREASE VOLUME CASE 42:send_string dvSFLivingSerial_Plasma_3,"'RGHT00', $0D,$0A"// DECREASE VOLUME } } }
2. With module
PROGRAM_NAME='iSFLivingAquavisionTV' #include 'iSFLivingSystemDevices.axi' #include 'iSFLivingSystemVariables.axi' DEFINE_VARIABLE DEFINE_MODULE 'Aquavision TV_Comm' AquavisionTV_Comm (dvSFLivingTP, dvSFLivingSerial_Plasma_3,btSerial_Plasma_6,nAquavisionType) DEFINE_EVENT // UI events BUTTON_EVENT [dvSFLivingTP,btSerial_Plasma_6] { HOLD[2,REPEAT]: { SWITCH(get_last(btSerial_Plasma_6)) { CASE 41: DO_PUSH (dvSFLivingTP, 1152) CASE 42:DO_PUSH (dvSFLivingTP, 1151) } } Release: { SWITCH(get_last(btSerial_Plasma_6)) { CASE 41:DO_Release (dvSFLivingTP, 1152) CASE 42:DO_Release (dvSFLivingTP, 1151) } } } MODULE_NAME='Aquavision TV_Comm'(DEV dvTP_DPS[],DEV dvDevice,integer nCHAN_BTN[],integer nType) define_start rebuild_event() DEFINE_EVENT DATA_EVENT[dvDevice] { ONLINE: { send_command dvDevice,"'TSET BAUD 9600,N,8,1 485 disable'" if(nType=2) send_command dvDevice,"'CHARD-20'" } } BUTTON_EVENT[dvTP_DPS,nCHAN_BTN] { Hold [2,REPEAT]: { if(nType==1) { switch(GET_LAST(nCHAN_BTN)) { CASE 24:send_string dvDevice,"'RGHT00', $0D,$0A"// DECREASE VOLUME CASE 25:send_string dvDevice,"'LEFT00', $0D,$0A"// INCREASE VOLUME } }else { switch(GET_LAST(nCHAN_BTN)) { CASE 24:send_string dvDevice,"'rght00', $0D,$0A"// DECREASE VOLUME CASE 25:send_string dvDevice,"'left00', $0D,$0A"// INCREASE VOLUME } } } RELEASE: { if(nType==1) { switch(GET_LAST(nCHAN_BTN)) { CASE 24:send_string dvDevice,"'RGHT00', $0D,$0A"// DECREASE VOLUME CASE 25:send_string dvDevice,"'LEFT00', $0D,$0A"// INCREASE VOLUME } }else { switch(GET_LAST(nCHAN_BTN)) { CASE 24:send_string dvDevice,"'rght00', $0D,$0A"// DECREASE VOLUME CASE 25:send_string dvDevice,"'left00', $0D,$0A"// INCREASE VOLUME } } } }
0
Comments
I probably use do_push timed more than do_push and often use 1 (1/10th second) for my time otherwise if I push a button that uses do_push and immediately release I can"t press and issue another push until the first push times out the default .5 seconds. That is of course unless your force the release with do_release which I always do too.
Example of my axi:
Example of my axs (module)
So, main code:
And inside the module:
I think I gravitated towards the button_event method simply because it can work exactly the same as if you had it in the main code if done correctly and I don't need to use timelines. Of course I don't think I ever thought of using a "to" with a push to work the channel ON/OFF, or even tried to see if that would work on a button event in a module instead of using do_push. In fact I really haven't used "to" for anything since my early days of programming and I have no idea why. Maybe it was "to" easy and I just felt the need to over complicate things.