See: Description
Interface | Description |
---|---|
AcquisitionRoundListener |
The
AcquisitionRoundListener interface defines methods for getting notified of the availability of sampled
input values. |
ADCChannel |
The
ADCChannel interface provides methods for controlling an ADC (Analog to Digital Converter) channel. |
MonitoringListener |
The
MonitoringListener interface defines methods for getting notified of ADC channel under- and
over-threshold input value conditions. |
Class | Description |
---|---|
ADCChannelConfig |
The
ADCChannelConfig class encapsulates the hardware addressing information, and static and dynamic
configuration parameters of an ADC channel. |
ADCPermission |
The
ADCPermission class defines permissions for ADC channel access. |
MonitoringEvent |
The
MonitoringEvent class encapsulates ADC channel under- and over-threshold value conditions. |
Exception | Description |
---|---|
InvalidInputSamplingRateException |
Thrown by an instance of
ADCChannel in case the requested sampling rate is higher than the maximum sampling
rate the ADC device can support. |
ADCChannel
instance for the ADC channel the application wants to
access and control, using its numerical ID, name, type (interface) and/or properties:
ADCChannel channel = PeripheralManager.open(8);
ADCChannel channel = PeripheralManager.open("TEMPERATURE", ADCChannel.class, null);
ADCChannel
interface such as the
acquire
method. When done, the application should call theint temp = channel.acquire();
ADCChannel.close()
method to close ADC channel. The following sample codes give examples of using the ADC API:channel.close();
class ADCAcquisition implements AcquisitionRoundListener { private ADCChannel channel = null; public void start(int channelID) throws IOException, NonAvailablePeripheralException, PeripheralNotFoundException { channel = (ADCChannel) PeripheralManager.open(channelID); channel.setSamplingInterval(100); // every 100 milliseconds int[] values = new int[10]; channel.startAcquisition(IntBuffer.wrap(values), this); } public void inputRoundCompleted(RoundCompletionEvent<ADCChannel, IntBuffer> event) { IntBuffer buffer = event.getBuffer(); while (buffer.hasRemaining()) { int value = buffer.get(); // Handle value... } } public void stop() throws IOException { if (channel != null) { channel.stopAcquisition(); channel.close(); } } }
Because of performance issue, procedures handling analog inputs, and especially event listeners, should be implemented to be as fast as possible. Unless otherwise noted, passing aclass ADCThreshold implements MonitoringListener { private ADCChannel channel = null; public void start(int channelID, int low, int high) throws IOException, NonAvailablePeripheralException, PeripheralNotFoundException { channel = (ADCChannel) PeripheralManager.open(channelID); channel.setSamplingInterval(100); // every 100 milliseconds channel.startMonitoring(low, high, this); } public void thresholdReached(MonitoringEvent event) { if (event.getType() == MonitoringEvent.OUT_OF_RANGE) { int value = event.acquire(); // Handle condition... } } public void stop() throws IOException { if (channel != null) { channel.stopMonitoring(); channel.close(); } } }
null
argument to a constructor or method in any class
or interface in this package will cause a NullPointerException
to be thrown.Copyright © 2012, 2013, Oracle and/or its affiliates. All rights reserved.
Legal Notices