|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
A2dEventListener | A listener to A2d events related to specific channel. |
GpioCounterListener | A listener to Gpio Counter events. |
GpioInterruptListener | A listener to Gpio Interrupt events. |
Class Summary | |
---|---|
A2dAutoPeriodConfig | The A2dAutoPeriodConfig class is designed for holding the configuration profile of A2D channel to period mode. |
A2dAutoThresholdConfig | The A2dAutoThresholdConfig class is designed for holding the configuration profile of a2d channel to threshold mode. |
A2dChannel | The A2dChannel class contains methods for configuration, and receiving notifications from the A2d channels. |
A2dManager | The A2dManager class contains methods for initialization and management of the A2d unit. |
Gpio | Gpio Class is an abstract base class to support common access methods
Gpio Specific Configuration: - Available pins: GPIO1-GPIO7, GPIO9-GPIO16. |
GpioCounter | The class provides Gpio Counter service methods. |
GpioCounterConfig | The class encapsulates all Gpio Counter relevant configuration data. |
GpioInput | GpioInput enables configuring each available gpio in the system as an input one. |
GpioInterruptConfig | Encapsulates all GPIO interrupt relevant data: notification type, debounce time and listener. |
GpioOutput | GpioOutput class enables configuring each available GPIO in the system as output. |
Exception Summary | |
---|---|
A2dException | A2d specific exception. |
GpioException | GPIO specific exception. |
HW API package - Controls GPIO and A2D HW lines.GPIO (General Purpose Input/Output) - Interact with external HW lines. Set or get the line value (0 or 1), receive interrupt notification on line value changed. Perform I/O line Real-time related configurations.
import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import com.motorola.oem.hapi.GpioException; import com.motorola.oem.hapi.GpioInput; import com.motorola.oem.hapi.GpioOutput; public class UserMIDlet extends MIDlet{ private GpioInput gpioInput; private GpioOutput gpioOutput; public UserMIDlet() { super(); } protected void startApp() throws MIDletStateChangeException { try { //Configuring GPIO1 as Input gpioInput = new GpioInput(1); gpioInput.read(); //Configuring GPIO2 as Output //Writing low value to GPIO2 gpioOutput = new GpioOutput(2); gpioOutput.write(false); } catch (GpioException e) { if (gpioInput != null) gpioInput.clear(); if (gpioOutput != null) gpioOutput.clear(); e.printStackTrace(); } } protected void pauseApp() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } } |
import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import com.motorola.oem.hapi.GpioException; import com.motorola.oem.hapi.GpioInput; import com.motorola.oem.hapi.GpioInterruptConfig; import com.motorola.oem.hapi.GpioInterruptListener; public class UserMIDlet extends MIDlet implements GpioInterruptListener{ private GpioInput gpioInput; private GpioInterruptConfig gpioInterruptConfig; public UserMIDlet() { super(); } protected void startApp() throws MIDletStateChangeException { try { //Configuring GPIO1 as Input //and enabling interrupt gpioInput = new GpioInput(1); gpioInterruptConfig = new GpioInterruptConfig(this); gpioInput.enableInterrupt(gpioInterruptConfig); } catch (GpioException e) { if (gpioInput != null) gpioInput.clear(); e.printStackTrace(); } } protected void pauseApp() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } public void onInterrupt(int gpioNum, boolean val) { //Handle interrupts on GPIO1 here } } |
import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import com.motorola.oem.hapi.GpioException; import com.motorola.oem.hapi.GpioInput; import com.motorola.oem.hapi.GpioCounterConfig; import com.motorola.oem.hapi.GpioInterruptConfig; import com.motorola.oem.hapi.GpioCounterListener; public class UserMIDlet extends MIDlet implements GpioCounterListener{ private GpioInput gpioInput; private GpioCounterConfig gpioCounterConfig; public UserMIDlet() { super(); } protected void startApp() throws MIDletStateChangeException { try { //Configuring GPIO14 as Input //Configuring gpioCounterConfig object with requested counter configuration. //Enabling counter. gpioInput = new GpioInput(14); gpioCounterConfig = new GpioCounterConfig(this); gpioCounterConfig.setNotificationType(GpioInterruptConfig.NOTIFICATION_TYPE_HIGH_TO_LOW); gpioCounterConfig.setGpioCounterExpiryValue(2500); gpioCounterConfig.setGpioCounterType(GpioCounterConfig.COUNTER_TYPE_ONE_SHOT); gpioInput.enableCounter(gpioCounterConfig); } catch (GpioException e) { if (gpioInput != null) gpioInput.clear(); e.printStackTrace(); } } protected void pauseApp() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } public void onCounterExpired(int gpioNum) { //Handle counter expiry on GPIO14 here } } |
import com.motorola.oem.hapi.GpioInput; public interface Listener { public void update(boolean readVal, GpioInput gpioInput); } |
import com.motorola.oem.hapi.GpioInput; public class GpioPoll extends Thread{ private GpioInput gpioInput = null; private Listener listener; public GpioPoll(GpioInput gpioInput, Listener listener) { this.gpioInput = gpioInput; this.listener = listener; } public void run() { try { while(true) { if (gpioInput == null){ System.out.println("GpioInput cannot be null"); break; } if (listener == null){ System.out.println("Listener cannot be null"); break; } boolean readVal = gpioInput.read(); listener.update(readVal,gpioInput); //Sleeping for one second Thread.sleep(1000); } } catch (InterruptedException e) { e.printStackTrace(); } } } |
import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import com.motorola.oem.hapi.GpioException; import com.motorola.oem.hapi.GpioInput; import com.motorola.oem.hapi.GpioInterruptConfig; import com.motorola.oem.hapi.GpioInterruptListener; public class UserMIDlet extends MIDlet implements GpioInterruptListener, Listener{ private GpioInput gpioInputInterrupt; private GpioPoll gpioPoll = null; private GpioInput gpioInput6 = null; private boolean gpioInput6ReadVal = false; public UserMIDlet() { super(); } protected void startApp() throws MIDletStateChangeException { try { //Enable GPIO1 interrupt. //GpioInterruptConfig constructs with Midlet itself as the interrupt listener. GpioInterruptConfig gpioInterruptConfig = new GpioInterruptConfig(this); gpioInputInterrupt = new GpioInput(1); gpioInputInterrupt.enableInterrupt(gpioInterruptConfig); } catch (GpioException e) { //Handle Exception } try { //Configure GPIO6 as input gpioInput6 = new GpioInput(6); gpioInput6ReadVal = gpioInput6.read(); //Start polling on GPIO6 gpioPoll = new GpioPoll(gpioInput6,this); gpioPoll.start(); } catch (GpioException e) { //Handle Exception } } protected void pauseApp() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } public void onInterrupt(int gpioNum, boolean val) { //Handle interrupts on GPIO1 here } public void update(boolean readVal, GpioInput gpioInput) { if (gpioInput == gpioInput6) { if (readVal == false && gpioInput6ReadVal == true) { //handle polling change on GPIO6 } else if (readVal == true && gpioInput6ReadVal == false) { //handle polling change on GPIO6 } gpioInput6ReadVal = readVal; } } } |
import javax.microedition.midlet.*; import com.motorola.oem.hapi.A2dException; import com.motorola.oem.hapi.A2dManager; import com.motorola.oem.hapi.A2dChannel; public class UserMidlet extends MIDlet { private A2dManager a2d = null; private int queryValue = 0; public UserMidlet() { super(); } public void startApp() { try { a2d = A2dManager.getInstance(); queryValue = a2d.getChannel(a2d.CH1).getValue(); } catch(A2dException e) { //Handle Exception } catch(InterruptedException e) { //Handle Exception } } public void pauseApp() { } public void destroyApp(boolean unconditional) { } } |
import javax.microedition.midlet.*; import com.motorola.oem.hapi.A2dException; import com.motorola.oem.hapi.A2dManager; import com.motorola.oem.hapi.A2dEventListener; import com.motorola.oem.hapi.A2dChannel; import com.motorola.oem.hapi.A2dAutoThresholdConfig; public class UserMidlet extends MIDlet implements A2dEventListener{ private A2dManager a2d = null;; private A2dAutoThresholdConfig threshold_config = null; public UserMidlet() { super(); } public void startApp() { try { A2dManager a2d = A2dManager.getInstance(); A2dAutoThresholdConfig threshold_config = new A2dAutoThresholdConfig(); threshold_config.setThreshold(threshold_config.THRESHOLD_LOW_LIMIT_LOW,(short)(115)); threshold_config.setThreshold(threshold_config.THRESHOLD_HIGH_LIMIT_LOW,(short)(135)); threshold_config.setThreshold(threshold_config.THRESHOLD_LOW_LIMIT_HIGH,(short)(155)); threshold_config.setThreshold(threshold_config.THRESHOLD_HIGH_LIMIT_HIGH,(short)(175)); a2d.getChannel(a2d.CH1).setListener(this); a2d.getChannel(a2d.CH1).startNotification(threshold_config); } catch(A2dException e) { //Handle Exception } } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void onNotification(int reportType,int channelNum,int a2dValue){ //Handle notification on A2d channel } } |
import javax.microedition.midlet.*; import com.motorola.oem.hapi.A2dException; import com.motorola.oem.hapi.A2dManager; import com.motorola.oem.hapi.A2dEventListener; import com.motorola.oem.hapi.A2dChannel; import com.motorola.oem.hapi.A2dAutoPeriodConfig; import com.motorola.oem.hapi.A2dAutoThresholdConfig; public class UserMidlet extends MIDlet implements A2dEventListener{ private A2dManager a2d = null; private A2dAutoThresholdConfig threshold_config = null; public UserMidlet() { super(); } public void startApp() { try { A2dManager a2d = A2dManager.getInstance(); A2dAutoPeriodConfig period_config = new A2dAutoPeriodConfig(); period_config.setPeriod(8); a2d.getChannel(a2d.CH1).setListener(this); a2d.getChannel(a2d.CH1).startNotification(period_config); } catch(A2dException e) { //Handle Exception } } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void onNotification(int reportType,int channelNum,int a2dValue){ //Handle notification on A2d channel } } |
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |