Pwmx.State (Pwmx v0.1.0)

Copy Markdown View Source

Struct keeping track of a PWM Output state. When developing on a non-linux box, or a linux box without PWM outputs, this struct is used instead of the sysfs calls. When running on the real board, this struct caches the values provided by the sysfs interface.

Summary

Functions

Sets the chip field to a binary value.

Sets the duty_cycle field to an integer value.

Sets the enabled field to a boolean value.

Sets the exported field to true.

Sets the inverted field to true.

Sets the inverted field to false.

Sets the output field to an integer value.

Sets the period field to an integer value.

Sets the exported field to false.

Types

t()

@type t() :: %Pwmx.State{
  chip: term(),
  duty_cycle: term(),
  enabled: term(),
  exported: term(),
  inverted: term(),
  output: term(),
  period: term()
}

Functions

set_chip(s, value)

@spec set_chip(t(), binary()) :: t()

Sets the chip field to a binary value.

iex> %{chip: "virtualchip0"} = (%Pwmx.State{} |> Pwmx.State.set_chip("virtualchip0"))

set_duty_cycle(s, value)

@spec set_duty_cycle(t(), integer()) :: t()

Sets the duty_cycle field to an integer value.

iex> %{duty_cycle: 1000} = (%Pwmx.State{} |> Pwmx.State.set_duty_cycle(1000))

set_enabled(s, value)

@spec set_enabled(t(), boolean()) :: t()

Sets the enabled field to a boolean value.

iex> %{enabled: false} = (%Pwmx.State{} |> Pwmx.State.set_enabled(false))

set_exported(s)

@spec set_exported(t()) :: t()

Sets the exported field to true.

iex> %{exported: true} = (%Pwmx.State{} |> Pwmx.State.set_exported())

set_inverted(s)

@spec set_inverted(t()) :: t()

Sets the inverted field to true.

iex> %{inverted: true} = (%Pwmx.State{} |> Pwmx.State.set_inverted())

set_not_inverted(s)

@spec set_not_inverted(t()) :: t()

Sets the inverted field to false.

iex> %{inverted: false} = (%Pwmx.State{} |> Pwmx.State.set_not_inverted())

set_output(s, value)

@spec set_output(t(), integer()) :: t()

Sets the output field to an integer value.

iex> %{output: 1} = (%Pwmx.State{} |> Pwmx.State.set_output(1))

set_period(s, value)

@spec set_period(t(), integer()) :: t()

Sets the period field to an integer value.

iex> %{period: 1000} = (%Pwmx.State{} |> Pwmx.State.set_period(1000))

set_unexported(s)

@spec set_unexported(t()) :: t()

Sets the exported field to false.

iex> %{exported: false} = (%Pwmx.State{} |> Pwmx.State.set_unexported())