See: Description
Interface | Description |
---|---|
DACChannel |
The
DACChannel interface provides methods for controlling a DAC (Digital to Analog Converter) channel. |
GenerationRoundListener |
The
GenerationRoundListener interface defines methods for getting notified of the completion of the
conversion of a set of raw output values and that more output values to be converted may be provided. |
Class | Description |
---|---|
DACChannelConfig |
The
DACChannelConfig class encapsulates the hardware addressing information, and static and dynamic
configuration parameters of an DAC channel. |
DACPermission |
The
DACPermission class defines permissions for DAC channel access. |
Exception | Description |
---|---|
InvalidOutputSamplingRateException |
Thrown by an instance of
DACChannel in case the requested sampling rate is higher than the maximum sampling
rate the DAC device can support. |
DACChannel
instance for the DAC channel the application wants to
access and control, using its numerical ID, name, type (interface) and/or properties:
DACChannel channel = (DACChannel) PeripheralManager.open(5);
DACChannel channel = (DACChannel) PeripheralManager.open("LED", DACChannel.class, null);
DACChannel
interface such as the
generate
method. When done, the application should call thechannel.generate(brightness);
DACChannel.close()
method to close the DAC channel. The following sample codes give examples of using the DAC API:channel.close();
Because of performance issue, procedures handling analog outputs, and especially event listeners, should be implemented to be as fast as possible. Unless otherwise noted, passing aclass VaryingDimmer implements GenerationRoundListener { private DACChannel channel = null; public void start(int channelID) throws IOException, NonAvailablePeripheralException, PeripheralNotFoundException { if (channel != null) { throw new InvalidStateException(); } channel = (DACChannel) PeripheralManager.open(channelID); channel.setSamplingInterval(1000); // every 1000 milliseconds // Creates a series of samples varying from min value to max value int[] values = new int[10]; int min = channel.getMinValue(); int max = channel.getMaxValue(); IntBuffer values = IntBuffer.wrap(new int[10]); createSamples(values, channel.getMinValue(), channel.getMaxValue(), 10); channel.startGeneration(values, this); } public void outputRoundCompleted(RoundCompletionEvent<DACChannel, IntBuffer> event) { try { // Replay the same sample series createSamples(event.getBuffer(), event.getPeripheral().getMinValue(), event.getPeripheral().getMaxValue(), 10); } catch (IOException ioe) { // Ignored } } // Creates a series of samples varying from min value to max value private void createSamples(IntBuffer buffer, int min, int max, int count) { for (int i = 0; i < count; i++) { buffer.put(min + (((max - min) / (count - 1)) * i)); } buffer.flip(); } public void stop() throws IOException { if (channel != null) { channel.stopGeneration(); 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
ing HTML relocated from here.-->