Documentation
¶
Overview ¶
Package fake implements a fake board.
Index ¶
- func AddCallback(s *DigitalInterruptWrapper, c chan board.Tick)
- func Tick(ctx context.Context, s *DigitalInterruptWrapper, high bool, nanoseconds uint64) error
- type Analog
- type Board
- func (b *Board) AnalogByName(name string) (board.Analog, error)
- func (b *Board) AnalogNames() []string
- func (b *Board) Close(ctx context.Context) error
- func (b *Board) DigitalInterruptByName(name string) (board.DigitalInterrupt, error)
- func (b *Board) DigitalInterruptNames() []string
- func (b *Board) GPIOPinByName(name string) (board.GPIOPin, error)
- func (b *Board) Reconfigure(ctx context.Context, deps resource.Dependencies, conf resource.Config) error
- func (b *Board) SetPowerMode(ctx context.Context, mode pb.PowerMode, duration *time.Duration) error
- func (b *Board) StreamTicks(ctx context.Context, interrupts []board.DigitalInterrupt, ch chan board.Tick, ...) error
- func (b *Board) WriteAnalog(ctx context.Context, pin string, value int32, extra map[string]interface{}) error
- type Config
- type DigitalInterruptWrapper
- type GPIOPin
- func (gp *GPIOPin) Get(ctx context.Context, extra map[string]interface{}) (bool, error)
- func (gp *GPIOPin) PWM(ctx context.Context, extra map[string]interface{}) (float64, error)
- func (gp *GPIOPin) PWMFreq(ctx context.Context, extra map[string]interface{}) (uint, error)
- func (gp *GPIOPin) Set(ctx context.Context, high bool, extra map[string]interface{}) error
- func (gp *GPIOPin) SetPWM(ctx context.Context, dutyCyclePct float64, extra map[string]interface{}) error
- func (gp *GPIOPin) SetPWMFreq(ctx context.Context, freqHz uint, extra map[string]interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCallback ¶ added in v0.26.0
func AddCallback(s *DigitalInterruptWrapper, c chan board.Tick)
AddCallback adds a callback to be sent a low/high value to when a tick happens.
Types ¶
type Analog ¶
type Analog struct { Value int CloseCount int Mu sync.RWMutex // contains filtered or unexported fields }
An Analog reads back the same set value.
type Board ¶
type Board struct { resource.Named Analogs map[string]*Analog Digitals map[string]*DigitalInterruptWrapper GPIOPins map[string]*GPIOPin CloseCount int // contains filtered or unexported fields }
A Board provides dummy data from fake parts in order to implement a Board.
func (*Board) AnalogByName ¶ added in v0.26.0
AnalogByName returns the analog pin by the given name if it exists.
func (*Board) AnalogNames ¶ added in v0.26.0
AnalogNames returns the names of all known analog pins.
func (*Board) DigitalInterruptByName ¶
func (b *Board) DigitalInterruptByName(name string) (board.DigitalInterrupt, error)
DigitalInterruptByName returns the interrupt by the given name if it exists.
func (*Board) DigitalInterruptNames ¶
DigitalInterruptNames returns the names of all known digital interrupts.
func (*Board) GPIOPinByName ¶
GPIOPinByName returns the GPIO pin by the given name if it exists.
func (*Board) Reconfigure ¶ added in v0.2.36
func (b *Board) Reconfigure(ctx context.Context, deps resource.Dependencies, conf resource.Config) error
Reconfigure atomically reconfigures this board in place based on the new config.
func (*Board) SetPowerMode ¶ added in v0.2.28
SetPowerMode sets the board to the given power mode. If provided, the board will exit the given power mode after the specified duration.
type Config ¶
type Config struct { AnalogReaders []board.AnalogReaderConfig `json:"analogs,omitempty"` DigitalInterrupts []board.DigitalInterruptConfig `json:"digital_interrupts,omitempty"` FailNew bool `json:"fail_new"` }
A Config describes the configuration of a fake board and all of its connected parts.
type DigitalInterruptWrapper ¶ added in v0.2.36
type DigitalInterruptWrapper struct {
// contains filtered or unexported fields
}
DigitalInterruptWrapper is a wrapper around a digital interrupt for testing fake boards.
func NewDigitalInterruptWrapper ¶ added in v0.2.36
func NewDigitalInterruptWrapper(conf board.DigitalInterruptConfig) (*DigitalInterruptWrapper, error)
NewDigitalInterruptWrapper returns a new digital interrupt to be used for testing.
func (*DigitalInterruptWrapper) Close ¶ added in v0.2.36
func (s *DigitalInterruptWrapper) Close(ctx context.Context) error
Close does nothing.
func (*DigitalInterruptWrapper) Name ¶ added in v0.26.0
func (s *DigitalInterruptWrapper) Name() string
Name returns the name of the digital interrupt.
func (*DigitalInterruptWrapper) RemoveCallback ¶ added in v0.2.36
func (s *DigitalInterruptWrapper) RemoveCallback(c chan board.Tick)
RemoveCallback removes a listener for interrupts.
type GPIOPin ¶
type GPIOPin struct {
// contains filtered or unexported fields
}
A GPIOPin reads back the same set values.