public static final class PWMChannelConfig.Builder
extends java.lang.Object
Builder
class allows for creating and initializing PWMChannelConfig
objects.
Calls can be chained in the following manner:
PWMChannelConfig config = new PWMChannelConfig.Builder() .setControllerNumber(1) .setChannelNumber(1) .setScaleFactor(1.0) .setPulsePeriod(10) .setIdleState(IDLE_STATE_HIGH) .setPulseAlignment(ALIGN_CENTER) .setOutputBufferSize(0) .build();
Constructor and Description |
---|
PWMChannelConfig.Builder()
Creates a new
Builder instance. |
Modifier and Type | Method and Description |
---|---|
PWMChannelConfig |
build()
Creates a new
PWMChannelConfig instance initialized with the
values set for each configuration parameters. |
PWMChannelConfig.Builder |
setChannelNumber(int channelNumber)
Sets the channel number (default value is
UNASSIGNED if not set). |
PWMChannelConfig.Builder |
setControllerName(java.lang.String controllerName)
Sets the controller name (default value is
null if not set). |
PWMChannelConfig.Builder |
setControllerNumber(int controllerNumber)
Sets the controller number (default value is
UNASSIGNED if not set). |
PWMChannelConfig.Builder |
setIdleState(int idleState)
Sets the idle output state (default value is
UNASSIGNED if not
set). |
PWMChannelConfig.Builder |
setOutputBufferSize(int outputBufferSize)
Sets the requested output buffer size (default value is
UNASSIGNED if not set). |
PWMChannelConfig.Builder |
setOutputConfig(GPIOPinConfig outputConfig)
Sets the configuration of the output (a GPIO output pin) on which the
pulses are to be generated (default value is
null if not set). |
PWMChannelConfig.Builder |
setPulseAlignment(int pulseAlignment)
Sets the pulse alignment - the alignment of the pulse within the pulse period (default value is
UNASSIGNED if not
set). |
PWMChannelConfig.Builder |
setPulsePeriod(int pulsePeriod)
Sets the initial scaled output sampling interval (default value is
UNASSIGNED if not
set). |
PWMChannelConfig.Builder |
setScaleFactor(double scaleFactor)
Sets the initial pulse period scale factor (default value is
1.0 if not set). |
public PWMChannelConfig.Builder()
Builder
instance.public PWMChannelConfig build()
PWMChannelConfig
instance initialized with the
values set for each configuration parameters. If a configuration parameter
was not explictly set its default value will be used.PWMChannelConfig
instance.public PWMChannelConfig.Builder setControllerName(java.lang.String controllerName)
null
if not set).controllerName
- the controller name (such as its device
file name on UNIX systems) or null
.Builder
instance.public PWMChannelConfig.Builder setChannelNumber(int channelNumber)
UNASSIGNED
if not set).channelNumber
- the channel number (a positive or zero integer)
or UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if channelNumber
is not in
the defined range.public PWMChannelConfig.Builder setControllerNumber(int controllerNumber)
UNASSIGNED
if not set).controllerNumber
- the hardware converter's number (a positive
or zero integer) or UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if controllerNumber
is not
in the defined range.public PWMChannelConfig.Builder setOutputConfig(GPIOPinConfig outputConfig)
null
if not set).outputConfig
- the configuration of the output (a GPIO output pin);
or null
if the output is implicit.Builder
instance.java.lang.IllegalArgumentException
- if outputConfig
is not
null
and outputConfig
's direction is not set to
GPIOPinConfig.DIR_OUTPUT_ONLY
or GPIOPinConfig.DIR_BOTH_INIT_OUTPUT
.public PWMChannelConfig.Builder setIdleState(int idleState)
UNASSIGNED
if not
set).idleState
- the idle output state: : PWMChannelConfig.IDLE_STATE_HIGH
, PWMChannelConfig.IDLE_STATE_LOW
or UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if idleState
is not in the
defined range.public PWMChannelConfig.Builder setPulsePeriod(int pulsePeriod)
UNASSIGNED
if not
set).pulsePeriod
- the initial scaled output sampling interval
(the amount of time between two samples) in microseconds (a positive
integer) or UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if pulsePeriod
is not
in the defined range.setScaleFactor(double)
public PWMChannelConfig.Builder setScaleFactor(double scaleFactor)
1.0
if not set).scaleFactor
- the sampling time and sampling interval scale
factor (a number greater or equal to 1.0
).Builder
instance.java.lang.IllegalArgumentException
- if scaleFactor
is NaN
or
is less than 1.0
.public PWMChannelConfig.Builder setPulseAlignment(int pulseAlignment)
UNASSIGNED
if not
set).pulseAlignment
- the pulse alignment: PWMChannelConfig.ALIGN_CENTER
, PWMChannelConfig.ALIGN_LEFT
, PWMChannelConfig.ALIGN_RIGHT
or UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if pulseAlignment
is not in the
defined range.public PWMChannelConfig.Builder setOutputBufferSize(int outputBufferSize)
UNASSIGNED
if not set).outputBufferSize
- the requested output buffer size in number of
samples (a positive or zero integer) or
UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if outputBufferSize
is not in
the defined range.Copyright © 2012, 2015, Oracle and/or its affiliates. All rights reserved.
Legal Notices