Documentation ¶
Overview ¶
Package pinwrappers implements interfaces that wrap the basic board interface and return types, and expands them with new methods and interfaces for the built in board models. Current expands analog reader and digital interrupt.
Index ¶
- func AddCallback(i *BasicDigitalInterrupt, c chan board.Tick)
- func RemoveCallback(i *BasicDigitalInterrupt, c chan board.Tick)
- func Tick(ctx context.Context, i *BasicDigitalInterrupt, high bool, nanoseconds uint64) error
- type AnalogSmoother
- type BasicDigitalInterrupt
- type ReconfigurableDigitalInterrupt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCallback ¶
func AddCallback(i *BasicDigitalInterrupt, c chan board.Tick)
AddCallback adds a listener for interrupts.
func RemoveCallback ¶ added in v0.27.0
func RemoveCallback(i *BasicDigitalInterrupt, c chan board.Tick)
RemoveCallback removes a listener for interrupts.
Types ¶
type AnalogSmoother ¶
type AnalogSmoother struct { Raw board.Analog AverageOverMillis int SamplesPerSecond int // contains filtered or unexported fields }
An AnalogSmoother smooths the readings out from an underlying reader.
func SmoothAnalogReader ¶
func SmoothAnalogReader(r board.Analog, c board.AnalogReaderConfig, logger logging.Logger) *AnalogSmoother
SmoothAnalogReader wraps the given reader in a smoother.
func (*AnalogSmoother) Close ¶
func (as *AnalogSmoother) Close(ctx context.Context) error
Close stops the smoothing routine.
func (*AnalogSmoother) Start ¶
func (as *AnalogSmoother) Start()
Start begins the smoothing routine that reads from the underlying analog reader.
type BasicDigitalInterrupt ¶
type BasicDigitalInterrupt struct {
// contains filtered or unexported fields
}
A BasicDigitalInterrupt records how many ticks/interrupts happen and can report when they happen to interested callbacks.
func (*BasicDigitalInterrupt) Name ¶
func (i *BasicDigitalInterrupt) Name() string
Name returns the name of the digital interrupt.
func (*BasicDigitalInterrupt) Reconfigure ¶
func (i *BasicDigitalInterrupt) Reconfigure(conf board.DigitalInterruptConfig) error
Reconfigure reconfigures this digital interrupt with a new formula.
type ReconfigurableDigitalInterrupt ¶
type ReconfigurableDigitalInterrupt interface { board.DigitalInterrupt Reconfigure(cfg board.DigitalInterruptConfig) error }
A ReconfigurableDigitalInterrupt is a simple reconfigurable digital interrupt that expects reconfiguration within the same type.
func CreateDigitalInterrupt ¶
func CreateDigitalInterrupt(cfg board.DigitalInterruptConfig) (ReconfigurableDigitalInterrupt, error)
CreateDigitalInterrupt is a factory method for creating a specific DigitalInterrupt based on the given config. If no type is specified, a BasicDigitalInterrupt is returned.