Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Previous page Next page Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Page 1 of 2
Topic:
onReleaseInterval?
This thread has 23 replies. Displaying posts 1 through 15.
Post 1 made on Wednesday November 10, 2010 at 21:02
deric.lts
Long Time Member
Joined:
Posts:
September 2010
24
Hi, i'm working on an aircond control. Basically, I have two buttons and one panel with two buttons being Temp+ and Temp- to increase/decrease the aircond temperature while the panel displaying the aircond status (degree).

Whenever i press Temp+/Temp-, executeActions() will be executed to send the IR codes to set the aircond to the respective temp. Hence, there's a blocking wait for each press. I would like to have something like..when Temp+/Temp- is pressed, executeActions() will not be executed unless the user release it after some time so that it allows the user to continuously press Temp+/Temp- quickly without blocking until it reaches to the desired temp and IR is sent.
Post 2 made on Wednesday November 10, 2010 at 23:26
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Assuming you simply want to not send IR until such time a release occurs and only if the button is held for a specific time period, you can:

Use new Date().valueOf() to calculate start time.

Then, in the onRelease() function of the widget, calculate time again using same operation. Subtract the "released" time from the "start" time and if greater than some value, call executeActions() or scheduleActions() on the same widget.

Assuming the button that contains the IR action that needs to be sent, by adding the IR code to the ActionList and then enabling ProntoScript for said button, code the following. It is relatively simple.

var start = new Date().valueOf();
onRelease = function()
{
var now = new Date().valueOf();
if ((now - start) >= 1000)
this.executeActions();
}
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on Thursday November 11, 2010 at 02:07
deric.lts
Long Time Member
Joined:
Posts:
September 2010
24
hi, i have tried the suggested method, but I have no idea why it failed since the function seems logic. Itz like an onHold function where executedActions will be executed after I hold the button for some time & released. 

But what i am trying to do is like..lets say the initial aircond temp is 23deg, and the user try to increase the temp from 23deg to 30deg by pressing (press and release for 7 times, not holding the button). No IR should be sent for each Temp+ button press (or else will generates a delay for every single press due to executeActions) until the user stop pressing it at 30deg. In order to do this, therefore I need a counter for to do a background count where executeActions() will only be executed when the user stop pressing the button for some time after the button is released.
Post 4 made on Thursday November 11, 2010 at 02:16
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
That script is considerably more complicated and I am running short on time tonight. I'm hoping that someone else will chime in. It can be done but it will involve the use of scheduleAfter() and counters to track number of presses as well as time since button was released.

To find out why things are failing, surround all your code including the body of functions with try/catch and log to the diagnostics log or print to system. This will hopefully help you move forward in the interim.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 5 made on Thursday November 11, 2010 at 02:29
deric.lts
Long Time Member
Joined:
Posts:
September 2010
24
ok..anyway..thx for ur help! =)
Post 6 made on Thursday November 11, 2010 at 03:20
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
It is 2:20am my time and I've gotta get some sleep. I will try in the next couple of days to put an example together in a small config if I get cycles.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 7 made on Thursday November 11, 2010 at 11:43
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
I would have done it the same way as Lyndel but with a little difference:

time = Date.now();
  onRelease = function () {
  if ((Date.now() - time) > 1000) {
   do the stuff
  }
};


But what deric.lts asked now is different, you can do:

var difference;

buttonTempUp.onPress = function () {
 var i = parseInt(this.label);
 difference = parseInt(this.label);
 while(true) {
  i = i+1;
  label = i;
  System.delay(500);
 }
};

buttonTempUp.onRelease = function () {
 difference = parseInt(this.label) - difference;
  while(difference) {
    this.scheduleActions();
    difference -= 1;
    System.delay(300);
  }
};


This would work this way:
when you press the button it looks at the current temp, saves it and then it increases it while you hold the button, one degre each half a second (you can change the delay). When you release it it calculates what is the difference betewwn the previous and the now set temperature and proceeds with sending the ir code as many times as the difference in degrees was. The delay in the onRelease has to be adjusted for how much time the sending of the IR code takes. The IR command should be appended to the same button.

