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 6 made on Thursday November 19, 2020 at 17:58
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,606
You also likely don't want to use System.getBatteryStatus() as you'd have to continually call this function at specific intervals.

The better way to do this would be to register for System Level events using System.addEventListener/System.removeEventListener

You should be able to drop this code into an Activity script and run on a remote. Note that you can also send data to an onscreen label with ProntoScript name of 'BATTERY'.

System.setDebugMask(9);

function myBatteryListener(aValue) {
System.print("batteryEvent:" + aValue);
var w = GUI.widget("BATTERY");
w && w.label = aValue;
}

System.addEventListener("battery",myBatteryListener);

//And, you'd likely want to remove the listener when exiting the activity to clean //things up.

// Here, CF.activity() and 'this' are the same.
this.onExit = function() {
System.removeEventListener("battery",myBatteryListener);
}
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse