Struct rppal::pwm::Pwm[][src]

pub struct Pwm { /* fields omitted */ }
Expand description

Provides access to the Raspberry Pi’s PWM peripheral.

Before using Pwm, make sure the selected PWM channel has been configured and activated. More information can be found here.

The embedded-hal PwmPin trait implementation for Pwm can be enabled by specifying the optional hal feature in the dependency declaration for the rppal crate.

The unproven embedded-hal Pwm trait implementation for Pwm can be enabled by specifying the optional hal-unproven feature in the dependency declaration for the rppal crate.

Implementations

Constructs a new Pwm.

new doesn’t change the channel’s period, pulse width or polarity. The channel will remain disabled until enable is called.

Constructs a new Pwm using the specified settings.

period indicates the time it takes for the PWM channel to complete one cycle.

pulse_width indicates the amount of time the PWM channel is active during a single period.

polarity configures the active logic level as either high (Normal) or low (Inverse).

enabled enables PWM on the selected channel. If enabled is set to false, the channel will remain disabled until enable is called.

This method will fail if period is shorter than pulse_width.

Constructs a new Pwm using the specified settings.

with_frequency is a convenience method that converts frequency to a period, and calculates the duty cycle as a percentage of the frequency.

frequency is specified in hertz (Hz).

duty_cycle is specified as a floating point value between 0.0 (0%) and 1.0 (100%).

polarity configures the active logic level as either high (Normal) or low (Inverse).

enabled enables PWM on the selected channel. If enabled is set to false, the channel will remain disabled until enable is called.

Returns the period.

Sets the period.

period indicates the time it takes for the PWM channel to complete one cycle.

This method will fail if period is shorter than the current pulse width.

Returns the pulse width.

Sets the pulse width.

pulse_width indicates the amount of time the PWM channel is active during a single period.

This method will fail if pulse_width is longer than the current period.

Returns the frequency.

frequency is a convenience method that calculates the frequency in hertz (Hz) based on the configured period.

Sets the frequency and duty cycle.

set_frequency is a convenience method that converts frequency to a period, and calculates the duty cycle as a percentage of the frequency.

frequency is specified in hertz (Hz).

duty_cycle is specified as a floating point value between 0.0 (0%) and 1.0 (100%).

Returns the duty cycle.

duty_cycle is a convenience method that calculates the duty cycle as a floating point value between 0.0 (0%) and 1.0 (100%) based on the configured period and pulse width.

Sets the duty cycle.

set_duty_cycle is a convenience method that converts duty_cycle to a pulse width based on the configured period.

duty_cycle is specified as a floating point value between 0.0 (0%) and 1.0 (100%).

Returns the polarity.

Sets the polarity.

polarity configures the active logic level as either high (Normal) or low (Inverse).

Returns true if the PWM channel is enabled.

Enables the PWM channel.

Disables the PWM channel.

Returns the value of reset_on_drop.

When enabled, disables the PWM channel when the Pwm instance goes out of scope. By default, this is set to true.

Note

Drop methods aren’t called when a process is abnormally terminated, for instance when a user presses Ctrl + C, and the SIGINT signal isn’t caught. You can catch those using crates such as simple_signal.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Pwm trait implementation for embedded-hal v1.0.0-alpha.5.

Disables a PWM channel.

Enables a PWM channel.

Returns the current PWM period.

Returns the current duty cycle.

Returns the maximum duty cycle value.

Sets a new duty cycle.

Sets a new PWM period.

Type for the duty methods Read more

Enumeration of channels that can be used with this Pwm interface Read more

A time unit that can be converted into a human time unit (e.g. seconds)

Enumeration of Pwm errors

Unproven Pwm trait implementation for embedded-hal v0.2.6.

Disables a PWM channel.

Enables a PWM channel.

Returns the current PWM period.

Returns the current duty cycle.

Returns the maximum duty cycle value.

Sets a new duty cycle.

Sets a new PWM period.

Type for the duty methods Read more

Enumeration of channels that can be used with this Pwm interface Read more

A time unit that can be converted into a human time unit (e.g. seconds)

PwmPin trait implementation for embedded-hal v1.0.0-alpha.5.

Type for the duty methods Read more

Enumeration of PwmPin errors

Disables a PWM channel

Enables a PWM channel

Returns the current duty cycle Read more

Returns the maximum duty cycle value

Sets a new duty cycle

PwmPin trait implementation for embedded-hal v0.2.6.

Type for the duty methods Read more

Disables a PWM channel

Enables a PWM channel

Returns the current duty cycle

Returns the maximum duty cycle value

Sets a new duty cycle

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.