public 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 parameter, and static and dynamic configuration parameters may be set to DeviceConfig.DEFAULT
.
Whether such default settings are supported is platform- as well as device driver-dependent.
An instance of PWMChannelConfig
can be passed to the DeviceManager.open(DeviceConfig)
or
DeviceManager.open(Class, DeviceConfig)
method 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.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
Constructor and Description |
---|
PWMChannelConfig(int controllerNumber,
int channelNumber,
int idleState,
int pulsePeriod,
int pulseAlignment)
Creates a new
PWMChannelConfig with the specified hardware addressing information and type. |
PWMChannelConfig(int controllerNumber,
int channelNumber,
int idleState,
int pulsePeriod,
int pulseAlignment,
GPIOPinConfig output)
Creates a new
PWMChannelConfig the specified hardware addressing information, type and GPIO pin output. |
PWMChannelConfig(java.lang.String controllerName,
int channelNumber,
int idleState,
int pulsePeriod,
int pulseAlignment)
Creates a new
PWMChannelConfig with the specified hardware addressing information and type. |
PWMChannelConfig(java.lang.String controllerName,
int channelNumber,
int idleState,
int pulsePeriod,
int pulseAlignment,
GPIOPinConfig output)
Creates a new
PWMChannelConfig the specified hardware addressing information, type and GPIO pin output. |
Modifier and Type | Method and Description |
---|---|
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()
Gets the output on which the pulses are to be generated.
|
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 default/initial pulse period (in microseconds).
|
int |
hashCode()
Returns the hash code value for this object.
|
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
public PWMChannelConfig(int controllerNumber, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment)
PWMChannelConfig
with the specified hardware addressing information and type. The output of
the PWM channel is implicit (such as a dedicated output pin).controllerNumber
- the hardware PWM controller (or generator)'s number (a positive or zero integer) or DeviceConfig.DEFAULT
.channelNumber
- the hardware PWM channel's number (a positive or zero integer) or DeviceConfig.DEFAULT
.idleState
- the output idle state: IDLE_STATE_HIGH
, IDLE_STATE_LOW
or DeviceConfig.DEFAULT
.pulsePeriod
- the default pulse period in microseconds (a positive integer) or DeviceConfig.DEFAULT
.pulseAlignment
- the pulse alignment: ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or
DeviceConfig.DEFAULT
.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.public PWMChannelConfig(int controllerNumber, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment, GPIOPinConfig output)
PWMChannelConfig
the specified hardware addressing information, type and GPIO pin output.
Note that 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 DeviceConfig.DEFAULT
.channelNumber
- the hardware PWM channel's number (a positive or zero integer) or DeviceConfig.DEFAULT
.idleState
- the output idle state: IDLE_STATE_HIGH
, IDLE_STATE_LOW
or DeviceConfig.DEFAULT
.pulsePeriod
- the default pulse period in microseconds (a positive integer) or DeviceConfig.DEFAULT
.pulseAlignment
- the pulse alignment: ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or
DeviceConfig.DEFAULT
.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.java.lang.NullPointerException
- if output
is null
.public PWMChannelConfig(java.lang.String controllerName, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment)
PWMChannelConfig
with the specified hardware addressing information and type. The output of
the PWM channel is implicit (such as a dedicated output pin).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 DeviceConfig.DEFAULT
.idleState
- the output idle state: IDLE_STATE_HIGH
, IDLE_STATE_LOW
or DeviceConfig.DEFAULT
.pulsePeriod
- the default pulse period in microseconds (a positive integer) or DeviceConfig.DEFAULT
.pulseAlignment
- the pulse alignment: ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or
DeviceConfig.DEFAULT
.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
.public PWMChannelConfig(java.lang.String controllerName, int channelNumber, int idleState, int pulsePeriod, int pulseAlignment, GPIOPinConfig output)
PWMChannelConfig
the specified hardware addressing information, type and GPIO pin output.
Note that 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 DeviceConfig.DEFAULT
.idleState
- the output idle state: IDLE_STATE_HIGH
, IDLE_STATE_LOW
or DeviceConfig.DEFAULT
.pulsePeriod
- the default pulse period in microseconds (a positive integer) or DeviceConfig.DEFAULT
.pulseAlignment
- the pulse alignment: ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or
DeviceConfig.DEFAULT
.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.java.lang.NullPointerException
- if controllerName
or output
is null
.public int getChannelNumber()
DeviceConfig.DEFAULT
.public int getControllerNumber()
getControllerNumber
in interface DeviceConfig.HardwareAddressing
DeviceConfig.DEFAULT
.public java.lang.String getControllerName()
getControllerName
in interface DeviceConfig.HardwareAddressing
null
.public GPIOPinConfig getOutputConfig()
null
if the output is implicit.public GPIOPin getOutput()
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()
DeviceConfig.DEFAULT
.public int getIdleState()
IDLE_STATE_HIGH
, IDLE_STATE_LOW
or DeviceConfig.DEFAULT
.public int getPulseAlignment()
ALIGN_CENTER
, ALIGN_LEFT
, ALIGN_RIGHT
or DeviceConfig.DEFAULT
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.Copyright © 2012, 2014, Oracle and/or its affiliates. All rights reserved.
Legal Notices