Documentation
¶
Index ¶
- Variables
- func Clamp[T constraints.Ordered](v, min, max T) T
- func LCDIndexToPixel(idx int) (x, y int)
- func LCDPixelToIndex(x, y int) int
- func Max[T constraints.Ordered](a, b T) T
- func Min[T constraints.Ordered](a, b T) T
- func RunCommand(c CommandInterface)
- func RunTimedCommand(c CommandInterface, intervalTime time.Duration)
- type BeaconButton
- type ColorSensor
- type ColorSensorInterface
- type Command
- func NewCommand(c CommandInterface) *Command
- func NewFuncCommand(f func()) *Command
- func NewIfCommand(runA func() bool, a, b CommandInterface) *Command
- func NewParallel(commands ...CommandInterface) *Command
- func NewParallelRace(commands ...CommandInterface) *Command
- func NewPrintCommand(text string) *Command
- func NewPrintlnCommand(text string) *Command
- func NewSequence(commands ...CommandInterface) *Command
- func NewWaitCommand(time time.Duration) *Command
- func (c *Command) OnlyIf(pred func() bool) *Command
- func (c *Command) RaceWith(cc ...CommandInterface) *Command
- func (c *Command) Repeatedly() *Command
- func (c *Command) Then(cc ...CommandInterface) *Command
- func (c *Command) Until(predicate func() bool) *Command
- func (c *Command) WhenDone(f func(bool)) *Command
- func (c *Command) While(cc ...CommandInterface) *Command
- func (c *Command) WithTimeout(dur time.Duration) *Command
- type CommandInterface
- type ConfigNotFoundError
- type DefaultCommand
- type EV3Brick
- type EV3BrickInterface
- type EV3Button
- type EV3Color
- type EV3Note
- type EV3Port
- type GyroSensor
- type GyroSensorInterface
- type InfraredSensor
- type InfraredSensorInterface
- type MainMenu
- type MainMenuInterface
- type Menu
- type MenuConfig
- type MenuPage
- type Motor
- type MotorInterface
- type MotorState
- type MotorStopAction
- type NamedCommand
- type PIDController
- func (p *PIDController) Get(current, setPoint float64) float64
- func (p *PIDController) Kd() float64
- func (p *PIDController) Ki() float64
- func (p *PIDController) Kp() float64
- func (p *PIDController) PID() (float64, float64, float64)
- func (p *PIDController) SetKd(kd float64)
- func (p *PIDController) SetKi(ki float64)
- func (p *PIDController) SetKp(kp float64)
- func (p *PIDController) SetPID(kp, ki, kd float64)
- type TouchSensor
- type TouchSensorInterface
- type UltrasonicSensor
- type UltrasonicSensorInterface
Constants ¶
This section is empty.
Variables ¶
var ConfigManager *configManager = &configManager{registeredConfigs: map[string]MenuConfig{}}
Functions ¶
func Clamp ¶
func Clamp[T constraints.Ordered](v, min, max T) T
func LCDIndexToPixel ¶
func LCDPixelToIndex ¶
func Max ¶
func Max[T constraints.Ordered](a, b T) T
func Min ¶
func Min[T constraints.Ordered](a, b T) T
func RunCommand ¶
func RunCommand(c CommandInterface)
RunCommand will run a command in a blocking fashion.
func RunTimedCommand ¶
func RunTimedCommand(c CommandInterface, intervalTime time.Duration)
RunTimedCommand will run a command in a blocking fashion with a target interval time.
Types ¶
type BeaconButton ¶
type BeaconButton int
const ( LeftUp BeaconButton = iota LeftDown RightUp RightDown Beacon )
type ColorSensor ¶
type ColorSensor struct {
ColorSensorInterface
}
func NewColorSensorBase ¶
func NewColorSensorBase(c ColorSensorInterface) *ColorSensor
type ColorSensorInterface ¶
type Command ¶
type Command struct {
CommandInterface
}
Command provides decorator functions on commands.
func NewCommand ¶
func NewCommand(c CommandInterface) *Command
func NewIfCommand ¶
func NewIfCommand(runA func() bool, a, b CommandInterface) *Command
NewIfCommand returns a command that will run a command depending on a predicate. If the predicate returns true when the command is initialised, then command a will be run.
func NewParallel ¶
func NewParallel(commands ...CommandInterface) *Command
NewParallel will run several commands at the same time waiting for all commands to complete.
func NewParallelRace ¶
func NewParallelRace(commands ...CommandInterface) *Command
NewParallelRace will run several commands at the same time. It will finish when the first command finishes and will interrupt the rest.
func NewPrintCommand ¶
NewPrintCommand prints out some text.
func NewPrintlnCommand ¶
func NewSequence ¶
func NewSequence(commands ...CommandInterface) *Command
NewSequence will run several commands one after another.
func NewWaitCommand ¶
NewWaitCommand waits for a time duration.
func (*Command) RaceWith ¶
func (c *Command) RaceWith(cc ...CommandInterface) *Command
func (*Command) Repeatedly ¶
Repeatedly will run a command forever reinitialising it if it ends.
func (*Command) Then ¶
func (c *Command) Then(cc ...CommandInterface) *Command
func (*Command) While ¶
func (c *Command) While(cc ...CommandInterface) *Command
type CommandInterface ¶
CommandInterface defines the interface for all commands to implement.
type ConfigNotFoundError ¶
type ConfigNotFoundError struct {
// contains filtered or unexported fields
}
func (ConfigNotFoundError) Error ¶
func (c ConfigNotFoundError) Error() string
type DefaultCommand ¶
type DefaultCommand struct{}
DefaultCommand provides a default implementation for all commands.
func (*DefaultCommand) End ¶
func (b *DefaultCommand) End(_ bool)
func (*DefaultCommand) Init ¶
func (b *DefaultCommand) Init()
func (*DefaultCommand) IsDone ¶
func (b *DefaultCommand) IsDone() bool
func (*DefaultCommand) Run ¶
func (b *DefaultCommand) Run()
type EV3Brick ¶
type EV3Brick struct {
EV3BrickInterface
}
func NewEV3BrickBase ¶
func NewEV3BrickBase(e EV3BrickInterface) *EV3Brick
type EV3BrickInterface ¶
type EV3BrickInterface interface {
IsButtonPressed(button EV3Button) bool
IsButtonDown(button EV3Button) bool
IsButtonReleased(button EV3Button) bool
IsButtonUp(button EV3Button) bool
ButtonsPressed() []EV3Button
SetLight(color EV3Color)
Beep(frequency, duration float64)
PlayNotes(notes []EV3Note, tempo float64)
SetVolume(volume float64)
ClearScreen()
DrawText(x, y int, text string)
PrintScreen(text ...string)
DrawPixel(x, y int, black bool)
Voltage() float64
Current() float64
}
type GyroSensor ¶
type GyroSensor struct {
GyroSensorInterface
}
func NewGyroSensorBase ¶
func NewGyroSensorBase(g GyroSensorInterface) *GyroSensor
type GyroSensorInterface ¶
type InfraredSensor ¶
type InfraredSensor struct {
InfraredSensorInterface
}
func NewInfraredSensorBase ¶
func NewInfraredSensorBase(i InfraredSensorInterface) *InfraredSensor
type InfraredSensorInterface ¶
type InfraredSensorInterface interface {
Distance() float64
Buttons(channel int) []BeaconButton
}
type MainMenu ¶
type MainMenu struct {
// contains filtered or unexported fields
}
func NewMainMenu ¶
func NewMainMenu(i MainMenuInterface, m *Menu) *MainMenu
type MainMenuInterface ¶
type Menu ¶
type Menu struct {
Pages []*MenuPage
}
func NewCommandMenu ¶
func NewCommandMenu() *Menu
type MenuConfig ¶
type MenuConfig interface {
GetCommandPages() Menu
}
type MenuPage ¶
type MenuPage struct {
Name string
Commands []NamedCommand
// contains filtered or unexported fields
}
type Motor ¶
type Motor struct {
MotorInterface
}
func NewMotorBase ¶
func NewMotorBase(m MotorInterface) *Motor
func (*Motor) RunToAbsPos ¶
func (m *Motor) RunToAbsPos(pos float64, tolerance float64, pid PIDController) *Command
func (*Motor) RunToRelPos ¶
func (m *Motor) RunToRelPos(pos float64, tolerance float64, pid PIDController) *Command
func (*Motor) SetCommand ¶
type MotorInterface ¶
type MotorInterface interface {
CountPerRot() int
State() MotorState
Inverted() bool
SetInverted(inverted bool)
Scale() float64
SetScale(scale float64)
Position() float64
ResetPosition(pos float64)
Speed() float64
Set(power float64)
Stop()
StopAction() MotorStopAction
SetStopAction(s MotorStopAction)
}
type MotorState ¶
type MotorState int
const ( Running MotorState = 1 << iota Ramping Holding Overloaded Stalled )
type MotorStopAction ¶
type MotorStopAction string
const ( Coast MotorStopAction = "coast" Brake MotorStopAction = "brake" Hold MotorStopAction = "hold" )
type NamedCommand ¶
type PIDController ¶
type PIDController struct {
// contains filtered or unexported fields
}
func NewPIDController ¶
func NewPIDController(kp, ki, kd float64) *PIDController
func (*PIDController) Get ¶
func (p *PIDController) Get(current, setPoint float64) float64
func (*PIDController) Kd ¶
func (p *PIDController) Kd() float64
func (*PIDController) Ki ¶
func (p *PIDController) Ki() float64
func (*PIDController) Kp ¶
func (p *PIDController) Kp() float64
func (*PIDController) SetKd ¶
func (p *PIDController) SetKd(kd float64)
func (*PIDController) SetKi ¶
func (p *PIDController) SetKi(ki float64)
func (*PIDController) SetKp ¶
func (p *PIDController) SetKp(kp float64)
func (*PIDController) SetPID ¶
func (p *PIDController) SetPID(kp, ki, kd float64)
type TouchSensor ¶
type TouchSensor struct {
TouchSensorInterface
}
func NewTouchSensorBase ¶
func NewTouchSensorBase(t TouchSensorInterface) *TouchSensor
type TouchSensorInterface ¶
type TouchSensorInterface interface {
IsPressed() bool
}
type UltrasonicSensor ¶
type UltrasonicSensor struct {
UltrasonicSensorInterface
}
func NewUltrasonicSensorBase ¶
func NewUltrasonicSensorBase(u UltrasonicSensorInterface) *UltrasonicSensor