Documentation ¶
Overview ¶
Package particle provides the Gobot adaptor for the Particle Photon and Electron.
Installing:
go get gobot.io/x/gobot && go install gobot.io/x/gobot/platforms/particle
Example:
package main import ( "time" "gobot.io/x/gobot" "gobot.io/x/gobot/drivers/gpio" "gobot.io/x/gobot/platforms/particle" ) func main() { core := paticle.NewAdaptor("device_id", "access_token") led := gpio.NewLedDriver(core, "D7") work := func() { gobot.Every(1*time.Second, func() { led.Toggle() }) } robot := gobot.NewRobot("particle", []gobot.Connection{core}, []gobot.Device{led}, work, ) robot.Start() }
For further information refer to Particle readme: https://gobot.io/x/gobot/blob/master/platforms/particle/README.md
Index ¶
- type Adaptor
- func (s *Adaptor) AnalogRead(pin string) (val int, err error)
- func (s *Adaptor) AnalogWrite(pin string, level byte) (err error)
- func (s *Adaptor) Connect() (err error)
- func (s *Adaptor) DigitalRead(pin string) (val int, err error)
- func (s *Adaptor) DigitalWrite(pin string, level byte) (err error)
- func (s *Adaptor) EventStream(source string, name string) (event *gobot.Event, err error)
- func (s *Adaptor) Finalize() (err error)
- func (s *Adaptor) Function(name string, args string) (val int, err error)
- func (s *Adaptor) Name() string
- func (s *Adaptor) PwmWrite(pin string, level byte) (err error)
- func (s *Adaptor) SetName(n string)
- func (s *Adaptor) Variable(name string) (result string, err error)
- type Event
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adaptor ¶
type Adaptor struct { DeviceID string AccessToken string APIServer string gobot.Eventer // contains filtered or unexported fields }
Adaptor is the Gobot Adaptor for Particle
func NewAdaptor ¶
NewAdaptor creates new Photon adaptor with deviceId and accessToken using api.particle.io server as default
func (*Adaptor) AnalogRead ¶
AnalogRead reads analog ping value using Particle cloud api
func (*Adaptor) AnalogWrite ¶
AnalogWrite writes analog pin with specified level using Particle cloud api
func (*Adaptor) Connect ¶
Connect returns true if connection to Particle Photon or Electron is successful
func (*Adaptor) DigitalRead ¶
DigitalRead reads from digital pin using Particle cloud api
func (*Adaptor) DigitalWrite ¶
DigitalWrite writes to a digital pin using Particle cloud api
func (*Adaptor) EventStream ¶
EventStream returns a gobot.Event based on the following params:
* source - "all"/"devices"/"device" (More info at: http://docs.particle.io/api/#reading-data-from-a-core-events) * name - Event name to subscribe for, leave blank to subscribe to all events.
A new event is emitted as a particle.Event struct
func (*Adaptor) Finalize ¶
Finalize returns true if connection to Particle Photon or Electron is finalized successfully
func (*Adaptor) Function ¶
Function executes a core function and returns value from request. Takes a String as the only argument and returns an Int. If function is not defined in core, it will time out