Parasound zTuner
ondrovic
Posts: 217
I writing a program to handle the Parasound zTuner. I am having an issue tyring to use the system keypad for direct station entry.
The keypad will return the following
But the zTuner's command to go to a direct frequency is the following
Here is what I have so far but could really use some help getting it to parse correctly
Thanks
The keypad will return the following
92.7 -or- 100.7
But the zTuner's command to go to a direct frequency is the following
W 1 6 92 70 -or- W 1 6 100 70
Here is what I have so far but could really use some help getting it to parse correctly
PROGRAM_NAME='zTuner' (***********************************************************) (***********************************************************) (* FILE_LAST_MODIFIED_ON: 04/05/2006 AT: 09:00:25 *) (***********************************************************) (* System Type : NetLinx *) (***********************************************************) (* REV HISTORY: *) (***********************************************************) (* $History: $ 200ms delay between commands or unit will lock up Version 1: ---------- Control of the device; Presets, Tune, Band & Feedback Version 2: ---------- Ability to push and hold Preset # and change the station *) (***********************************************************) (* DEVICE NUMBER DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_DEVICE dvZtuner = 5001:1:0 dvPanel = 10024:1:0 (***********************************************************) (* CONSTANT DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_CONSTANT Volatile Integer nZtuner_Preset_Buttons[]= { 500, /// Preset 1 501, /// Preset 2 502, /// Preset 3 503, /// Preset 4 504, /// Preset 5 505, /// Preset 6 506, /// Preset 7 507, /// Preset 8 508, /// Preset 9 509, /// Preset 10 510, /// Preset 11 511, /// Preset 12 512, /// Preset 13 513, /// Preset 14 514, /// Preset 15 515, /// Preset 16 516, /// Preset 17 517, /// Preset 18 518, /// Preset 19 519, /// Preset 20 520, /// Preset 21 521, /// Preset 22 522, /// Preset 23 523, /// Preset 24 524, /// Preset 25 525, /// Preset 26 526, /// Preset 27 527, /// Preset 28 528, /// Preset 29 529 /// Preset 30 } Volatile Integer nZtuner_Tune_Buttons[]= { 530, /// Auto Tune Up 531, /// Auto Tune Down 532, /// Manual Step Up 533 /// Manual Step Down } Volatile Integer nZtuner_Band_Buttons[]= { 534, /// FM 535, /// AM 536 /// Band Toggle } Volatile Integer nZtuner_VText_Fields[]= { 1, /// Display 1 2, /// Display 2 3, /// Display 3 4 /// Display 4 } Volatile Integer nZtuner_Preset_Control_Buttons[]= { 537, /// Next Preset 538 /// Previous Preset } (***********************************************************) (* DATA TYPE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_TYPE (***********************************************************) (* VARIABLE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_VARIABLE Persistent Integer Debug_Status (***********************************************************) (* LATCHING DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_LATCHING (***********************************************************) (* MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_MUTUALLY_EXCLUSIVE (***********************************************************) (* SUBROUTINE/FUNCTION DEFINITIONS GO BELOW *) (***********************************************************) (* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *) (* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *) (***********************************************************) Define_Function Char debug(Char sMsg[]) { If(Debug_Status) Send_String 0,"'Debug : ',' Line : ',Itoa(__Line__),' :: ',sMsg" } Define_Function SysKP_Parsing(Char sQue[100]) { Local_Var Char sWork[25] Local_Var Char sTrash[25] If(Debug_Status) debug("'SysKP_Parsing :: ','sQue : ',sQue") sFormat(sQue) If(Debug_Status) debug("'SysKP_Parsing :: ','sQue : ',sQue") Send_String dvZtuner,"sQue,13" } Define_Function sFormat(Char sQue[100]) { Local_Var Char sWork[25] Local_Var Char sTrash[25] Local_Var Char sWork_Temp_1[25] Local_Var Char sWork_Temp_2[25] Local_Var Char sNum_1[4] Local_Var Char sNum_2[2] If(Debug_Status) /// Debug information debug("'sFormat :: ','Formatting data.'") Select { Active(Find_String(sQue,'.',1)): { If(Debug_Status) debug("'sFormat :: ','Found a . in the data.'") } Active(!(Find_String(sQue,'.',1))): { If(Debug_Status) debug("'sFormat :: ','Not a . in the data.'") sNum_1 = Left_String(sQue,2) If(Debug_Status) debug("'sFormat :: ','sNum_1 : ',sNum_1") sNum_2 = Right_String(sQue,2) If(Debug_Status) debug("'sFormat :: ','sNum_2 : ',sNum_2") sQue = "sNum_1,' ',sNum_2" If(Debug_Status) debug("'sFormat :: ','sQue : ',sQue") } } } (***********************************************************) (* STARTUP CODE GOES BELOW *) (***********************************************************) DEFINE_START (***********************************************************) (* THE EVENTS GO BELOW *) (***********************************************************) DEFINE_EVENT Data_Event[dvZtuner] { Online: { Send_Command dvZtuner,"'SET BAUD 9600,N,8,1'" If(Debug_Status) debug("'Device Online :: Setting Communication'") } String: { Local_Var Char sBuffer[500] Local_Var Char sTrash[500] Local_Var Char sTemp[500] Local_Var Char sStation[10] Local_Var Char sBand[2] sBuffer = Data.Text } } Data_Event[dvPanel] { String: { Local_Var Char sQue[1000] Local_Var Char sTrash[100] Local_Var Char sResponse[100] sQue = Data.Text If(Debug_Status) debug("'Data.Text : ',Data.Text") Select { Active(Find_String(sQue,'Radio-',1)): { sTrash = Remove_String(sQue,'Radio-',1) If(Debug_Status) debug("'Keypad Detection :: ','Set the keypad to Radio mode.'") } Active(Find_String(sQue,'KEYP-',1)): { sTrash = Remove_String(sQue,'KEYP-',1) sResponse = Remove_String(sQue,sQue,1) If(Debug_Status) debug("'Keypad Detection :: ','Send the keypad string to the function.',' sResponse : ',sResponse") SysKP_Parsing(sResponse) } Active(Find_String(sQue,'KEYB-',1)): { sTrash = Remove_String(sQue,'KEYB-',1) sResponse = Remove_String(sQue,sQue,1) If(Debug_Status) debug("'Keypad Detection :: ','Send the keyboard string to the function.',' sResponse : ',sResponse") SysKP_Parsing(sResponse) } } } } Button_Event[dvPanel,nZtuner_Preset_Buttons] { Push: { /// Do Nothing :) } Release: { Local_Var Integer nButton Local_Var Char sCmd[15] nButton = Get_Last(nZtuner_Preset_Buttons) sCmd = "'W 1 3 1 ',ITOA(nButton)" If(Debug_Status) debug("'Radio Presets :: ','sCmd : ',sCmd") Send_String dvZtuner,"sCmd,13" } Hold[20]: { Local_Var Integer nButton Local_Var Char sCmd[15] nButton = Get_Last(nZtuner_Preset_Buttons) sCmd = "'W 1 3 2 ',Itoa(nButton)" If(Debug_Status) debug("'Memorizing Channel into preset :: ','sCmd : ',sCmd") Send_String dvZtuner,"sCmd,13" } } Button_Event[dvPanel,nZtuner_Tune_Buttons] { Push: { Local_Var Integer nButton Local_Var Char sCmd[15] nButton = Get_Last(nZtuner_Tune_Buttons) sCmd = "'W 1 7 ',ITOA(nButton)" If(Debug_Status) debug("'Radio Tune :: ','sCmd : ',sCmd") Send_String dvZtuner,"sCmd,13" } } Button_Event[dvPanel,nZtuner_Band_Buttons] { Push: { Local_Var Integer nButton Local_Var Char sCmd[15] nButton = Get_Last(nZtuner_Band_Buttons) If(nButton == 3) nButton = 10 sCmd = "'W 1 8 ',Itoa(nButton)" If(Debug_Status) debug("'Radio Band :: ','sCmd : ',sCmd") Send_String dvZtuner,"sCmd,13" } } Button_Event[dvPanel,nZtuner_Preset_Control_Buttons] { Push: { Local_Var Integer nButton Local_Var Char sCmd[15] nButton = Get_Last(nZtuner_Preset_Control_Buttons) + 2 sCmd = "'W 1 3 ',Itoa(nButton)" If(Debug_Status) debug("'Radio Preset Control :: ','sCmd : ',sCmd") Send_String dvZtuner,"sCmd,13" } } (***********************************************************) (* THE ACTUAL PROGRAM GOES BELOW *) (***********************************************************) DEFINE_PROGRAM (***********************************************************) (* END OF PROGRAM *) (* DO NOT PUT ANY CODE BELOW THIS COMMENT *) (***********************************************************)
Thanks
0
Comments
Buttons pressed on the touch panel ( im using the system keypad )
But never mind I just worked it out
If it works great, but I think you did more work then you needed to. Good practice though.
The feedback is correctly updating if I use the following code :
It will display a for FM and a for AM
However it will not work when trying to do this :
What am I doing wrong?
Thanks for the advice / help
Or, you could do this:
You could also add a default condition that alerts you to the fact that there was a problem.
Jeff
Worked like a charm thanks again
Thanks
*** EDIT : Fixed it ***
Thanks
Chris Ondrovic
Here is as far as I have gotten. ( First attempt @ writing a module )
I can successfully control the zTuner via the CP4 & MVP.
The MVP I have control, debug statements & feedback.
The CP4 controls the device but will not update the feedback, it will also not trigger the debug that is programmed into the code.
Any ideas?
Main Program
Module
Thanks for the help...... again
Chris Ondrovic