×
Namespaces

Variants
Actions
Revision as of 10:15, 18 December 2008 by seppo_fn (Talk | contribs)

Blinking flashing increasing brightness of backlight in WRT

From Nokia Developer Wiki
Jump to: navigation, search


Article Metadata
Tested with
Devices(s): Nokia E90 Communicator (v.210.34.75 and later), Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition, FP2, S60 5th Edition
S60 5th Edition
S60 3rd Edition FP2
S60 3rd Edition FP1
Article
Keywords: x-systeminfo-widget, SystemInfo.lightblink(), SystemInfo.lighton()
Created: (24 Nov 2008)
Last edited: seppo_fn (18 Dec 2008)

Overview

This code snippet demonstrates how to control the backlight of a device by using the SystemInfo Service API of the Web Runtime version 1.0.

The API is supported from S60 3rd Edition, FP2 onwards. It is also supported in select S60 3rd Edition, FP1 devices or newest firmware versions (for example, Nokia E90 Communicator, from v.210.34.75 onwards).

Source

Embed the SystemInfo widget into the document:

<body>
<embed type="application/x-systeminfo-widget" hidden="yes" />
</body>

Add three buttons to control the backlight:

<input type="button" onclick="lightOn();" value="Light on" />
<input type="button" onclick="blink();" value="Blink" />
<input type="button" onclick="lightOff();" value="Light off" />

And here's the JavaScript code:

var sysInfo = null;
 
window.onload = init;
 
var SMOOTH = true;
 
function init() {
// Obtain the SystemInfo object
try {
sysInfo = document.embeds[0];
} catch (ex) {
alert("SystemInfo object cannot be found.");
return;
}
}
 
// Switches the display light on
function lightOn() {
if (sysInfo == undefined) {
alert("SystemInfo object is undefined.");
return;
}
 
// Reset the backlight state to default
resetLight();
 
sysInfo.lighton(sysInfo.lighttargetsystem, sysInfo.lightinfiniteduration,
sysInfo.lightmaxintensity, SMOOTH);
}
 
// Starts blinking the display
function blink() {
if (sysInfo == undefined) {
alert("SystemInfo object is undefined.");
return;
}
 
// Reset the backlight state to default
resetLight();
 
sysInfo.lightblink(sysInfo.lighttargetsystem,
sysInfo.lightinfiniteduration, sysInfo.lightdefaultcycletime,
sysInfo.lightdefaultcycletime, sysInfo.lightmaxintensity);
}
 
// Switches the display light off
function lightOff() {
if (sysInfo == undefined) {
alert("SystemInfo object is undefined.");
return;
}
 
sysInfo.lightoff(sysInfo.lighttargetsystem, sysInfo.lightinfiniteduration,
SMOOTH);
}
 
// Sets the backlight of the display to default value
function resetLight() {
if (sysInfo == undefined) {
alert("SystemInfo object is undefined.");
return;
}
 
sysInfo.lighton(sysInfo.lighttargetsystem, sysInfo.lightinfiniteduration,
sysInfo.lightdefaultintensity, SMOOTH);
}

Postconditions

Different possibilities to control the backlight are demonstrated.

Supplementary material

For a complete example that makes use of the SystemInfo Service API to control the backlight, see Blinking_flashing_increasing_brightness_of_backlight_in_WRT.zip

117 page views in the last 30 days.
×