raspi_sim

package
v0.0.0-...-f91051b Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RPI3PinGPIOMap = NewPinToGPIOMap("3", map[string]string{

	"3":  "2",
	"5":  "3",
	"7":  "4",
	"8":  "14",
	"10": "15",
	"11": "17",
	"12": "18",
	"13": "27",
	"15": "22",
	"16": "23",
	"18": "24",
	"19": "10",
	"21": "9",
	"22": "25",
	"23": "11",
	"24": "8",
	"26": "7",
	"27": "0",
	"28": "1",
	"29": "5",
	"31": "6",
	"32": "12",
	"33": "13",
	"35": "19",
	"36": "16",
	"37": "26",
	"38": "20",
	"40": "21",
})

RPI3GPIOPinMap is a mapping for the latest 40 pin raspberry revisions

Functions

func Close

func Close() error

func Stop

func Stop() error

Types

type GobotSimulator

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

func NewGobotSimulator

func NewGobotSimulator(adapter RaspiAdaptor) *GobotSimulator

NewGobotSimulator creates a bot that makes your machine behave like a raspberry pi in some ways

func (*GobotSimulator) AddKeyPressPWAction

func (sim *GobotSimulator) AddKeyPressPWAction(key rune, pin string, action int) (*gobot_sim.PinWriteAction, error)

AddKeyPressPWAction writes something to a pin when a key is pressed. It maps a key press to a specific action on a pin, for example to turn it on or simulate a button press and release

func (*GobotSimulator) Run

func (sim *GobotSimulator) Run() error

Run sets up the simulator bot and starts it

func (*GobotSimulator) SetPinToGPIOMap

func (sim *GobotSimulator) SetPinToGPIOMap(pinToGPIO *PinToGPIOMap)

SetPinToGPIOMap sets a pin mapping to gpio numbers for the platform (defaults to RPI3 mapping).

func (*GobotSimulator) WatchPin

func (sim *GobotSimulator) WatchPin(pin string, handler gobot_sim.PinChangedFunc) (*gobot_sim.PinWatcher, error)

WatchPin intercepts writes to a pin and calls a function if the value changed

type PinToGPIOMap

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

GPIOToPinMap maps gpio numbers to pins for a Raspberry revision

func NewPinToGPIOMap

func NewPinToGPIOMap(revision string, mapping map[string]string) *PinToGPIOMap

func (*PinToGPIOMap) Revision

func (m *PinToGPIOMap) Revision() string

func (*PinToGPIOMap) ToGPIO

func (m *PinToGPIOMap) ToGPIO(pin string) (string, error)

type RaspiAdaptor

type RaspiAdaptor interface {
	gpio.DigitalReader
	gpio.DigitalWriter
	gobot.Adaptor
}

type VAdaptor

type VAdaptor struct {
	PiBlasterPeriod uint32
	// contains filtered or unexported fields
}

VAdaptor is the Gobot VAdaptor for the Raspberry Pi

func NewVAdaptor

func NewVAdaptor(pinMap *PinToGPIOMap) *VAdaptor

NewVAdaptor creates a Raspi VAdaptor it is modified to accept a map of pins to gpio numbers, instead of the automatically determined map.

func (*VAdaptor) Connect

func (r *VAdaptor) Connect() (err error)

Connect starts connection with board and creates digitalPins and pwmPins adaptor maps

func (*VAdaptor) DigitalPin

func (r *VAdaptor) DigitalPin(pin string, dir string) (sysfsPin sysfs.DigitalPinner, err error)

DigitalPin returns matched digitalPin for specified values

func (*VAdaptor) DigitalRead

func (r *VAdaptor) DigitalRead(pin string) (val int, err error)

DigitalRead reads digital value from pin

func (*VAdaptor) DigitalWrite

func (r *VAdaptor) DigitalWrite(pin string, val byte) (err error)

DigitalWrite writes digital value to specified pin

func (*VAdaptor) Finalize

func (r *VAdaptor) Finalize() (err error)

Finalize closes connection to board and pins

func (*VAdaptor) GetConnection

func (r *VAdaptor) GetConnection(address int, bus int) (connection i2c.Connection, err error)

GetConnection returns an i2c connection to a device on a specified bus. Valid bus number is [0..1] which corresponds to /dev/i2c-0 through /dev/i2c-1.

func (*VAdaptor) GetDefaultBus

func (r *VAdaptor) GetDefaultBus() int

GetDefaultBus returns the default i2c bus for this platform

func (*VAdaptor) GetSpiConnection

func (r *VAdaptor) GetSpiConnection(busNum, chipNum, mode, bits int, maxSpeed int64) (connection spi.Connection, err error)

GetSpiConnection returns an spi connection to a device on a specified bus. Valid bus number is [0..1] which corresponds to /dev/spidev0.0 through /dev/spidev0.1.

func (*VAdaptor) GetSpiDefaultBits

func (r *VAdaptor) GetSpiDefaultBits() int

GetSpiDefaultBits returns the default spi number of bits for this platform.

func (*VAdaptor) GetSpiDefaultBus

func (r *VAdaptor) GetSpiDefaultBus() int

GetSpiDefaultBus returns the default spi bus for this platform.

func (*VAdaptor) GetSpiDefaultChip

func (r *VAdaptor) GetSpiDefaultChip() int

GetSpiDefaultChip returns the default spi chip for this platform.

func (*VAdaptor) GetSpiDefaultMaxSpeed

func (r *VAdaptor) GetSpiDefaultMaxSpeed() int64

GetSpiDefaultMaxSpeed returns the default spi bus for this platform.

func (*VAdaptor) GetSpiDefaultMode

func (r *VAdaptor) GetSpiDefaultMode() int

GetSpiDefaultMode returns the default spi mode for this platform.

func (*VAdaptor) Name

func (r *VAdaptor) Name() string

Name returns the VAdaptor's name

func (*VAdaptor) PWMPin

func (r *VAdaptor) PWMPin(pin string) (raspiPWMPin sysfs.PWMPinner, err error)

PWMPin returns a raspi.PWMPin which provides the sysfs.PWMPinner interface

func (*VAdaptor) PwmWrite

func (r *VAdaptor) PwmWrite(pin string, val byte) (err error)

PwmWrite writes a PWM signal to the specified pin

func (*VAdaptor) ServoWrite

func (r *VAdaptor) ServoWrite(pin string, angle byte) (err error)

ServoWrite writes a servo signal to the specified pin

func (*VAdaptor) SetName

func (r *VAdaptor) SetName(n string)

SetName sets the VAdaptor's name

Jump to

Keyboard shortcuts

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