See: Description
| Interface | Description |
|---|---|
| GenerationListener |
The
GenerationListener interface defines methods for getting notified of pulse generation completion
conditions (i.e. |
| GenerationRoundListener |
The
GenerationRoundListener interface defines methods for getting notified of the completion of the
generation of a sequence of pulses and that more pulses (the width thereof) to generate may be specified. |
| PWMChannel |
The
PWMChannel interface provides methods for controlling a PWM (Pulse Width Modulation) signal generator
channel. |
| Class | Description |
|---|---|
| GenerationEvent |
The
GenerationEvent class encapsulates pulse a generation completion condition (i.e. |
| PWMChannelConfig |
The
PWMChannelConfig class encapsulates the hardware addressing information, and static and dynamic
configuration parameters of a PWM channel. |
| PWMPermission |
The
PWMPermission class defines permissions for PWM channel access. |
| Exception | Description |
|---|---|
| InvalidPulseRateException |
Thrown by an instance of
PWMChannel in case the requested pulse rate/frequency is higher than the maximum
rate/frequency the PWM device can support. |
PWMChannel instance for the PWM generator's channel the application wants to
access and control, using its numerical ID, name, type (interface) and/or properties:
PWMChannel channel = (PWMChannel) PeripheralManager.open(8);
PWMChannel channel = PeripheralManager.open("DIMMER", PWMChannel.class, null);
PWMChannel.setPulsePeriod(int) method ; then generate pulses of a specified width or
duty cycle by calling one of the PWMChannel.generate(int, int) or
PWMChannel.startGeneration(int). When done, the application should call thechannel.setPulsePeriod(1000000); // Pulse period = 1 second channel.generate(500000, 10); // Generate 10 pulses with a width of 0.5 second
PWMChannel.close() method to close PWM channel. The following sample code gives an example of using the PWM channel API to progressively dim the light of a LED (for example) starting from its maximum intensity (100% duty cycle) in 10 successive steps of 10 seconds each:channel.close();
class VaryingDimmer implements GenerationRoundListener {
private PWMChannel channel = null;
private int step = 10;
public void pulseGenerationCompleted(GenerationEvent event) {
if (step > 0) {
try {
channel.startGeneration((channel.getPulsePeriod() / 10) * --step, 10, this);
} catch (IOException ex) {
// Iggnored
}
}
}
public void start(int channelID) throws IOException, NonAvailablePeripheralException, PeripheralNotFoundException {
if (channel != null) {
throw new IllegalStateException();
}
channel = (PWMChannel) PeripheralManager.open(channelID);
channel.setPulsePeriod(1000000); // period = 1 second
channel.startGeneration((channel.getPulsePeriod() / 10) * step, 10, this);
}
public void stop() throws IOException, NonAvailablePeripheralException {
if (channel != null) {
channel.stopGeneration();
channel.close();
}
}
}
Because of performance issue, procedures handling PWM events, and especially event listeners, should be
implemented to be as fast as possible.
Unless otherwise noted, passing a 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