Documentation ¶
Index ¶
- Variables
- func Close() error
- func Stop() error
- type GobotSimulator
- func (sim *GobotSimulator) AddKeyPressPWAction(key rune, pin string, action int) (*gobot_sim.PinWriteAction, error)
- func (sim *GobotSimulator) Run() error
- func (sim *GobotSimulator) SetPinToGPIOMap(pinToGPIO *PinToGPIOMap)
- func (sim *GobotSimulator) WatchPin(pin string, handler gobot_sim.PinChangedFunc) (*gobot_sim.PinWatcher, error)
- type PinToGPIOMap
- type RaspiAdaptor
- type VAdaptor
- func (r *VAdaptor) Connect() (err error)
- func (r *VAdaptor) DigitalPin(pin string, dir string) (sysfsPin sysfs.DigitalPinner, err error)
- func (r *VAdaptor) DigitalRead(pin string) (val int, err error)
- func (r *VAdaptor) DigitalWrite(pin string, val byte) (err error)
- func (r *VAdaptor) Finalize() (err error)
- func (r *VAdaptor) GetConnection(address int, bus int) (connection i2c.Connection, err error)
- func (r *VAdaptor) GetDefaultBus() int
- func (r *VAdaptor) GetSpiConnection(busNum, chipNum, mode, bits int, maxSpeed int64) (connection spi.Connection, err error)
- func (r *VAdaptor) GetSpiDefaultBits() int
- func (r *VAdaptor) GetSpiDefaultBus() int
- func (r *VAdaptor) GetSpiDefaultChip() int
- func (r *VAdaptor) GetSpiDefaultMaxSpeed() int64
- func (r *VAdaptor) GetSpiDefaultMode() int
- func (r *VAdaptor) Name() string
- func (r *VAdaptor) PWMPin(pin string) (raspiPWMPin sysfs.PWMPinner, err error)
- func (r *VAdaptor) PwmWrite(pin string, val byte) (err error)
- func (r *VAdaptor) ServoWrite(pin string, angle byte) (err error)
- func (r *VAdaptor) SetName(n string)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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
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 ¶
Connect starts connection with board and creates digitalPins and pwmPins adaptor maps
func (*VAdaptor) DigitalPin ¶
DigitalPin returns matched digitalPin for specified values
func (*VAdaptor) DigitalRead ¶
DigitalRead reads digital value from pin
func (*VAdaptor) DigitalWrite ¶
DigitalWrite writes digital value to specified pin
func (*VAdaptor) GetConnection ¶
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 ¶
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 ¶
GetSpiDefaultBits returns the default spi number of bits for this platform.
func (*VAdaptor) GetSpiDefaultBus ¶
GetSpiDefaultBus returns the default spi bus for this platform.
func (*VAdaptor) GetSpiDefaultChip ¶
GetSpiDefaultChip returns the default spi chip for this platform.
func (*VAdaptor) GetSpiDefaultMaxSpeed ¶
GetSpiDefaultMaxSpeed returns the default spi bus for this platform.
func (*VAdaptor) GetSpiDefaultMode ¶
GetSpiDefaultMode returns the default spi mode for this platform.
func (*VAdaptor) PWMPin ¶
PWMPin returns a raspi.PWMPin which provides the sysfs.PWMPinner interface
func (*VAdaptor) ServoWrite ¶
ServoWrite writes a servo signal to the specified pin