pwm

package
v0.0.0-...-5cb36dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package pwm manages a sysfs exposed pwm pin, providing helpers to configure the pwm signal using more commonly understood values such as frequency and duty cycles

NOTE:

When changing period, period must be >= duty_ycle or the device will reject the change, see
https://github.com/torvalds/linux/blob/master/drivers/pwm/core.c#L471

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance implements the Pwm interface

func New

func New(logger *zap.SugaredLogger, channel int, frequencyHz float64) (*Instance, error)

New creates a new pwm instance

func (*Instance) GetDutyCycle

func (p *Instance) GetDutyCycle() (float64, error)

GetDutyCycle retrieves the current pwm values and returns a value from 0 to 100.0

func (*Instance) SetDutyCycle

func (p *Instance) SetDutyCycle(percentage float64) error

SetDutyCycle sets the pwm values for duty cycle, percentage is a value from 0 to 100.0

type Pwm

type Pwm interface {
	SetDutyCycle(percentage float64)
	GetDutyCycle() float64
}

Pwm provides an interface to a Pwm pin using percentages rather than nanosecond values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL