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) int
- func (s *SparkCoreAdaptor) AnalogWrite(pin string, level byte)
- func (s *SparkCoreAdaptor) Connect() bool
- func (s *SparkCoreAdaptor) DigitalRead(pin string) int
- func (s *SparkCoreAdaptor) DigitalWrite(pin string, level byte)
- func (s *SparkCoreAdaptor) Finalize() bool
- func (s *SparkCoreAdaptor) PwmWrite(pin string, level byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SparkCoreAdaptor ¶
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) int
AnalogRead reads analog ping value using spark cloud api
func (*SparkCoreAdaptor) AnalogWrite ¶
func (s *SparkCoreAdaptor) AnalogWrite(pin string, level byte)
AnalogWrite writes analog pin with specified level using spark cloud api
func (*SparkCoreAdaptor) Connect ¶
func (s *SparkCoreAdaptor) Connect() bool
Connect returns true if connection to spark core is succesfull
func (*SparkCoreAdaptor) DigitalRead ¶
func (s *SparkCoreAdaptor) DigitalRead(pin string) int
DigitalRead reads from digital pin using spark cloud api
func (*SparkCoreAdaptor) DigitalWrite ¶
func (s *SparkCoreAdaptor) DigitalWrite(pin string, level byte)
DigitalWrite writes to a digital pin using spark cloud api
func (*SparkCoreAdaptor) Finalize ¶
func (s *SparkCoreAdaptor) Finalize() bool
Finalize returns true if connection to spark core is finalized successfully
func (*SparkCoreAdaptor) PwmWrite ¶
func (s *SparkCoreAdaptor) PwmWrite(pin string, level byte)
PwmWrite writes in pin using analog write api