Documentation ¶
Overview ¶
Package spark provides the Gobot adaptor for the Spark Core.
Installing:
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/spark
Example:
package main import ( "time" "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/platforms/gpio" "github.com/hybridgroup/gobot/platforms/spark" ) func main() { gbot := gobot.NewGobot() sparkCore := spark.NewSparkCoreAdaptor("spark", "device_id", "access_token") led := gpio.NewLedDriver(sparkCore, "led", "D7") work := func() { gobot.Every(1*time.Second, func() { led.Toggle() }) } robot := gobot.NewRobot("spark", []gobot.Connection{sparkCore}, []gobot.Device{led}, work, ) gbot.AddRobot(robot) gbot.Start() }
For further information refer to spark readme: https://github.com/hybridgroup/gobot/blob/master/platforms/spark/README.md
Index ¶
- type SparkCoreAdaptor
- func (s *SparkCoreAdaptor) AnalogRead(pin string) (val int, err error)
- func (s *SparkCoreAdaptor) AnalogWrite(pin string, level byte) (err error)
- func (s *SparkCoreAdaptor) Connect() (errs []error)
- func (s *SparkCoreAdaptor) DigitalRead(pin string) (val int, err error)
- func (s *SparkCoreAdaptor) DigitalWrite(pin string, level byte) (err error)
- func (s *SparkCoreAdaptor) Finalize() (errs []error)
- func (s *SparkCoreAdaptor) Name() string
- func (s *SparkCoreAdaptor) PwmWrite(pin string, level byte) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SparkCoreAdaptor ¶
type SparkCoreAdaptor struct { DeviceID string AccessToken string APIServer string // contains filtered or unexported fields }
func NewSparkCoreAdaptor ¶
func NewSparkCoreAdaptor(name string, deviceID string, accessToken string) *SparkCoreAdaptor
NewSparkCoreAdaptor creates new spark core adaptor with deviceId and accessToken using api.spark.io server as default
func (*SparkCoreAdaptor) AnalogRead ¶
func (s *SparkCoreAdaptor) AnalogRead(pin string) (val int, err error)
AnalogRead reads analog ping value using spark cloud api
func (*SparkCoreAdaptor) AnalogWrite ¶
func (s *SparkCoreAdaptor) AnalogWrite(pin string, level byte) (err error)
AnalogWrite writes analog pin with specified level using spark cloud api
func (*SparkCoreAdaptor) Connect ¶
func (s *SparkCoreAdaptor) Connect() (errs []error)
Connect returns true if connection to spark core is succesfull
func (*SparkCoreAdaptor) DigitalRead ¶
func (s *SparkCoreAdaptor) DigitalRead(pin string) (val int, err error)
DigitalRead reads from digital pin using spark cloud api
func (*SparkCoreAdaptor) DigitalWrite ¶
func (s *SparkCoreAdaptor) DigitalWrite(pin string, level byte) (err error)
DigitalWrite writes to a digital pin using spark cloud api
func (*SparkCoreAdaptor) Finalize ¶
func (s *SparkCoreAdaptor) Finalize() (errs []error)
Finalize returns true if connection to spark core is finalized successfully
func (*SparkCoreAdaptor) Name ¶
func (s *SparkCoreAdaptor) Name() string