gopigo

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LED

type LED struct {
	// contains filtered or unexported fields
}

LED is the led service object

func NewLED

func NewLED(driver *gopigo3.Driver, options ...LEDOption) *LED

NewLED creates a new gopigo LED object for manipulating the bots lights

Example (Debug)
package main

import (
	"time"

	"github.com/open-farms/bot/pkg/gopigo"
	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/dexter/gopigo3"
	"gobot.io/x/gobot/platforms/raspi"
)

func main() {
	rpi := raspi.NewAdaptor()
	driver := gopigo3.NewDriver(rpi)
	done := make(chan bool, 1)

	gobot.After(5*time.Second, func() {
		done <- true
	})

	work := func() {
		led := gopigo.NewLED(driver,
			gopigo.WithDebug(),
		)
		err := led.Blink(1*time.Second, done)
		if err != nil {
			panic(err)
		}
	}

	robot := gobot.NewRobot("gopigo",
		[]gobot.Connection{rpi},
		[]gobot.Device{driver},
		work,
	)

	robot.Start()
}
Output:

func (*LED) ApplyColor

func (l *LED) ApplyColor(c color.RGBA, light gopigo3.Led) error

ApplyColor sets the color of the gopigo's LED

func (l *LED) Blink(frequency time.Duration, done chan bool) error

Blink the lights on the robot at a specified interval

func (*LED) Wink

func (l *LED) Wink(frequency time.Duration, light gopigo3.Led) error

Wink a light on the robot at a specified interval

type LEDOption

type LEDOption func(*LED)

func WithDebug

func WithDebug() LEDOption

WithDebug enables debug logging for the led driver

type Motor

type Motor struct {
	// contains filtered or unexported fields
}

func NewMotor

func NewMotor(driver *gopigo3.Driver, options ...MotorOption) *Motor

NewMotor creates a new gopigo Motor

func (*Motor) Backwards

func (m *Motor) Backwards(speed uint) error

Backwards moves backwards at a default speed

func (*Motor) Forward

func (m *Motor) Forward(speed int) error

Forward moves the robot forwards

func (*Motor) Left

func (m *Motor) Left(speed int) error

Left moves the robot to the left

func (*Motor) Right

func (m *Motor) Right(speed int) error

Right moves the robot to the right

func (*Motor) Stop

func (m *Motor) Stop() error

Stop sets the motor dps to zero

func (*Motor) WithDebug

func (m *Motor) WithDebug() MotorOption

type MotorOption

type MotorOption func(*Motor)

type Robot

type Robot struct {
	Driver  *gopigo3.Driver
	Adaptor *raspi.Adaptor

	LED   *LED
	Motor *Motor
}

func NewRobot

func NewRobot() *Robot

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL