AVForums

Our philosophy in our forums, reviews, podcasts and feature videos is to promote audio and visual excellence by gathering and sharing the best information and resources available.

Help

To begin please visit our help section »

Not a Member Yet?

It only takes a minute to start enjoying the benefits of AVForums membership, and it's free!

Member Log in

Controlling Rako lights with the TSU9600 scroll wheel

Post Reply
Old 16-11-2009, 9:00 PM   #1
Senior Member
 
Dave964's Avatar
Join Date: Nov 2007
Location: Camberley
Experience Points:
5,139, Level: 16
Points: 5,139, Level: 16 Points: 5,139, Level: 16 Points: 5,139, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Thanks: Gave 2, Got 115
Posts: 1,190
Controlling Rako lights with the TSU9600 scroll wheel

I decided that I would like to control my Rako lights directly from whatever device I'm in, without entering the Rako module. Note that this is not necessarily the best code in the world - the rotary counter should really be a state, and it would be better if I could restart timers (which I can do with my own timer module). But I just wanted something working quickly this evening so was only willing to spend half an hour on it.

When I mention "light button" below, I mean the icon on the display - not the hard button.

The prontoscript below will allow the following :

1) A brief press of the light button on the display switches the lights on to scene 3 if they are off - or switches them off if they are on. Holding the light button down will jump to the Rako module (this assumes you were using the light button to jump to the Rako module already). Note that this assumes all light control is via the pronto - if you use a real light switch the pronto will be out of sync, but that just means you'll need to press the button twice to get it back in sync.

2) The scroll wheel can be used to fade the lights up / down.

Before you can do this, you must understand prontoscript names. These are NOT labels. Each device / Activity can have a prontoscript name (in the Properties). Each page can have a prontoscript name. Each button can have a prontoscript name. Before you can use the prontoscript below, you must create buttons that send RS232 commands as follows. Note that you will need to use your own house number (mine assumes HO:1), your own room (mine assumes RO:4), your own channel (mine assumes CH:1).

Fade up - HO:1\rRO:4\rCH:1\rCOMMAND:1\r

Fade down - HO:1\rRO:4\rCH:1\rCOMMAND:2\r

Stop fade - HO:1\rRO:4\rCH:1\rCOMMAND:15\r

Off - HO:1\rRO:4\rCH:1\rOFF\r

Scene 3 - HO:1\rRO:4\rCH:1\rSC:3\r

Obviously you can choose a different scene if you wish - this is the scene that will be selected if you press the lights button briefly when the lights are off.

You need to give each of these buttons a prontoscript name. They need to be created on a page with a prontoscript name. The page must belong to a device with a prontoscript name. You will see in the prontoscript examples below that I placed my buttons on the RESOURCE_PAGE of my SKY_DEVICE and the prontoscript names for the buttons I used should be obvious.

Now - to be able to use the lights button to toggle the lights on and off you need to track the state of the lights. In the properties page of your Home device, add the following prontoscript :

if (!System.getGlobal ("lights"))
{
System.setGlobal ("lights", "off");
}


Now - for the lights button / icon on the System page add the following prontoscript. The onHoldInterval of 300 means you have to press the button for 300ms before it would jump to the Rako module - you can increase or decrease this period as you wish :

var button_held = false;
onHoldInterval = 300;

onHold = function ()
{
button_held = true;
onHoldInterval = 0;
}

onRelease = function ()
{
if (!button_held)
{
if (System.getGlobal ("lights") == "on")
{
CF.widget ("RAKO_OFF_BUTTON", "RESOURCE_PAGE", "SKY_DEVICE").executeActions ();
System.setGlobal ("lights", "off");
}
else
{
CF.widget ("RAKO_SCENE_3_BUTTON", "RESOURCE_PAGE", "SKY_DEVICE").executeActions ();
System.setGlobal ("lights", "on");
}

}
else
{
executeActions ();
}


Note the prontoscript names in capitals - you must use your own names (or name your buttons / pages / device the same as mine).

Now - in the properties page of each device where you want to use the scroll wheel to control the Rako lights add the following prontoscript :


var rotary_count = 0;

onRotary = function(clicks)
{
if ( clicks > 0 ) // Rotated right
{
if (rotary_count == 0)
{
/* Start fading up */
CF.widget ("RAKO_FADE_UP_BUTTON", "RESOURCE_PAGE", "SKY_DEVICE").executeActions ();
rotary_count = 1;
}

}

else if ( clicks < 0 ) // Rotated left
{
if (rotary_count == 0)
{
/* Start fading down */
CF.widget ("RAKO_FADE_DOWN_BUTTON", "RESOURCE_PAGE", "SKY_DEVICE").executeActions ();
rotary_count = 1;
}

}

else /* clicks must be zero - scrolling has stopped */
{
CF.widget ("RAKO_STOP_BUTTON", "RESOURCE_PAGE", "SKY_DEVICE").executeActions ();
rotary_count = 0;
}

System.setGlobal ("lights", "on");
}


Note that if you are using the Rako module, you will need to add the following line of prontoscript code to the fade up / fade down / scenes 1-4 buttons :

System.setGlobal ("lights", "on");

And the following line of code to the Off button :

System.setGlobal ("lights", "off");

Last edited by Dave964; 18-11-2009 at 5:10 PM.
  Quote
Old 18-11-2009, 5:13 PM   #2
Senior Member
 
Dave964's Avatar
Join Date: Nov 2007
Location: Camberley
Experience Points:
5,139, Level: 16
Points: 5,139, Level: 16 Points: 5,139, Level: 16 Points: 5,139, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Thanks: Gave 2, Got 115
Posts: 1,190
Re: Controlling Rako lights with the TSU9600 scroll wheel

Having used it for a couple of days, I found that scroll wheel control of the lights was not 100% reliable. The light control didn't seem that smooth, and even using different timer values didn't help.

So, tonight I decided to do some debugging and see what was happening. What I found was that the rotary function was called more often than I thought - but, the key thing was that it's always called when the wheel has stopped turning - with a click value of zero.

What this means is that the messing about with timers to try and detect when the wheel had stopped turning was completely unnecessary. I have therefore replaced the scroll wheel part of the code above - it now seems to be much more reliable, results in much smoother fading up / down of the lights and much more accurate control (since there is no timer delay before the scrolling stops).
  Quote
Post Reply

Powered by  
 Latest popular product prices
Venom Wii Remote Silicon Glove Twin 
1 price
 £7.98 Click to show/hide the offers

Startech Adapter Kit For 2.5" Hd... 
1 price
 £10.78 Click to show/hide the offers

John Lewis 2-Way Remote Control 
1 price
 £13.00 Click to show/hide the offers

NIKON ML-L3 Wireless Remote Control 
1 price
 £13.99 Click to show/hide the offers

Apple Remote 
1 price
 £19.50 Click to show/hide the offers

Lindy 3 Port Hdmi Switch With Re... 
1 price
 £20.38 Click to show/hide the offers

SKY TELEVISION SKY150 
1 price
 £29.09 Click to show/hide the offers

Microsoft Xbox 360 Media Remote ... 
1 price
 £22.95 Click to show/hide the offers

 Updated February 13th at 11:30am. Prices include delivery.


Thread information and display options
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off