public class PWM
extends java.lang.Object
PWM
channel
lets you control the physical module PWM interface.
To obtain an instance of the PWM you have to use the
PWMManager.createPWM(int)
method.
Modifier and Type | Field | Description |
---|---|---|
static int |
FREQUENCY |
Deprecated.
This constant is no longer acceptable for default frequency. Use
getFrequency() |
static long |
PERIOD |
Deprecated.
This constant is no longer acceptable for default period. Use
getPeriod() |
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals(java.lang.Object other) |
|
int |
getChannelIndex() |
Retrieves the PWM channel index.
|
PWMChip |
getChip() |
Retrieves the PWM chip.
|
double |
getDutyCycle() |
Deprecated.
This method is no longer acceptable to read the PWM channel duty cycle percentage.
Use |
int |
getDutyCyclePercentage() |
Retrieves the configured duty cycle percentage of this PWM channel.
|
long |
getDutyCycleRaw() |
Retrieves the configured duty cycle of this PWM channel in nanoseconds.
|
long |
getFrequency() |
Retrieves the configured frequency of this PWM channel in Hz.
|
long |
getPeriod() |
Retrieves the configured period of this PWM channel in nanoseconds.
|
PWMPolarity |
getPolarity() |
Retrieves the configured polarity of this PWM channel.
|
int |
hashCode() |
|
boolean |
isEnabled() |
Retrieves the enable status of this PWM channel.
|
void |
setDutyCycle(double dutyCycle) |
Deprecated.
This method is no longer acceptable to set the PWM channel duty cycle percentage.
Use |
void |
setDutyCyclePercentage(int percentage) |
Sets the duty cycle percentage of the PWM signal.
|
void |
setDutyCycleRaw(long dutyCycle) |
Sets the duty cycle of the PWM signal in nanoseconds.
|
void |
setEnabled(boolean enable) |
Changes the enable status of this PWM channel.
|
void |
setFrequency(long frequency) |
Sets the frequency of the PWM signal in Hz.
|
void |
setPeriod(long period) |
Sets the period of the PWM signal in nanoseconds.
|
void |
setPolarity(PWMPolarity polarity) |
Sets the polarity of the PWM signal.
|
java.lang.String |
toString() |
@Deprecated public static final int FREQUENCY
getFrequency()
@Deprecated public static final long PERIOD
getPeriod()
public PWMChip getChip()
getChannelIndex()
,
PWMChip
public int getChannelIndex()
getChip()
@Deprecated public void setDutyCycle(double dutyCycle) throws java.lang.IllegalArgumentException, PWMException
Use setDutyCyclePercentage(double)
or setDutyCycleRaw(long)
instead.
dutyCycle
- The duty cycle percentage of the PWM signal (0 to 100%).java.lang.IllegalArgumentException
- If dutyCycle < 0
or
dutyCycle > 100
.PWMException
- If there is any error setting the duty cycle.@Deprecated public double getDutyCycle() throws PWMException
Use getDutyCyclePercentage()
or getDutyCycleRaw()
instead.
PWMException
- If there is any error reading the duty cycle.public void setPeriod(long period) throws java.lang.IllegalArgumentException, PWMException
period
- The new period to set in nanoseconds.java.lang.IllegalArgumentException
- If period < 1
PWMException
- If there is any error setting the period.getPeriod()
,
#setFrequency(int)
,
getFrequency()
public long getPeriod() throws PWMException
PWMException
- If there is any error reading the period.setPeriod(long)
,
#setFrequency(int)
,
getFrequency()
public void setDutyCycleRaw(long dutyCycle) throws java.lang.IllegalArgumentException, PWMException
dutyCycle
- The new duty cycle to set in nanoseconds.java.lang.IllegalArgumentException
- If dutyCycle < 0
or the duty cycle
to set is greater than the configured period.PWMException
- If there is any error setting the duty cycle.getDutyCycleRaw()
,
setDutyCyclePercentage(int)
,
getDutyCyclePercentage()
public long getDutyCycleRaw() throws PWMException
PWMException
- If there is any error reading the duty cycle.setDutyCycleRaw(long)
,
setDutyCyclePercentage(int)
,
getDutyCyclePercentage()
public void setDutyCyclePercentage(int percentage) throws java.lang.IllegalArgumentException, PWMException
percentage
- The new duty cycle percentage to set.java.lang.IllegalArgumentException
- If percentage < 0
or
if percentage > 100
PWMException
- If there is any error setting the duty cycle percentage.setDutyCycleRaw(long)
,
getDutyCycleRaw()
,
getDutyCyclePercentage()
public int getDutyCyclePercentage() throws PWMException
PWMException
- If there is any error reading the duty cycle percentage.setDutyCycleRaw(long)
,
getDutyCycleRaw()
,
setDutyCyclePercentage(int)
public void setFrequency(long frequency) throws java.lang.IllegalArgumentException, PWMException
frequency
- The new frequency to set in Hz.java.lang.IllegalArgumentException
- If frequency <= 0
or
if frequency > 1000000000
PWMException
- If there is any error setting the frequency.setPeriod(long)
,
getPeriod()
,
getFrequency()
public long getFrequency() throws PWMException
PWMException
- If there is any error reading the frequency.setPeriod(long)
,
getPeriod()
,
setFrequency(long)
public void setPolarity(PWMPolarity polarity) throws java.lang.NullPointerException, PWMException
polarity
- The new polarity to set.java.lang.NullPointerException
- If polarity == null
PWMException
- If there is any error setting the polarity.PWMPolarity
,
getPolarity()
public PWMPolarity getPolarity() throws PWMException
PWMException
- If there is any error reading the polarity.PWMPolarity
,
setPolarity(PWMPolarity)
public void setEnabled(boolean enable) throws PWMException
enable
- true
to enable the PWM channel, false
to disable it.PWMException
- If there is any error changing the enable status.isEnabled()
public boolean isEnabled() throws PWMException
true
if PWM channel is enabled, false
otherwise.PWMException
- If there is any error reading the enable status.setEnabled(boolean)
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object