You can make a non blocking climbing of the IR also:


function increaseTemp() {
  while(difference) {
    buttonTempUp.scheduleActions();
    difference -= 1;
    scheduleAfter(300, increaseTemp);
  }
}


buttonTempUp.onRelease = function () {
  difference = parseInt(this.label) - difference;
  increaseTemp;
};


There could be some minor "typos" in the syntax. The var difference must be declared at page level so both functions will have access to it.
Post 8 made on Thursday November 11, 2010 at 17:54
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
I think he is wanting user to press and release multiple times, keep a count of the number of times pressed, then some time after the last release, execute a series of actions; 1 action per press. In this case, scheduleAfter usage will be required.

Derik.lts, can you confirm if this is the behavior you desire?
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 9 made on Thursday November 11, 2010 at 18:35
BluPhenix
Long Time Member
Joined:
Posts:
December 2008
371
Hm I re-red his post and I think you're right. Oh well now he has some code for the not intended scenario too :).
Post 10 made on Thursday November 11, 2010 at 19:23
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
It is much more complex than I wanted to tackle at 2:00am last night. Still busy working on another project but will try to get to it soon.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 11 made on Thursday November 11, 2010 at 20:29
deric.lts
Long Time Member
Joined:
Posts:
September 2010
24
Lyndel McGee and BluPhenix:

ya, the user is suppose to press multiple times acting like an actual aircond remote controller (will not keep increasing when you are holding the button). Anyway, thanks for the help BluPhenix.
Post 12 made on Friday November 12, 2010 at 01:53
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
So, you want to press and hold which will increase/decrease the number and then upon release, set the temp to that value?

Didn't Philips do something like this with the Aprilaire module? Did you have a look at that module?
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 13 made on Friday November 12, 2010 at 04:01
deric.lts
Long Time Member
Joined:
Posts:
September 2010
24
Nope. As I have mentioned, i want it to behave just like an actual aircond remote where it will only increase/decrease by 1 deg for every single press (press&release) and will not further increase/decrease even if you are continue to hold the button.

Lets say the user want to increase the temp from 23deg to 25deg. This means that the user is required to press the TEMP+ button twice (press & release). The problem occurs where there will be an unnecessary delay generated during the 23deg to 24deg (due to IR sending) that forces user to wait b4 the user can press for the second time to increase from 24deg to 25deg. Therefore, this could be avoided if there's a "onReleaseInterval" function where IR will only be sent if the button is release for 5 sec or longer as the user will just press&release in a very fast manner (release & follow by the next press in a very fast manner) to increase to the desired temp (completely release).

Pardon me if my sentences are too confusing.



Temp+ Button Script
switch (CF.widget("current_status").label)
{
        .....
        .....

        case "23":
            page("TEMP1").widget("tempUp24").executeActions();
            CF.widget("current_status").label = "24";
            break;

        case "24":
            page("TEMP1").widget("tempUp25").executeActions();
            CF.widget("current_status").label = "25";
            break;

        case "25":
            page("TEMP1").widget("tempUp26").executeActions();
            CF.widget("current_status").label = "26";
            break;

            .....
            .....
}

Funtion Action of tempUp24-26 buttons

Function: 23... on Daikin... (Action)
Post 14 made on Friday November 12, 2010 at 05:00
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Your example seems to imply that you don't have discrete IR codes for setting a specific temperature as your widgets are tagged "tempUpXX". Do you also have set of widgets that are tagged "tempDownXX"?
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 15 made on Friday November 12, 2010 at 05:10
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
You mention Daikin. Are you using the Coolmaster interface? Are you aware that Philips has a Daikin 232 module? Is there a particular reason you did not use 232 vs IR? I also realize that this module has discrete temperature buttons and not the up/down you desire.

I will state that I'm very concerned things can get really out of sync if you are exclusively using IR as you have no way to query the current status.

Please confirm whether or not 232 is in use for the Daikin.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Page 1 of 2


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse