Documentation ¶
Overview ¶
Package fake implements a fake motor.
Index ¶
- func NewMotor(ctx context.Context, deps resource.Dependencies, conf resource.Config, ...) (motor.Motor, error)
- 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) 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{}) (motor.Properties, error)
- func (m *Motor) Reconfigure(ctx context.Context, deps resource.Dependencies, conf resource.Config) 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) SetRPM(ctx context.Context, rpm 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 ¶
Types ¶
type Config ¶
type Config struct { Pins PinConfig `json:"pins,omitempty"` BoardName string `json:"board,omitempty"` 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 { resource.Named resource.TriviallyCloseable Board string PWM board.GPIOPin PositionReporting bool Encoder fake.Encoder MaxRPM float64 DirFlip bool TicksPerRotation int OpMgr *operation.SingleOperationManager Logger logging.Logger // 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) 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{}) (motor.Properties, error)
Properties returns the status of whether the motor supports certain optional properties.
func (*Motor) Reconfigure ¶ added in v0.2.36
func (m *Motor) Reconfigure(ctx context.Context, deps resource.Dependencies, conf resource.Config) error
Reconfigure atomically reconfigures this motor in place based on the new config.
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.