public class

PWM

extends Object
java.lang.Object
   ↳ com.digi.android.pwm.PWM

Class Overview

Represents a PWM (Pulse Width Modulation) channel. A 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.

Summary

Constants
int FREQUENCY This constant is deprecated. This constant is no longer acceptable for default frequency. Use ERROR(/getFrequency())
long PERIOD This constant is deprecated. This constant is no longer acceptable for default period. Use ERROR(/getPeriod())
Public Methods
boolean equals(Object other)
int getChannelIndex()
Retrieves the PWM channel index.
PWMChip getChip()
Retrieves the PWM chip.
double getDutyCycle()
This method is deprecated. This method is no longer acceptable to read the PWM channel duty cycle percentage.

Use ERROR(/getDutyCyclePercentage()) or ERROR(/getDutyCycleRaw()) instead.

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)
This method is deprecated. This method is no longer acceptable to set the PWM channel duty cycle percentage.

Use ERROR(/setDutyCyclePercentage(double)) or ERROR(/setDutyCycleRaw(long)) instead.

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.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int FREQUENCY

This constant is deprecated.
This constant is no longer acceptable for default frequency. Use ERROR(/getFrequency())

Default frequency configured in the PWM: .FREQUENCY Hz.

Constant Value: 21000 (0x00005208)

public static final long PERIOD

This constant is deprecated.
This constant is no longer acceptable for default period. Use ERROR(/getPeriod())

Default period configured in the PWM: .PERIOD nanoseconds.

Constant Value: 47619 (0x000000000000ba03)

Public Methods

public boolean equals (Object other)

Parameters
other Object
Returns
boolean

public int getChannelIndex ()

Retrieves the PWM channel index.

Returns
int The PWM channel index.

See also:

public PWMChip getChip ()

Retrieves the PWM chip.

Returns
PWMChip The PWM chip.

public double getDutyCycle ()

This method is deprecated.
This method is no longer acceptable to read the PWM channel duty cycle percentage.

Use ERROR(/getDutyCyclePercentage()) or ERROR(/getDutyCycleRaw()) instead.

Retrieves the duty cycle percentage configured in this PWM channel.

Returns
double dutyCycle The duty cycle percentage configured in this PWM channel (0 to 100%).
Throws
PWMException If there is any error reading the duty cycle.

public int getDutyCyclePercentage ()

Retrieves the configured duty cycle percentage of this PWM channel.

Returns
int The configured duty cycle percentage of this PWM channel.
Throws
PWMException If there is any error reading the duty cycle percentage.

public long getDutyCycleRaw ()

Retrieves the configured duty cycle of this PWM channel in nanoseconds.

Returns
long The configured duty cycle of this PWM channel in nanoseconds.
Throws
PWMException If there is any error reading the duty cycle.

public long getFrequency ()

Retrieves the configured frequency of this PWM channel in Hz.

Returns
long The configured frequency of this PWM channel in Hz.
Throws
PWMException If there is any error reading the frequency.

public long getPeriod ()

Retrieves the configured period of this PWM channel in nanoseconds.

Returns
long The configured period of this PWM channel in nanoseconds.
Throws
PWMException If there is any error reading the period.

public PWMPolarity getPolarity ()

Retrieves the configured polarity of this PWM channel.

Returns
PWMPolarity The configured polarity of this PWM channel.
Throws
PWMException If there is any error reading the polarity.

public int hashCode ()

Returns
int

public boolean isEnabled ()

Retrieves the enable status of this PWM channel.

Returns
boolean true if PWM channel is enabled, false otherwise.
Throws
PWMException If there is any error reading the enable status.

public void setDutyCycle (double dutyCycle)

This method is deprecated.
This method is no longer acceptable to set the PWM channel duty cycle percentage.

Use ERROR(/setDutyCyclePercentage(double)) or ERROR(/setDutyCycleRaw(long)) instead.

Sets the duty cycle percentage of the PWM signal.

Parameters
dutyCycle double: The duty cycle percentage of the PWM signal (0 to 100%).
Throws
IllegalArgumentException If dutyCycle < 0 or dutyCycle > 100.
PWMException If there is any error setting the duty cycle.

public void setDutyCyclePercentage (int percentage)

Sets the duty cycle percentage of the PWM signal.

Parameters
percentage int: The new duty cycle percentage to set.
Throws
IllegalArgumentException If percentage < 0 or if percentage > 100
PWMException If there is any error setting the duty cycle percentage.

public void setDutyCycleRaw (long dutyCycle)

Sets the duty cycle of the PWM signal in nanoseconds.

Parameters
dutyCycle long: The new duty cycle to set in nanoseconds.
Throws
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.

public void setEnabled (boolean enable)

Changes the enable status of this PWM channel.

Parameters
enable boolean: true to enable the PWM channel, false to disable it.
Throws
PWMException If there is any error changing the enable status.

See also:

public void setFrequency (long frequency)

Sets the frequency of the PWM signal in Hz.

Parameters
frequency long: The new frequency to set in Hz.
Throws
IllegalArgumentException If frequency <= 0 or if frequency > 1000000000
PWMException If there is any error setting the frequency.

public void setPeriod (long period)

Sets the period of the PWM signal in nanoseconds.

Parameters
period long: The new period to set in nanoseconds.
Throws
IllegalArgumentException If period < 1
PWMException If there is any error setting the period.

public void setPolarity (PWMPolarity polarity)

Sets the polarity of the PWM signal.

Parameters
polarity PWMPolarity: The new polarity to set.
Throws
NullPointerException If polarity == null
PWMException If there is any error setting the polarity.

public String toString ()

Returns
String