LG TV 50PC5D
edgelitoc
Posts: 160
Hi There,
Have anyone control the volume for the tv above. As per manual sending volume control command is
send_string dvTV1,"kf [set id] [data][cr]" where data min:0 ~ max:64,
how would you handle data so I can have level events.
thanks a lot ..
Have anyone control the volume for the tv above. As per manual sending volume control command is
send_string dvTV1,"kf [set id] [data][cr]" where data min:0 ~ max:64,
how would you handle data so I can have level events.
thanks a lot ..
0
Comments
well, I suppose you could create a virtual device that shadows the level of the TV and then send/recieve levels that way. However, for something as simple as rs-232 control of a TV I wouldn't do that. You've got the commands and the level right there. Why not just park the levels in a variable and manage it that way? That's what I do anyway.
Thanks for the reply, how would you incorporate the data to have a level.
Thanks,
edgelito
I would create a buffer to hold the incoming data. As I see from my LG manual the response from the TV is [f][ ][Set ID][ ][OK][Data][x]
So, in the TV should respond to the command you send and will give you it's acknowledgement of recieving the command. You can parse the incoming data and save the volume value in a varialble. (something like nCurrent_TV_Vol) I'd then send the updated volume to a fader on a touch panel.
If you're having trouble, perhaps you could post your code and we'll see if we can help.
Well, provided your bargraph on your TP is set up to handle values from 0-100. We should be doing something like SEND_LEVEL dvTP, nVolLevel, nTheVolume
But what is nTheVolume?
The manual says the data range is min: 0, max: 64. But wait! If you read the manual closely, you will find that this number is an ASCII representation of a HEX value. So they mean 0 to 64 Hexdecimal, not the Decimal number 64.
This is tricky because 64 does not contain ABCDE or F in it, if it did, it would be immediately obvious that this was intended to be interpreted as a Hex number. Also the Decimal number 64 happens to be a power of 2, so it would seem to be a somewhat logical choice for an upper limit.
Okay so what is the Decimal equivalent of $64 ?
6 * 16 = 96
4 * 1 = 4
________
100
Perfect, because our bargraph is from 0-100. If it weren't we would have to write a math function to scale the number, or change the bargraph limits on all our touchpanels.
So all you have to do, when you get that value back from the unit is call hextoi() on the value, then you will get an integer which you use in your SEND_LEVEL and you're done.
here is my codes:
dvPLASMA3 = 0128:1:0
DEFINE_CALL 'TV_VOL' (FUNCTION)
{
LOCAL_VAR VOLDATA
LOCAL_VAR VOLDATA1
LOCAL_VAR VOLDOWNS
LOCAL_VAR VOLUPS
VOLDATA = 0
{
SELECT
{
ACTIVE(FUNCTION = TVVOLUP):
{
VOLDATA = 1
VOLDATA = VOLDATA + 1
VOLDATA1 = VOLDATA + 10
VOLUPS = VOLDATA1 + 4
SEND_STRING dvPLASMA3,"'kf 1','VOLUPS',$0D"
}
ACTIVE(FUNCTION = TVVOLDOWN):
{
VOLDATA = 1
VOLDATA = VOLDATA + 1
VOLDATA1 = VOLDATA + 10
VOLDOWNS = VOLDATA1 - 4
SEND_STRING dvPLASMA3,"'kf 1','VOLDOWNS',$0D"
}
}
}
}
(***********************************************************)
(* STARTUP CODE GOES BELOW *)
(***********************************************************)
CREATE_LEVEL dvPLASMA3,2,nVOLUME
SEND_LEVEL TP,2,nVOLUME
LEVEL_EVENT[dvPLASMA3,2] //VOLUME dvPLASMA3
{
SEND_LEVEL TP,2,nVOLUME
}