gpiotest

package
v3.6.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package gpiotest is meant to be used to test drivers using fake Pins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogPinIO

type LogPinIO struct {
	gpio.PinIO
}

LogPinIO logs when its state changes.

func (*LogPinIO) In

func (p *LogPinIO) In(pull gpio.Pull, edge gpio.Edge) error

In implements gpio.PinIn.

func (*LogPinIO) Out

func (p *LogPinIO) Out(l gpio.Level) error

Out implements gpio.PinOut.

func (*LogPinIO) PWM

func (p *LogPinIO) PWM(duty gpio.Duty, f physic.Frequency) error

PWM implements gpio.PinOut.

func (*LogPinIO) Read

func (p *LogPinIO) Read() gpio.Level

Read implements gpio.PinIn.

func (*LogPinIO) Real

func (p *LogPinIO) Real() gpio.PinIO

Real implements gpio.RealPin.

func (*LogPinIO) WaitForEdge

func (p *LogPinIO) WaitForEdge(timeout time.Duration) bool

WaitForEdge implements gpio.PinIn.

type Pin

type Pin struct {
	// These should be immutable.
	N   string
	Num int
	Fn  string // TODO(maruel): pin.Func in v4.

	// Grab the Mutex before accessing the following members.
	sync.Mutex
	L         gpio.Level // Used for both input and output
	P         gpio.Pull
	EdgesChan chan gpio.Level  // Use it to fake edges
	D         gpio.Duty        // PWM duty
	F         physic.Frequency // PWM period
}

Pin implements gpio.PinIO.

Modify its members to simulate hardware events.

func (*Pin) DefaultPull

func (p *Pin) DefaultPull() gpio.Pull

DefaultPull implements gpio.PinIn.

func (*Pin) Func

func (p *Pin) Func() pin.Func

Func implements pin.PinFunc.

func (*Pin) Function

func (p *Pin) Function() string

Function implements pin.Pin.

func (*Pin) Halt

func (p *Pin) Halt() error

Halt implements conn.Resource.

It has no effect.

func (*Pin) In

func (p *Pin) In(pull gpio.Pull, edge gpio.Edge) error

In implements gpio.PinIn.

func (*Pin) Name

func (p *Pin) Name() string

Name implements pin.Pin.

func (*Pin) Number

func (p *Pin) Number() int

Number implements pin.Pin.

func (*Pin) Out

func (p *Pin) Out(l gpio.Level) error

Out implements gpio.PinOut.

func (*Pin) PWM

func (p *Pin) PWM(duty gpio.Duty, f physic.Frequency) error

PWM implements gpio.PinOut.

func (*Pin) Pull

func (p *Pin) Pull() gpio.Pull

Pull implements gpio.PinIn.

func (*Pin) Read

func (p *Pin) Read() gpio.Level

Read implements gpio.PinIn.

func (*Pin) SetFunc

func (p *Pin) SetFunc(f pin.Func) error

SetFunc implements pin.PinFunc.

func (*Pin) String

func (p *Pin) String() string

String implements conn.Resource.

func (*Pin) SupportedFuncs

func (p *Pin) SupportedFuncs() []pin.Func

SupportedFuncs implements pin.PinFunc.

func (*Pin) WaitForEdge

func (p *Pin) WaitForEdge(timeout time.Duration) bool

WaitForEdge implements gpio.PinIn.

Jump to

Keyboard shortcuts

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