Need some help MSP 8
ondrovic
Posts: 217
I am having some issues with the followng code can someone give me some advise
Problems:
1. Feeback for button 8 isnt wokring
2. Having to hit button 5 for the power to actually cut off
3. Button 8 ( which is source 5 needs to be input # 7)
thanks
Problems:
1. Feeback for button 8 isnt wokring
2. Having to hit button 5 for the power to actually cut off
3. Button 8 ( which is source 5 needs to be input # 7)
PROGRAM_NAME='keypads' (***********************************************************) (* System Type : NetLinx *) (***********************************************************) (* REV HISTORY: *) (***********************************************************) (***********************************************************) (* DEVICE NUMBER DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_DEVICE dvSwitcher = 5001:4:1 /// Ada Switcher * RS232 dvCd = 5001:9:1 /// Denon DCM 280 * IR dvSatM = 5001:10:1 /// Direct TV D11 dvTuner1 = 5001:2:1 /// Z-Tuner : Zone 1 * RS232 dvTuner2 = 5001:3:1 /// Z-Tuner : Zone 2 * RS232 dviPort = 5001:1:1 /// vdviPort = 33015:1:1 /// dvMSP1 = 6001:1:1 /// Guest Room # 6 dvMSP2 = 6002:1:1 /// Guest Room # 7 dvMSP3 = 6003:1:1 /// Kitchen dvMSP4 = 6004:1:1 /// Loggia dvMSP5 = 6005:1:1 /// Pool dvMSP6 = 6006:1:1 /// Guest Bedroom # 1 dvMSP7 = 6007:1:1 /// Guest Bedroom # 2 dvMSP8 = 6008:1:1 /// Guest Bedroom # 3 dvMSP9 = 6009:1:1 /// Guest Bedroom # 4 dvMSP10 = 6010:1:1 /// Her Master Bathroom dvMSP11 = 6011:1:1 /// His Master Bathroom dvMSP12 = 6012:1:1 /// Master Bedroom dvMSP13 = 6013:1:1 /// Ocean Porch vdvMSP1 = 33021:1:1 vdvMSP2 = 33022:1:1 vdvMSP3 = 33023:1:1 vdvMSP4 = 33024:1:1 vdvMSP5 = 33025:1:1 vdvMSP6 = 33026:1:1 vdvMSP7 = 33027:1:1 vdvMSP8 = 33028:1:1 vdvMSP9 = 33029:1:1 vdvMSP10 = 33030:1:1 vdvMSP11 = 33031:1:1 vdvMSP12 = 33032:1:1 vdvMSP13 = 33033:1:1 gdvTP = 7000:1:1 (***********************************************************) (* CONSTANT DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_CONSTANT INTEGER nMSP_SC_Buttons[]= { 1, /// Tuner 2, /// CD 3, /// Sat Music ( XM ) 4, /// Request 8 /// Ipod } Integer nMSP_PWR_Button[]= { 5 /// Power Off } INTEGER nMSP_VOL_Buttons[]= { 6, /// Volume UP 7 /// Volume Down } (***********************************************************) (* DATA TYPE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_TYPE (***********************************************************) (* VARIABLE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_VARIABLE CHAR strWhPwr[18] INTEGER nKPButton INTEGER nKPIndex INTEGER nKPAddress INTEGER nZnSc[18] INTEGER nMute[18] INTEGER nZoneSc CHAR strDebug[255] (* IPOD *) VOLATILE INTEGER TP_BUTTONS[] = // Touchpanel button mapping array { // CHANNEL BUTTONS / Place Holder / Function 101, //01 Menu 102, //02 Select 103, //03 Play/Pause 104, //04 Offline/Online 105, //05 Previous<< 106, //06 Next>> 107, //07 108, //08 109, //09 List up 10 110, //10 List up 1 111, //11 List Down 1 112, //12 List Down 10 113, //13 List 1 114, //14 List 2 115, //15 List 3 116, //16 List 4 117, //17 List 5 118, //18 List 6 119, //19 List 7 120, //20 List 8 121, //21 List 9 122, //22 List 10 123, //23 Repeat 124, //24 Shuffle 125, //25 Playlist 126, //26 Now Playing 127, //27 List Level 130 //28 nothing } VOLATILE INTEGER TP_FIELDS[]= // VARIABLE TEXT BUTTONS { //Addres Codes / Place Holder / Function 100, //01 iPod Name 101, //02 List 01 102, //03 List 02 103, //04 List 03 104, //05 List 04 105, //06 List 05 106, //07 List 06 107, //08 List 07 108, //09 List 08 109, //10 List 09 110, //11 List 10 111, //12 Playing x of y 112, //13 Artist 113, //14 Album 114, //15 Track 115, //16 Time 116, //17 Repeat 117, //18 Shuffle 118, //19 Play Status 119, //20 List x of y 120 //21 Pathway } PERSISTENT INTEGER UI_LIST[] = {10,2,0} // See below: - not implemented in 1.0 Beta (* All Key Pads *) DEV dvKp[] = {vdvMSP1, vdvMSP2, vdvMSP3, vdvMSP4, vdvMSP5, vdvMSP6, vdvMSP7, vdvMSP8, vdvMSP9, vdvMSP10, vdvMSP11, vdvMSP12, vdvMSP13} (* Zone 1 *) DEV dvKPZn1[] = {vdvMSP1, vdvMSP2, vdvMSP3, vdvMSP4, vdvMSP5, vdvMSP6, vdvMSP7, vdvMSP8, vdvMSP9, vdvMSP13} (* Zone 2 *) DEV dvKPZn2[] = {vdvMSP10, vdvMSP11, vdvMSP12} (***********************************************************) (* LATCHING DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_LATCHING (***********************************************************) (* MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_MUTUALLY_EXCLUSIVE ([vdvMSP1,1] .. [vdvMSP1,5]) ([vdvMSP2,1] .. [vdvMSP2,5]) ([vdvMSP3,1] .. [vdvMSP3,5]) ([vdvMSP4,1] .. [vdvMSP4,5]) ([vdvMSP5,1] .. [vdvMSP5,5]) ([vdvMSP6,1] .. [vdvMSP6,5]) ([vdvMSP7,1] .. [vdvMSP7,5]) ([vdvMSP8,1] .. [vdvMSP8,5]) ([vdvMSP9,1] .. [vdvMSP9,5]) ([vdvMSP10,1] .. [vdvMSP10,5]) ([vdvMSP1,11] .. [vdvMSP11,5]) ([vdvMSP1,12] .. [vdvMSP12,5]) ([vdvMSP1,13] .. [vdvMSP13,5]) (***********************************************************) (* SUBROUTINE/FUNCTION DEFINITIONS GO BELOW *) (***********************************************************) (* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *) (* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *) DEFINE_CALL 'Zone On' { SWITCH(nZoneSc) { CASE 1: { SEND_STRING dvTuner1,"'W 1 1 1',13" /// Turn On Tuner Zone 1 PULSE[dvCD,1] /// Play On CD Player /// Sat Music Power On DO_PUSH(gdvTP,200) /// Request Zone 1 Connect WAIT 5 { DO_PUSH(gdvTP,25) /// Request Zone 1 Play } DO_PUSH(gdvTP,104) /// I-Pod Connect WAIT 10 { DO_PUSH(gdvTP,103) } SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLR1R0',ITOA(nKPIndex),13" SEND_STRING dvSwitcher,"'`SAD0',ITOA(nZnSc[nKPIndex]),'R0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLR1R',ITOA(nKPIndex),13" SEND_STRING dvSwitcher,"'`SAD0',ITOA(nZnSc[nKPIndex]),'R',ITOA(nKPIndex),13" } } } CASE 2: { SEND_STRING dvTuner2,"'W 1 1 1',13" /// Turn On Tuner Zone 2 PULSE[dvCD,1] /// Play On CD Player /// Sat Music Power On /// Request Zone 2 Connect /// Request Zone 2 Play /// I-Pod Connect SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLR1R0',ITOA(nKPIndex),13" SEND_STRING dvSwitcher,"'`SAD0',ITOA(nZnSc[nKPIndex]),'R0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLR1R',ITOA(nKPIndex),13" SEND_STRING dvSwitcher,"'`SAD0',ITOA(nZnSc[nKPIndex]),'R',ITOA(nKPIndex),13" } } } } ON[nKPAddress,nZnSc[nKPIndex]] strWhPwr[nKPIndex] = 'N' strDebug = 'Zone On Call Is Running' } DEFINE_CALL 'Zone Source' { SWITCH(nZoneSc) { CASE 1: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SAD0',ITOA(nZnSc[nKPIndex]),'R0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SAD0',ITOA(nZnSc[nKPIndex]),'R',ITOA(nKPIndex),13" } } } CASE 2: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SAD0',ITOA(nZnSc[nKPIndex]),'R0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SAD0',ITOA(nZnSc[nKPIndex]),'R',ITOA(nKPIndex),13" } } } } ON[nKPAddress,nZnSc[nKPIndex]] strDebug = 'Zone Source Call Is Running' } DEFINE_CALL 'Source Function' { SWITCH(nZoneSc) { CASE 1: { SWITCH(nKPButton) { CASE 1: /// Tuner Next Preset { SEND_STRING dvTuner1,"'W 1 3 3',13" BREAK } CASE 2: /// CD Next Track { PULSE[dvCD,4] BREAK } CASE 3: /// Sat Music Next Preset { BREAK } CASE 4: /// Request Next Track { DO_PUSH(gdvTP,32) BREAK } CASE 5: /// IPOD Next Track { DO_PUSH(gdvTP,106) BREAK } } BREAK } CASE 2: { SWITCH(nKPButton) { CASE 1: /// Tuner Next Preset { SEND_STRING dvTuner2,"'W 1 3 3',13" BREAK } CASE 2: /// CD Next Track { PULSE[dvCD,4] BREAK } CASE 3: /// Sat Music Next Preset { BREAK } CASE 4: /// Request Next Track { BREAK } CASE 5: /// IPOD Next Track { BREAK } } BREAK } } OFF[nKPAddress,nZnSc[nKPIndex]] WAIT 5 ON[nKPAddress,nZnSc[nKPIndex]] strDebug = 'Source Function Call Is Running' } DEFINE_CALL 'Zone Off' { IF(!(FIND_STRING(strWhPwr, 'N',1))) { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SRMOFR0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SRMOFR',ITOA(nKPIndex),13" } } SWITCH(nZoneSc) { CASE 1: { SEND_STRING dvTuner1,"'W 1 1 0',13" BREAK } CASE 2: { SEND_STRING dvTuner2,"'W 1 1 0',13" BREAK } } PULSE[dvCD,2] DO_PUSH(gdvTP,104) } strWhPwr[nKPIndex] = 'F' ON[nKPAddress,5] } (***********************************************************) (* STARTUP CODE GOES BELOW *) (***********************************************************) DEFINE_START (* Power Status MSPs *) strWhPwr = 'FFFFFFFFFFFFFFFFFF' (* MSP Modules *) DEFINE_MODULE 'MSPMod' modMSP1 (vdvMSP1, dvMSP1) DEFINE_MODULE 'MSPMod' modMSP2 (vdvMSP2, dvMSP2) DEFINE_MODULE 'MSPMod' modMSP3 (vdvMSP4, dvMSP3) DEFINE_MODULE 'MSPMod' modMSP4 (vdvMSP4, dvMSP4) DEFINE_MODULE 'MSPMod' modMSP5 (vdvMSP5, dvMSP5) DEFINE_MODULE 'MSPMod' modMSP6 (vdvMSP6, dvMSP6) DEFINE_MODULE 'MSPMod' modMSP7 (vdvMSP7, dvMSP7) DEFINE_MODULE 'MSPMod' modMSP8 (vdvMSP8, dvMSP8) DEFINE_MODULE 'MSPMod' modMSP9 (vdvMSP9, dvMSP9) DEFINE_MODULE 'MSPMod' modMSP10 (vdvMSP10, dvMSP10) DEFINE_MODULE 'MSPMod' modMSP11 (vdvMSP11, dvMSP11) DEFINE_MODULE 'MSPMod' modMSP12 (vdvMSP12, dvMSP12) DEFINE_MODULE 'MSPMod' modMSP13 (vdvMSP13, dvMSP13) (* MISC *) #INCLUDE 'Queue_and_Threshold_Sizes.axi' (* Touch Panel *) DEFINE_MODULE 'iPort_UI' IPORT_UI1(vdviPort, gdvTP, TP_BUTTONS, TP_FIELDS, UI_LIST) DEFINE_MODULE 'iPort COMM' IPORT_MODULE(vdviPort, dviPort) (* System Information Strings ******************************) (* Use this section if there is a TP in the System! *) (* SEND_COMMAND TP,"'!F',250,'1'" SEND_COMMAND TP,"'TEXT250-',__NAME__" SEND_COMMAND TP,"'!F',251,'1'" SEND_COMMAND TP,"'TEXT251-',__FILE__,', ',S_DATE,', ',S_TIME" SEND_COMMAND TP,"'!F',252,'1'" SEND_COMMAND TP,"'TEXT252-',__VERSION__" SEND_COMMAND TP,"'!F',253,'1'" (* Must fill this (Master Ver) *) SEND_COMMAND TP,'TEXT253-' SEND_COMMAND TP,"'!F',254,'1'" (* Must fill this (Panel File) *) SEND_COMMAND TP,'TEXT254-' SEND_COMMAND TP,"'!F',255,'1'" (* Must fill this (Dealer Info) *) SEND_COMMAND TP,'TEXT255-' *) (***********************************************************) (* THE EVENTS GO BELOW *) (***********************************************************) DEFINE_EVENT BUTTON_EVENT [dvKPZn1,nMSP_SC_Buttons] { PUSH: { nZoneSc = 1 } } BUTTON_EVENT [dvKPZn2,nMSP_SC_Buttons] { PUSH: { nZoneSc = 2 } } BUTTON_EVENT [dvKP,nMSP_SC_Buttons] { PUSH: { nKPButton = Get_Last(nMSP_SC_Buttons) nKPIndex = Get_Last(dvKP) nKPAddress = (nKPIndex + 33020) SELECT { ACTIVE(!(strWhPwr[nKPIndex] = 'N') AND nKPButton < 6): { nZnSc[nKPIndex] = nKPButton CALL 'Zone On' } ACTIVE(strWhPwr[nKPIndex] = 'N' AND nKPButton < 6 AND nKPButton = nZnSc[nKPIndex]): { CALL 'Source Function' } ACTIVE(strWhPwr[nKPIndex] = 'N' AND nKPButton < 6 AND !(nKPButton = nZnSc[nKPIndex])): { nZnSc[nKPIndex] = nKPButton CALL 'Zone Source' } } } HOLD[20]: { SWITCH(nZoneSc) { CASE 1: { SWITCH(nKPButton) { CASE 1: /// Tuner Previous Preset { SEND_STRING dvTuner1,"'W 1 3 4',13" BREAK } CASE 2: /// CD Next Disc { PULSE[dvCD,50] BREAK } CASE 3: /// Sat Music Previous Preset { BREAK } CASE 4: /// Request Next Album { BREAK } CASE 5: /// IPod Previous Track { IF(nZnSc = 5) { nZnSc[nKPIndex] = 7 } DO_PUSH(gdvTP,105) BREAK } } } CASE 2: { SWITCH(nKPButton) { CASE 1: /// Tuner Previous Preset { SEND_STRING dvTuner2,"'W 1 3 4',13" BREAK } CASE 2: /// CD Next Disc { PULSE[dvCD,50] BREAK } CASE 3: /// Sat Music Previous Preset { BREAK } CASE 4: /// Request Next Album { BREAK } CASE 5: /// IPod { IF(nZnSc = 5) { nZnSc[nKPIndex] = 7 } DO_PUSH(gdvTP,105) BREAK } } } } } } BUTTON_EVENT[dvKP,nMSP_VOL_Buttons] { PUSH: { nKPButton = Get_Last(nMSP_VOL_Buttons) nKPIndex = Get_Last(dvKP) nKPAddress = (nKPIndex + 33020) SWITCH(nZoneSC) { CASE 1: { SWITCH(nKPButton) { CASE 1: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLUPR0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLUPR',ITOA(nKPIndex),13" } } PULSE[nKPAddress,6] } CASE 2: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLDNR0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLDNR',ITOA(nKPIndex),13" } } PULSE[nKPAddress,7] } } } CASE 2: { SWITCH(nKPButton) { CASE 1: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLUPR0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLUPR',ITOA(nKPIndex),13" } } PULSE[nKPAddress,6] } CASE 2: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLDNR0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLDNR',ITOA(nKPIndex),13" } } } PULSE[nKPAddress,7] } } } } HOLD[2,REPEAT]: { SWITCH(nZoneSC) { CASE 1: { SWITCH(nKPButton) { CASE 1: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLUPR0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLUPR',ITOA(nKPIndex),13" } } PULSE[nKPAddress,6] } CASE 2: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLDNR0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLDNR',ITOA(nKPIndex),13" } } PULSE[nKPAddress,7] } } } CASE 2: { SWITCH(nKPButton) { CASE 1: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLUPR0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLUPR',ITOA(nKPIndex),13" } } PULSE[nKPAddress,6] } CASE 2: { SELECT { ACTIVE(nKPIndex < 10): { SEND_STRING dvSwitcher,"'`SVLDNR0',ITOA(nKPIndex),13" } ACTIVE(nKPIndex > 9): { SEND_STRING dvSwitcher,"'`SVLDNR',ITOA(nKPIndex),13" } } } PULSE[nKPAddress,7] } } } } } BUTTON_EVENT[dvKp,5] { PUSH: { nKPIndex = Get_Last(dvKP) nKPAddress = (nKPIndex + 33020) CALL 'Zone Off' } } (***********************************************************) (* THE ACTUAL PROGRAM GOES BELOW *) (***********************************************************) DEFINE_PROGRAM [vdvMSP1,5] = (strWhPwr[1] = 'F') [vdvMSP2,5] = (strWhPwr[2] = 'F') [vdvMSP3,5] = (strWhPwr[3] = 'F') [vdvMSP4,5] = (strWhPwr[4] = 'F') [vdvMSP5,5] = (strWhPwr[5] = 'F') [vdvMSP6,5] = (strWhPwr[6] = 'F') [vdvMSP7,5] = (strWhPwr[7] = 'F') [vdvMSP8,5] = (strWhPwr[8] = 'F') [vdvMSP9,5] = (strWhPwr[9] = 'F') [vdvMSP10,5] = (strWhPwr[10] = 'F') [vdvMSP11,5] = (strWhPwr[11] = 'F') [vdvMSP12,5] = (strWhPwr[12] = 'F') [vdvMSP13,5] = (strWhPwr[13] = 'F') (***********************************************************) (* END OF PROGRAM *) (* DO NOT PUT ANY CODE BELOW THIS COMMENT *) (***********************************************************)
thanks
0
Comments