Пример #1
0
func newI2cTestAdaptor(name string) *i2cTestAdaptor {
	return &i2cTestAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"I2cTestAdaptor",
		),
	}
}
Пример #2
0
func newGpioTestAdaptor(name string) *gpioTestAdaptor {
	return &gpioTestAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"/dev/null",
		),
	}
}
Пример #3
0
func NewPebbleAdaptor(name string) *PebbleAdaptor {
	return &PebbleAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"PebbleAdaptor",
		),
	}
}
Пример #4
0
func NewSparkCoreAdaptor(name string, deviceID string, accessToken string) *SparkCoreAdaptor {
	return &SparkCoreAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"SparkCoreAdaptor",
		),
		DeviceID:    deviceID,
		AccessToken: accessToken,
	}
}
Пример #5
0
func NewDigisparkAdaptor(name string) *DigisparkAdaptor {
	return &DigisparkAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"DigisparkAdaptor",
		),
		connect: func(d *DigisparkAdaptor) {
			d.littleWire = LittleWireConnect()
		},
	}
}
Пример #6
0
func NewBeagleboneAdaptor(name string) *BeagleboneAdaptor {
	return &BeagleboneAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"BeagleboneAdaptor",
		),
		connect: func() {
			ensureSlot("cape-bone-iio")
			ensureSlot("am33xx_pwm")
		},
	}
}
Пример #7
0
func NewArdroneAdaptor(name string) *ArdroneAdaptor {
	return &ArdroneAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"ArdroneAdaptor",
		),
		connect: func(a *ArdroneAdaptor) {
			d, err := client.Connect(client.DefaultConfig())
			if err != nil {
				panic(err)
			}
			a.drone = d
		},
	}
}
Пример #8
0
func NewNeuroskyAdaptor(name string, port string) *NeuroskyAdaptor {
	return &NeuroskyAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"NeuroskyAdaptor",
			port,
		),
		connect: func(port string) io.ReadWriteCloser {
			sp, err := serial.OpenPort(&serial.Config{Name: port, Baud: 57600})
			if err != nil {
				panic(err)
			}
			return sp
		},
	}
}
Пример #9
0
func NewJoystickAdaptor(name string) *JoystickAdaptor {
	return &JoystickAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"JoystickAdaptor",
		),
		connect: func(j *JoystickAdaptor) {
			sdl.Init(sdl.INIT_JOYSTICK)
			if sdl.NumJoysticks() > 0 {
				j.joystick = sdl.JoystickOpen(0)
			} else {
				panic("No joystick available")
			}
		},
	}
}
Пример #10
0
func NewFirmataAdaptor(name, port string) *FirmataAdaptor {
	return &FirmataAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"FirmataAdaptor",
			port,
		),
		connect: func(f *FirmataAdaptor) {
			sp, err := serial.OpenPort(&serial.Config{Name: f.Port(), Baud: 57600})
			if err != nil {
				panic(err)
			}
			f.Board = newBoard(sp)
		},
	}
}
Пример #11
0
func NewSpheroAdaptor(name string, port string) *SpheroAdaptor {
	return &SpheroAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"SpheroAdaptor",
			port,
		),
		connect: func(a *SpheroAdaptor) {
			c := &serial.Config{Name: a.Port(), Baud: 115200}
			s, err := serial.OpenPort(c)
			if err != nil {
				panic(err)
			}
			a.sp = s
		},
	}
}
Пример #12
0
func NewLeapMotionAdaptor(name string, port string) *LeapMotionAdaptor {
	return &LeapMotionAdaptor{
		Adaptor: *gobot.NewAdaptor(
			name,
			"LeapMotionAdaptor",
			port,
		),
		connect: func(l *LeapMotionAdaptor) {
			origin := fmt.Sprintf("http://%v", l.Port())
			url := fmt.Sprintf("ws://%v/v3.json", l.Port())
			ws, err := websocket.Dial(url, "", origin)
			if err != nil {
				panic(err)
			}
			l.ws = ws
		},
	}
}