-
- All Superinterfaces:
Describable
,Identity
,IO<Pwm,PwmConfig,PwmProvider>
,Lifecycle
,OnOff<Pwm>
,OnOffRead<Pwm>
,OnOffWrite<Pwm>
- All Known Implementing Classes:
PwmBase
public interface Pwm extends IO<Pwm,PwmConfig,PwmProvider>, OnOff<Pwm>
Pwm interface.
- Version:
- $Id: $Id
- Author:
- Robert Savage (http://www.savagehomeautomation.com)
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default int
actualFrequency()
Get the actual frequency value in Hertz (number of cycles per second) applied by the PWM signal generator after the PWM signal is turned 'ON'.Pwm
addPreset(PwmPreset preset)
Add a new PwmPreset to this PWM instance.default int
address()
Get the GPIO pin number/address of this PWM instance.Pwm
applyPreset(String name)
Apply/recall a PwmPreset by name to this PWM instance.PwmPreset
deletePreset(String name)
Delete/remove a PwmPreset by name from this PWM instance.default float
dutyCycle()
Get the duty-cycle value as a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period.default Pwm
dutyCycle(Number dutyCycle)
Set the duty-cycle value as a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period.default int
frequency()
Get the configured frequency value in Hertz (number of cycles per second) that the PWM signal generator should attempt to output when the PWM signal is turned 'ON'.default Pwm
frequency(int frequency)
Set the configured frequency value in Hertz (number of cycles per second) that the PWM signal generator should use when the PWM signal is turned 'ON'.int
getActualFrequency()
Get the actual frequency value in Hertz (number of cycles per second) applied by the PWM signal generator after the PWM signal is turned 'ON'.default int
getAddress()
Get the GPIO pin number/address of this PWM instance.float
getDutyCycle()
Get the duty-cycle value as a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period.int
getFrequency()
Get the configured frequency value in Hertz (number of cycles per second) that the PWM signal generator should attempt to output when the PWM signal is turned 'ON'.PwmPreset
getPreset(String name)
Get a single PwmPreset from this PWM instance by the preset's name.Map<String,PwmPreset>
getPresets()
Get all the PwmPreset instances assigned to this PWM instance.default PwmType
getPwmType()
Get the PWM type of this PWM instance.default boolean
isOff()
Get the PWM signal OFF/DISABLED state.boolean
isOn()
Get the PWM signal ON/ENABLED state.static PwmConfigBuilder
newConfigBuilder(Context context)
newConfigBuilder.Pwm
off()
Turn the PWM signal [OFF] by applying a zero frequency and zero duty-cycle to the PWM pin.Pwm
on()
Turn the PWM signal [ON] using the configured frequency and duty-cycle.default Pwm
on(Number dutyCycle)
Turn the PWM signal [ON] using a specified duty-cycle (%) at the pre-configured frequency (Hz).default Pwm
on(Number dutyCycle, int frequency)
Turn the PWM signal [ON] using a specified duty-cycle (%) at the pre-configured frequency (Hz).default PwmPreset
preset(String name)
Get a single PwmPreset from this PWM instance by the preset's name.default Map<String,PwmPreset>
presets()
Get all the PwmPreset assigned to this PWM instance.default PwmType
pwmType()
Get the PWM type of this PWM instance.void
setDutyCycle(Number dutyCycle)
Set the duty-cycle value as a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period.void
setFrequency(int frequency)
Set the configured frequency value in Hertz (number of cycles per second) that the PWM signal generator should use when the PWM signal is turned 'ON'.-
Methods inherited from interface com.pi4j.common.Identity
describe, description, getDescription, getId, getMetadata, getName, id, metadata, name
-
Methods inherited from interface com.pi4j.common.Lifecycle
initialize, shutdown
-
-
-
-
Method Detail
-
newConfigBuilder
static PwmConfigBuilder newConfigBuilder(Context context)
newConfigBuilder.
- Parameters:
context
-Context
- Returns:
- a
PwmConfigBuilder
object.
-
getAddress
default int getAddress()
Get the GPIO pin number/address of this PWM instance.- Returns:
- gpio pin number/address
-
address
default int address()
Get the GPIO pin number/address of this PWM instance.- Returns:
- gpio pin number/address
-
isOn
boolean isOn()
Get the PWM signal ON/ENABLED state.
-
isOff
default boolean isOff()
Get the PWM signal OFF/DISABLED state.
-
on
Pwm on() throws IOException
Turn the PWM signal [ON] using the configured frequency and duty-cycle.- Specified by:
on
in interfaceOnOffWrite<Pwm>
- Returns:
- returns this PWM instance
- Throws:
IOException
- if fails to communicate with the PWM pin
-
off
Pwm off() throws IOException
Turn the PWM signal [OFF] by applying a zero frequency and zero duty-cycle to the PWM pin.- Specified by:
off
in interfaceOnOffWrite<Pwm>
- Returns:
- a
Pwm
object. - Throws:
IOException
- if fails to communicate with the PWM pin
-
pwmType
default PwmType pwmType()
Get the PWM type of this PWM instance. (Hardware/Software)- Returns:
- the PWM type of this PWM instance.
-
getPwmType
default PwmType getPwmType()
Get the PWM type of this PWM instance. (Hardware/Software)- Returns:
- the PWM type of this PWM instance.
-
on
default Pwm on(Number dutyCycle) throws IOException
Turn the PWM signal [ON] using a specified duty-cycle (%) at the pre-configured frequency (Hz).- Parameters:
dutyCycle
- The duty-cycle value is a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period. A value of 50 represents a duty-cycle where half of the time period the signal is LOW and the other half is HIGH. The duty-cycle range is valid from 0 to 100 including factional values. (Values above 50% mean the signal will remain HIGH more time than LOW.)- Returns:
- returns this PWM instance
- Throws:
IOException
- if fails to communicate with the PWM pin
-
on
default Pwm on(Number dutyCycle, int frequency) throws IOException
Turn the PWM signal [ON] using a specified duty-cycle (%) at the pre-configured frequency (Hz).- Parameters:
dutyCycle
- The duty-cycle value is a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period. A value of 50 represents a duty-cycle where half of the time period the signal is LOW and the other half is HIGH. The duty-cycle range is valid from 0 to 100 including factional values. (Values above 50% mean the signal will remain HIGH more time than LOW.)frequency
- The desired frequency value in Hertz (number of cycles per second) that the PWM signal generator should attempt to output. Please note that certain PWM signal generators may be limited to specific frequency bands and may not generate all possible explicit frequency values. Immediately after calling this method, you can check the 'Pwm::actualFrequency()' or 'Pwm::getActualFrequency()' properties to determine what frequency the PWM generator actually applied.- Returns:
- returns this PWM instance
- Throws:
IOException
- if fails to communicate with the PWM pin
-
getDutyCycle
float getDutyCycle() throws IOException
Get the duty-cycle value as a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period. The duty-cycle range is valid from 0 to 100 including factional values. (Values above 50% mean the signal will remain HIGH more time than LOW.) Example: A value of 50 represents a duty-cycle where half of the time period the signal is LOW and the other half is HIGH.- Returns:
- duty-cycle value expressed as a percentage (rage: 0-100)
- Throws:
IOException
- if fails to communicate with the PWM pin
-
dutyCycle
default float dutyCycle() throws IOException
Get the duty-cycle value as a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period. The duty-cycle range is valid from 0 to 100 including factional values. (Values above 50% mean the signal will remain HIGH more time than LOW.) Example: A value of 50 represents a duty-cycle where half of the time period the signal is LOW and the other half is HIGH.- Returns:
- duty-cycle value expressed as a percentage (rage: 0-100)
- Throws:
IOException
- if fails to communicate with the PWM pin
-
setDutyCycle
void setDutyCycle(Number dutyCycle) throws IOException
Set the duty-cycle value as a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period. The duty-cycle range is valid from 0 to 100 including factional values. This method will not update a live PWM signal, but rather stage the duty-cycle value for subsequent call to the 'Pwm::On()' method. Call 'Pwm::On()' if you wish to make a live/ immediate change to the duty-cycle on an existing PWM signal. (Values above 50% mean the signal will remain HIGH more time than LOW.) Example: A value of 50 represents a duty-cycle where half of the time period the signal is LOW and the other half is HIGH.- Parameters:
dutyCycle
- duty-cycle value expressed as a percentage (rage: 0-100)- Throws:
IOException
- if fails to communicate with the PWM pin
-
dutyCycle
default Pwm dutyCycle(Number dutyCycle) throws IOException
Set the duty-cycle value as a decimal value that represents the percentage of the ON vs OFF time of the PWM signal for each period. The duty-cycle range is valid from 0 to 100 including factional values. This method will not update a live PWM signal, but rather stage the duty-cycle value for subsequent call to the 'Pwm::On()' method. Call 'Pwm::On()' if you wish to make a live/ immediate change to the duty-cycle on an existing PWM signal. (Values above 50% mean the signal will remain HIGH more time than LOW.) Example: A value of 50 represents a duty-cycle where half of the time period the signal is LOW and the other half is HIGH.- Parameters:
dutyCycle
- duty-cycle value expressed as a percentage (rage: 0-100)- Returns:
- returns this PWM instance
- Throws:
IOException
- if fails to communicate with the PWM pin
-
getFrequency
int getFrequency() throws IOException
Get the configured frequency value in Hertz (number of cycles per second) that the PWM signal generator should attempt to output when the PWM signal is turned 'ON'. Please note that certain PWM signal generators may be limited to specific frequency bands and may not generate all possible explicit frequency values. After enabling the PWM signal using the 'on(..) method, you can check the 'Pwm::frequency()' or 'Pwm::getFrequency()' properties to determine what frequency the PWM generator actually applied.- Returns:
- the configured frequency (Hz) that is used when turning the PWM signal to the 'ON' state.
- Throws:
IOException
- if fails to communicate with the PWM pin
-
frequency
default int frequency() throws IOException
Get the configured frequency value in Hertz (number of cycles per second) that the PWM signal generator should attempt to output when the PWM signal is turned 'ON'. Please note that certain PWM signal generators may be limited to specific frequency bands and may not generate all possible explicit frequency values. After enabling the PWM signal using the 'on(...)' method, you can check the 'Pwm::frequency()' or 'Pwm::getFrequency()' properties to determine what frequency the PWM generator actually applied.- Returns:
- the configured frequency (Hz) that is used when turning the PWM signal to the 'ON' state.
- Throws:
IOException
- if fails to communicate with the PWM pin
-
getActualFrequency
int getActualFrequency() throws IOException
Get the actual frequency value in Hertz (number of cycles per second) applied by the PWM signal generator after the PWM signal is turned 'ON'. Please note that certain PWM signal generators may be limited to specific frequency bands and may not generate all possible explicit frequency values. After enabling the PWM signal using the 'on(...)' method, you can call this method to determine what frequency the PWM generator actually applied.- Returns:
- the actual frequency (Hz) applied by the PWM generator when the PWM signal is set to the 'ON' state.
- Throws:
IOException
- if fails to communicate with the PWM pin
-
actualFrequency
default int actualFrequency() throws IOException
Get the actual frequency value in Hertz (number of cycles per second) applied by the PWM signal generator after the PWM signal is turned 'ON'. Please note that certain PWM signal generators may be limited to specific frequency bands and may not generate all possible explicit frequency values. After enabling the PWM signal using the 'on(...)' method, you can call this method to determine what frequency the PWM generator actually applied.- Returns:
- the actual frequency (Hz) applied by the PWM generator when the PWM signal is set to the 'ON' state.
- Throws:
IOException
- if fails to communicate with the PWM pin
-
setFrequency
void setFrequency(int frequency) throws IOException
Set the configured frequency value in Hertz (number of cycles per second) that the PWM signal generator should use when the PWM signal is turned 'ON'. Note: This method will not update a live PWM signal, but rather stage the frequency value for subsequent call to the 'Pwm::On()' method. Call 'Pwm::On()' if you wish to make a live/immediate change to the duty-cycle on an existing PWM signal.- Parameters:
frequency
- the number of cycles per second (Hertz)- Throws:
IOException
- if fails to communicate with the PWM pin
-
frequency
default Pwm frequency(int frequency) throws IOException
Set the configured frequency value in Hertz (number of cycles per second) that the PWM signal generator should use when the PWM signal is turned 'ON'. Note: This method will not update a live PWM signal, but rather stage the frequency value for subsequent call to the 'Pwm::On()' method. Call 'Pwm::On()' if you wish to make a live/immediate change to the duty-cycle on an existing PWM signal.- Parameters:
frequency
- the number of cycles per second (Hertz)- Returns:
- returns this PWM instance
- Throws:
IOException
- if fails to communicate with the PWM pin
-
getPresets
Map<String,PwmPreset> getPresets()
Get all the PwmPreset instances assigned to this PWM instance.- Returns:
- a map of PwmPresets indexed/cataloged by preset name.
-
presets
default Map<String,PwmPreset> presets()
Get all the PwmPreset assigned to this PWM instance.- Returns:
- a map of PwmPreset indexed/cataloged by preset name.
-
getPreset
PwmPreset getPreset(String name)
Get a single PwmPreset from this PWM instance by the preset's name.- Parameters:
name
- preset name string- Returns:
- a single PwmPreset instance
-
preset
default PwmPreset preset(String name)
Get a single PwmPreset from this PWM instance by the preset's name.- Parameters:
name
- preset name string- Returns:
- a single PwmPreset instance
-
deletePreset
PwmPreset deletePreset(String name)
Delete/remove a PwmPreset by name from this PWM instance.- Parameters:
name
- preset name string- Returns:
- the deleted PWM Preset instance
-
addPreset
Pwm addPreset(PwmPreset preset)
Add a new PwmPreset to this PWM instance. You can create new PWM preset instance using the 'PwmPreset::newBuilder(name)' static factory method.- Parameters:
preset
- a pre-configured PwmPreset instance- Returns:
- this PWM instance
-
applyPreset
Pwm applyPreset(String name) throws IOException
Apply/recall a PwmPreset by name to this PWM instance. This will update the PWM signal with the configured PWM frequency and duty-cycle defined in the preset object.- Parameters:
name
- preset name string- Returns:
- the deleted PWM Preset instance
- Throws:
IOException
- if fails to communicate with the PWM pin
-
-