- All Superinterfaces:
Describable,Identity,IO<Pwm,,PwmConfig, PwmProvider> Lifecycle,OnOff<Pwm>,OnOffRead<Pwm>,OnOffWrite<Pwm>
- All Known Implementing Classes:
PwmBase
Pwm interface.
- Version:
- $Id: $Id
- Author:
- Robert Savage (http://www.savagehomeautomation.com)
-
Method Summary
Modifier and TypeMethodDescriptiondefault intGet the actual frequency value in Hertz (number of cycles per second) applied by the PWM signal generator after the PWM signal is turned 'ON'.Add a new PwmPreset to this PWM instance.default intaddress()Get the GPIO pin number/address of this PWM instance.applyPreset(String name) Apply/recall a PwmPreset by name to this PWM instance.deletePreset(String name) Delete/remove a PwmPreset by name from this PWM instance.default floatGet 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 PwmSet 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 intGet 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 Pwmfrequency(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'.intGet 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 intGet the GPIO pin number/address of this PWM instance.floatGet 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.intGet 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'.Get a single PwmPreset from this PWM instance by the preset's name.Get all the PwmPreset instances assigned to this PWM instance.default PwmTypeGet the PWM type of this PWM instance.default booleanisOff()Get the PWM signal OFF/DISABLED state.booleanisOn()Get the PWM signal ON/ENABLED state.static PwmConfigBuildernewConfigBuilder(Context context) newConfigBuilder.off()Turn the PWM signal [OFF] by applying a zero frequency and zero duty-cycle to the PWM pin.on()Turn the PWM signal [ON] using the configured frequency and duty-cycle.default PwmTurn the PWM signal [ON] using a specified duty-cycle (%) at the pre-configured frequency (Hz).default PwmTurn the PWM signal [ON] using a specified duty-cycle (%) at the pre-configured frequency (Hz).default PwmPresetGet a single PwmPreset from this PWM instance by the preset's name.presets()Get all the PwmPreset assigned to this PWM instance.default PwmTypepwmType()Get the PWM type of this PWM instance.voidsetDutyCycle(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.voidsetFrequency(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, nameMethods inherited from interface com.pi4j.common.Lifecycle
initialize, shutdown
-
Method Details
-
newConfigBuilder
newConfigBuilder.
- Parameters:
context-Context- Returns:
- a
PwmConfigBuilderobject.
-
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
Turn the PWM signal [ON] using the configured frequency and duty-cycle.- Specified by:
onin interfaceOnOffWrite<Pwm>- Returns:
- returns this PWM instance
- Throws:
IOException- if fails to communicate with the PWM pin
-
off
Turn the PWM signal [OFF] by applying a zero frequency and zero duty-cycle to the PWM pin.- Specified by:
offin interfaceOnOffWrite<Pwm>- Returns:
- a
Pwmobject. - Throws:
IOException- if fails to communicate with the PWM pin
-
pwmType
Get the PWM type of this PWM instance. (Hardware/Software)- Returns:
- the PWM type of this PWM instance.
-
getPwmType
Get the PWM type of this PWM instance. (Hardware/Software)- Returns:
- the PWM type of this PWM instance.
-
on
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
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
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
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
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
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
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
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
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
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
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
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
Get all the PwmPreset instances assigned to this PWM instance.- Returns:
- a map of PwmPresets indexed/cataloged by preset name.
-
presets
Get all the PwmPreset assigned to this PWM instance.- Returns:
- a map of PwmPreset indexed/cataloged by preset name.
-
getPreset
Get a single PwmPreset from this PWM instance by the preset's name.- Parameters:
name- preset name string- Returns:
- a single PwmPreset instance
-
preset
Get a single PwmPreset from this PWM instance by the preset's name.- Parameters:
name- preset name string- Returns:
- a single PwmPreset instance
-
deletePreset
Delete/remove a PwmPreset by name from this PWM instance.- Parameters:
name- preset name string- Returns:
- the deleted PWM Preset instance
-
addPreset
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
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
-