gpiotest

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: Apache-2.0 Imports: 7 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.PinIO.

func (*LogPinIO) Out

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

Out implements gpio.PinIO.

func (*LogPinIO) PWM

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

PWM implements gpio.PinIO.

func (*LogPinIO) Pull

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

Pull implements gpio.PinIO.

func (*LogPinIO) Read

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

Read implements gpio.PinIO.

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.PinIO.

type Pin

type Pin struct {
	N   string // Should be immutable
	Num int    // Should be immutable
	Fn  string // Should be immutable

	sync.Mutex            // Grab the Mutex before modifying the members to keep it concurrent safe
	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) Function

func (p *Pin) Function() string

Function return the value of the Fn field of the 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 returns the name of the pin.

func (*Pin) Number

func (p *Pin) Number() int

Number returns the pin number.

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) String

func (p *Pin) String() string

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