spark

package
Version: v0.0.0-...-86e32b9 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2014 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

README

Spark

This package 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()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SparkCoreAdaptor

type SparkCoreAdaptor struct {
	gobot.Adaptor
	DeviceID    string
	AccessToken string
}

func NewSparkCoreAdaptor

func NewSparkCoreAdaptor(name string, deviceID string, accessToken string) *SparkCoreAdaptor

func (*SparkCoreAdaptor) AnalogRead

func (s *SparkCoreAdaptor) AnalogRead(pin string) float64

func (*SparkCoreAdaptor) AnalogWrite

func (s *SparkCoreAdaptor) AnalogWrite(pin string, level byte)

func (*SparkCoreAdaptor) Connect

func (s *SparkCoreAdaptor) Connect() bool

func (*SparkCoreAdaptor) DigitalRead

func (s *SparkCoreAdaptor) DigitalRead(pin string) int

func (*SparkCoreAdaptor) DigitalWrite

func (s *SparkCoreAdaptor) DigitalWrite(pin string, level byte)

func (*SparkCoreAdaptor) Finalize

func (s *SparkCoreAdaptor) Finalize() bool

func (*SparkCoreAdaptor) PwmWrite

func (s *SparkCoreAdaptor) PwmWrite(pin string, level byte)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL