Documentation ¶
Overview ¶
Package fake implements a fake motor.
Index ¶
- type Config
- type Motor
- func (m *Motor) Direction() int
- func (m *Motor) GoFor(ctx context.Context, rpm, revolutions float64, extra map[string]interface{}) error
- func (m *Motor) GoTillStop(ctx context.Context, rpm float64, stopFunc func(ctx context.Context) bool) error
- func (m *Motor) GoTo(ctx context.Context, rpm, pos float64, extra map[string]interface{}) error
- func (m *Motor) IsMoving(ctx context.Context) (bool, error)
- func (m *Motor) IsPowered(ctx context.Context, extra map[string]interface{}) (bool, float64, error)
- func (m *Motor) Position(ctx context.Context, extra map[string]interface{}) (float64, error)
- func (m *Motor) PowerPct() float64
- func (m *Motor) Properties(ctx context.Context, extra map[string]interface{}) (map[motor.Feature]bool, error)
- func (m *Motor) ResetZeroPosition(ctx context.Context, offset float64, extra map[string]interface{}) error
- func (m *Motor) SetPower(ctx context.Context, powerPct float64, extra map[string]interface{}) error
- func (m *Motor) Stop(ctx context.Context, extra map[string]interface{}) error
- type PinConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Pins PinConfig `json:"pins"` BoardName string `json:"board"` MinPowerPct float64 `json:"min_power_pct,omitempty"` MaxPowerPct float64 `json:"max_power_pct,omitempty"` PWMFreq uint `json:"pwm_freq,omitempty"` Encoder string `json:"encoder,omitempty"` MaxRPM float64 `json:"max_rpm,omitempty"` TicksPerRotation int `json:"ticks_per_rotation,omitempty"` DirectionFlip bool `json:"direction_flip,omitempty"` }
Config describes the configuration of a motor.
type Motor ¶
type Motor struct { Name string Board string PWM board.GPIOPin PositionReporting bool Logger golog.Logger Encoder *fakeencoder.Encoder MaxRPM float64 DirFlip bool TicksPerRotation int generic.Echo // contains filtered or unexported fields }
A Motor allows setting and reading a set power percentage and direction.
func (*Motor) GoFor ¶
func (m *Motor) GoFor(ctx context.Context, rpm, revolutions float64, extra map[string]interface{}) error
GoFor sets the given direction and an arbitrary power percentage. If rpm is 0, the motor should immediately move to the final position.
func (*Motor) GoTillStop ¶
func (m *Motor) GoTillStop(ctx context.Context, rpm float64, stopFunc func(ctx context.Context) bool) error
GoTillStop always returns an error.
func (*Motor) IsPowered ¶
IsPowered returns if the motor is pretending to be on or not, and its power level.
func (*Motor) Properties ¶
func (m *Motor) Properties(ctx context.Context, extra map[string]interface{}) (map[motor.Feature]bool, error)
Properties returns the status of whether the motor supports certain optional features.
func (*Motor) ResetZeroPosition ¶
func (m *Motor) ResetZeroPosition(ctx context.Context, offset float64, extra map[string]interface{}) error
ResetZeroPosition resets the zero position.
Click to show internal directories.
Click to hide internal directories.