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

Login:
Pass:
 
 

Original thread:
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.


Hosting Services by ipHouse