gpiotest

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2018 License: Apache-2.0 Imports: 6 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) 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
}

Pin implements gpio.PinIO.

Modify its members to simulate hardware events.

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 is concurrent safe.

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 is concurrent safe.

func (*Pin) Pull

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

Pull implements gpio.PinIn.

func (*Pin) Read

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

Read is concurrent safe.

func (*Pin) String

func (p *Pin) String() string

func (*Pin) WaitForEdge

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

WaitForEdge implements gpio.PinIn.

type PinPWM

type PinPWM struct {
	Pin

	D gpio.Duty     // duty
	P time.Duration // period
}

PinPWM implements gpio.PinPWM.

func (*PinPWM) PWM

func (p *PinPWM) PWM(duty gpio.Duty, period time.Duration) error

Jump to

Keyboard shortcuts

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