public final class PWMChannelConfig extends java.lang.Object implements DeviceConfig<PWMChannel>, DeviceConfig.HardwareAddressing
PWMChannelConfig
class encapsulates the hardware addressing information, and static and dynamic
configuration parameters of a PWM channel.
Some hardware addressing, static or dynamic configuration parameters may be
set to UNASSIGNED
or null
(see
Unassigned, Default or Unused Parameter Values).
An instance of PWMChannelConfig
can be passed to the open(DeviceConfig, ...)
and
open(Class, DeviceConfig, ...)
methods of the DeviceManager
to open the designated PWM channel with the specified
configuration. A InvalidDeviceConfigException
is thrown when attempting to open a device with
an invalid or unsupported configuration.
DeviceManager.open(DeviceConfig)
,
DeviceManager.open(Class, DeviceConfig)
Modifier and Type | Class and Description |
---|---|
static class |
PWMChannelConfig.Builder
The
Builder class allows for creating and initializing PWMChannelConfig objects. |
DeviceConfig.HardwareAddressing
Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_CENTER
Center alignement.
|
static int |
ALIGN_LEFT
Left alignement.
|
static int |
ALIGN_RIGHT
Right alignement.
|
static int |
IDLE_STATE_HIGH
High idle state.
|
static int |
IDLE_STATE_LOW
Low idle state.
|
DEFAULT, UNASSIGNED
Constructor and Description |
---|
PWMChannelConfig(int controllerNumber,
int channelNumber,
int idleState,
int pulsePeriod,
int pulseAlignment)
Deprecated.
As of 1.1, use
PWMChannelConfig.Builder instead. |
PWMChannelConfig(int controllerNumber,
int channelNumber,
int idleState,
int pulsePeriod,
int pulseAlignment,
GPIOPinConfig output)
Deprecated.
As of 1.1, use
PWMChannelConfig.Builder instead. |
PWMChannelConfig(java.lang.String controllerName,
int channelNumber,
int idleState,
int pulsePeriod,
int pulseAlignment)
Deprecated.
As of 1.1, use
PWMChannelConfig.Builder instead. |
PWMChannelConfig(java.lang.String controllerName,
int channelNumber,
int idleState,
int pulsePeriod,
int pulseAlignment,
GPIOPinConfig output)
Deprecated.
As of 1.1, use
PWMChannelConfig.Builder instead. |
Modifier and Type | Method and Description |
---|---|
static PWMChannelConfig |
deserialize(java.io.InputStream in)
Creates a new
PWMChannelConfig whose state is deserialized from the specified InputStream . |
boolean |
equals(java.lang.Object obj)
Checks two
PWMChannelConfig objects for equality. |
int |
getChannelNumber()
Gets the configured PWM channel number.
|
java.lang.String |
getControllerName()
Gets the configured controller name (such as its device file name on UNIX systems).
|
int |
getControllerNumber()
Gets the configured controller number (the PWM controller or generator number).
|
int |
getIdleState()
Gets the configured idle output state.
|
GPIOPin |
getOutput()
Deprecated.
As of 1.1, replaced by
PWMChannel.getOutput . |
int |
getOutputBufferSize()
Gets the requested or allocated output buffer size.
|
GPIOPinConfig |
getOutputConfig()
Gets the configured output configuration on which the pulses are to be generated.
|
int |
getPulseAlignment()
Gets the configured pulse alignment.
|
int |
getPulsePeriod()
Gets the configured initial scaled pulse period (in microseconds).
|
double |
getScaleFactor()
Gets the configured initial pulse period scale factor.
|
int |
hashCode()
Returns the hash code value for this object.
|
int |
serialize(java.io.OutputStream out)
Serializes the state of this
PWMChannelConfig object to the specified OutputStream . |
public static final int IDLE_STATE_HIGH
public static final int IDLE_STATE_LOW
public static final int ALIGN_CENTER
public static final int ALIGN_LEFT
public static final int ALIGN_RIGHT
@Deprecated public PWMChannelConfig(int controllerNumber, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment)
PWMChannelConfig.Builder
instead.PWMChannelConfig
with the specified hardware addressing information and configuration parameters. The output of
the PWM channel is implicit (such as a dedicated output pin).
The controller name is set to null
.
The requested output buffer size is set to UNASSIGNED
.
The pulse period time scale factor is set to 1.0
.
controllerNumber
- the hardware PWM controller (or generator)'s number (a positive or zero integer) or UNASSIGNED
.channelNumber
- the hardware PWM channel's number (a positive or zero integer) or UNASSIGNED
.idleState
- the output idle state: IDLE_STATE_HIGH
, IDLE_STATE_LOW
or UNASSIGNED
.pulsePeriod
- the initial pulse period in microseconds (a positive integer) or UNASSIGNED
.pulseAlignment
- the pulse alignment: ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or
UNASSIGNED
.java.lang.IllegalArgumentException
- if any of the following is true:
controllerNumber
is not in the defined range;channelNumber
is not in the defined range;idleState
is not in the defined range;pulsePeriod
is not in the defined range.pulseAlignment
is not in the defined range.@Deprecated public PWMChannelConfig(int controllerNumber, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment, GPIOPinConfig output)
PWMChannelConfig.Builder
instead.PWMChannelConfig
the specified hardware addressing information, configuration parameters and GPIO pin output.
The controller name is set to null
.
The requested output buffer size is set to UNASSIGNED
.
The pulse period time scale factor is set to 1.0
.
If the access modes (exclusive or shared) supported by the designated
GPIO pin output are incompatible with those required by the underlying PWMChannel
device or device driver, attempting to open
the PWMChannel
device using this configuration may result in a
InvalidDeviceConfigException
to be thrown.
controllerNumber
- the hardware PWM controller (or generator)'s number (a positive or zero integer) or UNASSIGNED
.channelNumber
- the hardware PWM channel's number (a positive or zero integer) or UNASSIGNED
.idleState
- the output idle state: IDLE_STATE_HIGH
, IDLE_STATE_LOW
or UNASSIGNED
.pulsePeriod
- the initial pulse period in microseconds (a positive integer) or UNASSIGNED
.pulseAlignment
- the pulse alignment: ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or
UNASSIGNED
.output
- the configuration of the output (a GPIO output pin) on which the pulses are to be generated.java.lang.IllegalArgumentException
- if any of the following is true:
controllerNumber
is not in the defined range;channelNumber
is not in the defined range;idleState
is not in the defined range;pulsePeriod
is not in the defined range;pulseAlignment
is not in the defined range;GPIOPinConfig.DIR_OUTPUT_ONLY
or GPIOPinConfig.DIR_BOTH_INIT_OUTPUT
.java.lang.NullPointerException
- if output
is null
.@Deprecated public PWMChannelConfig(java.lang.String controllerName, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment)
PWMChannelConfig.Builder
instead.PWMChannelConfig
with the specified hardware addressing information and configuration parameters. The output of
the PWM channel is implicit (such as a dedicated output pin).
The controller number is set to UNASSIGNED
.
The requested output buffer size is set to UNASSIGNED
.
The pulse period time scale factor is set to 1.0
.
controllerName
- the controller name (such as its device file name on UNIX systems).channelNumber
- the hardware PWM channel's number (a positive or zero integer) or UNASSIGNED
.idleState
- the output idle state: IDLE_STATE_HIGH
, IDLE_STATE_LOW
or UNASSIGNED
.pulsePeriod
- the initial pulse period in microseconds (a positive integer) or UNASSIGNED
.pulseAlignment
- the pulse alignment: ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or
UNASSIGNED
.java.lang.IllegalArgumentException
- if any of the following is true:
channelNumber
is not in the defined range;idleState
is not in the defined range;pulsePeriod
is not in the defined range;pulseAlignment
is not in the defined range.java.lang.NullPointerException
- if controllerName
is null
.@Deprecated public PWMChannelConfig(java.lang.String controllerName, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment, GPIOPinConfig output)
PWMChannelConfig.Builder
instead.PWMChannelConfig
the specified hardware addressing information, configuration parameters and GPIO pin output.
The controller number is set to UNASSIGNED
.
The requested output buffer size is set to UNASSIGNED
.
The pulse period time scale factor is set to 1.0
.
If the access modes (exclusive or shared) supported by the designated
GPIO pin output are incompatible with those required by the underlying PWMChannel
device or device driver, attempting to open
the PWMChannel
device using this configuration may result in a
InvalidDeviceConfigException
to be thrown.
controllerName
- the controller name (such as its device file name on UNIX systems).channelNumber
- the hardware PWM channel's number (a positive or zero integer) or UNASSIGNED
.idleState
- the output idle state: IDLE_STATE_HIGH
, IDLE_STATE_LOW
or UNASSIGNED
.pulsePeriod
- the initial pulse period in microseconds (a positive integer) or UNASSIGNED
.pulseAlignment
- the pulse alignment: ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or
UNASSIGNED
.output
- the configuration of the output (a GPIO output pin) on which the pulses are to be generated.java.lang.IllegalArgumentException
- if any of the following is true:
channelNumber
is not in the defined range;idleState
is not in the defined range;pulsePeriod
is not in the defined range;pulseAlignment
is not in the defined range;GPIOPinConfig.DIR_OUTPUT_ONLY
or GPIOPinConfig.DIR_BOTH_INIT_OUTPUT
.java.lang.NullPointerException
- if controllerName
or output
is null
.public static PWMChannelConfig deserialize(java.io.InputStream in) throws java.io.IOException
PWMChannelConfig
whose state is deserialized from the specified InputStream
.
This method may be invoked to restore the state of a PWMChannelConfig
object from a persistent store.in
- the stream to read from.PWMChannelConfig
instance.java.io.IOException
- if an I/O error occurs or if the provided stream does not
contain a representation of a PWMChannelConfig
object.public int serialize(java.io.OutputStream out) throws java.io.IOException
PWMChannelConfig
object to the specified OutputStream
.
This method may be invoked by the DeviceManager
to save the state of this PWMChannelConfig
object to a persistent store.serialize
in interface DeviceConfig<PWMChannel>
out
- the stream to write to.java.io.IOException
- if an I/O error occurs.DeviceProvider.deserialize(java.io.InputStream)
public int getChannelNumber()
UNASSIGNED
.public int getControllerNumber()
getControllerNumber
in interface DeviceConfig.HardwareAddressing
UNASSIGNED
.public java.lang.String getControllerName()
getControllerName
in interface DeviceConfig.HardwareAddressing
null
.public int getOutputBufferSize()
UNASSIGNED
.public GPIOPinConfig getOutputConfig()
null
if the output is implicit.@Deprecated public GPIOPin getOutput()
PWMChannel.getOutput
.
A concurrent runtime change of the
dynamic configuration parameters of the output (such as of its direction) may result in
IOException
being thrown by PWM operations.
null
if the output is implicit
or if this PWMChannelConfig
instance is not associated to an actual PWMChannel
instance.public int getPulsePeriod()
UNASSIGNED
.public int getIdleState()
IDLE_STATE_HIGH
, IDLE_STATE_LOW
or UNASSIGNED
.public int getPulseAlignment()
ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or UNASSIGNED
public double getScaleFactor()
1.0
).public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
PWMChannelConfig
objects for equality.equals
in class java.lang.Object
obj
- the object to test for equality with this object.true
if obj
is a PWMChannelConfig
and has
the same hardware addressing information and configuration parameter values
as this PWMChannelConfig
object; false
otherwise.Copyright © 2012, 2015, Oracle and/or its affiliates. All rights reserved.
Legal Notices