Blackberry LED Programming

yohanli.com

Created with Sketch.

Blackberry LED Programming

This article show how to access LED on blackberry handheld.

For LED programming, we need to import net.rim.device.api.system.LED.

LED

Source Code TestLed.java

package com.rim.yohanli.testled;

import net.rim.device.api.system.LED;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

public class TestLed extends UiApplication{
public static void main(String[] args) {
TestLed theApp = new TestLed();
theApp.enterEventDispatcher();
}
public TestLed() {
pushScreen(new TestLedScreen());
LedSetting.TurnLEDOn(0x00FF00FF);
}
}

final class TestLedScreen extends MainScreen {
public TestLedScreen(){
super();
LabelField title = new LabelField(“Test Led”,
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
add(new RichTextField(“You should see Purple Led Color blinking”));
}

public boolean onClose() {
Dialog.alert(“Goodbye!”);
System.exit(0);
return true;
}
}

final class LedSetting {
private static final int tOn = 250;
private static final int tOff = 1250;
public static void TurnLEDOn(int rgb){
LED.setState(LED.LED_TYPE_STATUS,LED.STATE_ON);
LED.setColorConfiguration(tOn, tOff, rgb);
}
}

Reference: RIM Device Java Library

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *