Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GPIO PWM Write #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gpio/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type Conn interface {
// GetValue gets the value of the pin. 0 for low values, 1 for high.
GetValue(pin string) (int, error)

// SetPWMValue sets the value of the pin. Value must be in the range 0-255.
SetPWMValue(pin string, v int) error

// SetDirection sets the direction of the pin.
SetDirection(pin string, dir Direction) error

Expand Down
5 changes: 5 additions & 0 deletions gpio/gpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func (d *Device) GetValue(pin string) (int, error) {
return d.conn.GetValue(pin)
}

// SetPWMValue sets the value of the pin. Value must be in range 0-255.
func (d *Device) SetPWMValue(pin string, v int) error {
return d.conn.SetPWMValue(pin, v)
}

// SetDirection configures the direction of the pin.
func (d *Device) SetDirection(pin string, dir Direction) error {
return d.conn.SetDirection(pin, driver.Direction(dir))
Expand Down