• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang gobot.NewEventer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中gobot/io/x/gobot.NewEventer函数的典型用法代码示例。如果您正苦于以下问题:Golang NewEventer函数的具体用法?Golang NewEventer怎么用?Golang NewEventer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewEventer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: NewWiichuckDriver

// NewWiichuckDriver creates a WiichuckDriver with specified i2c interface.
//
// It adds the following events:
//	"z"- Gets triggered every interval amount of time if the z button is pressed
//	"c" - Gets triggered every interval amount of time if the c button is pressed
//	"joystick" - Gets triggered every "interval" amount of time if a joystick event occurred, you can access values x, y
//	"error" - Gets triggered whenever the WiichuckDriver encounters an error
func NewWiichuckDriver(a I2c, v ...time.Duration) *WiichuckDriver {
	w := &WiichuckDriver{
		name:       "Wiichuck",
		connection: a,
		interval:   10 * time.Millisecond,
		pauseTime:  1 * time.Millisecond,
		Eventer:    gobot.NewEventer(),
		joystick: map[string]float64{
			"sy_origin": -1,
			"sx_origin": -1,
		},
		data: map[string]float64{
			"sx": 0,
			"sy": 0,
			"z":  0,
			"c":  0,
		},
	}

	if len(v) > 0 {
		w.interval = v[0]
	}

	w.AddEvent(Z)
	w.AddEvent(C)
	w.AddEvent(Joystick)
	w.AddEvent(Error)
	return w
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:36,代码来源:wiichuck_driver.go


示例2: NewAnalogSensorDriver

// NewAnalogSensorDriver returns a new AnalogSensorDriver with a polling interval of
// 10 Milliseconds given an AnalogReader and pin.
//
// Optionally accepts:
// 	time.Duration: Interval at which the AnalogSensor is polled for new information
//
// Adds the following API Commands:
// 	"Read" - See AnalogSensor.Read
func NewAnalogSensorDriver(a AnalogReader, pin string, v ...time.Duration) *AnalogSensorDriver {
	d := &AnalogSensorDriver{
		name:       "AnalogSensor",
		connection: a,
		pin:        pin,
		Eventer:    gobot.NewEventer(),
		Commander:  gobot.NewCommander(),
		interval:   10 * time.Millisecond,
		halt:       make(chan bool),
	}

	if len(v) > 0 {
		d.interval = v[0]
	}

	d.AddEvent(Data)
	d.AddEvent(Error)

	d.AddCommand("Read", func(params map[string]interface{}) interface{} {
		val, err := d.Read()
		return map[string]interface{}{"val": val, "err": err}
	})

	return d
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:33,代码来源:analog_sensor_driver.go


示例3: NewDriver

// NewDriver creates a new pebble driver
// Adds following events:
//		button - Sent when a pebble button is pressed
//		accel - Pebble watch acceleromenter data
//		tab - When a pebble watch tap event is detected
// And the following API commands:
//		"publish_event"
//		"send_notification"
//		"pending_message"
func NewDriver(adaptor *Adaptor) *Driver {
	p := &Driver{
		name:       "Pebble",
		connection: adaptor,
		Messages:   []string{},
		Eventer:    gobot.NewEventer(),
		Commander:  gobot.NewCommander(),
	}

	p.AddEvent("button")
	p.AddEvent("accel")
	p.AddEvent("tap")

	p.AddCommand("publish_event", func(params map[string]interface{}) interface{} {
		p.PublishEvent(params["name"].(string), params["data"].(string))
		return nil
	})

	p.AddCommand("send_notification", func(params map[string]interface{}) interface{} {
		p.SendNotification(params["message"].(string))
		return nil
	})

	p.AddCommand("pending_message", func(params map[string]interface{}) interface{} {
		return p.PendingMessage()
	})

	return p
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:38,代码来源:pebble_driver.go


示例4: New

// New returns a new Client
func New() *Client {
	c := &Client{
		ProtocolVersion: "",
		FirmwareName:    "",
		connection:      nil,
		pins:            []Pin{},
		analogPins:      []int{},
		connected:       false,
		Eventer:         gobot.NewEventer(),
	}

	for _, s := range []string{
		"FirmwareQuery",
		"CapabilityQuery",
		"AnalogMappingQuery",
		"ProtocolVersion",
		"I2cReply",
		"StringData",
		"Error",
	} {
		c.AddEvent(s)
	}

	return c
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:26,代码来源:client.go


示例5: NewDriver

// NewDriver creates a Parrot Minidrone Driver
func NewDriver(a *ble.ClientAdaptor) *Driver {
	n := &Driver{
		name:       "Minidrone",
		connection: a,
		Pcmd: Pcmd{
			Flag:  0,
			Roll:  0,
			Pitch: 0,
			Yaw:   0,
			Gaz:   0,
			Psi:   0,
		},
		Eventer: gobot.NewEventer(),
	}

	n.AddEvent(Battery)
	n.AddEvent(FlightStatus)

	n.AddEvent(Takeoff)
	n.AddEvent(Flying)
	n.AddEvent(Hovering)
	n.AddEvent(Landing)
	n.AddEvent(Landed)
	n.AddEvent(Emergency)
	n.AddEvent(Rolling)

	return n
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:29,代码来源:minidrone_driver.go


示例6: NewMCP23017Driver

// NewMCP23017Driver creates a new driver with specified i2c interface.
func NewMCP23017Driver(a I2c, conf MCP23017Config, deviceAddress int, v ...time.Duration) *MCP23017Driver {
	m := &MCP23017Driver{
		name:            "MCP23017",
		connection:      a,
		conf:            conf,
		mcp23017Address: deviceAddress,
		Commander:       gobot.NewCommander(),
		Eventer:         gobot.NewEventer(),
	}

	m.AddCommand("WriteGPIO", func(params map[string]interface{}) interface{} {
		pin := params["pin"].(uint8)
		val := params["val"].(uint8)
		port := params["port"].(string)
		err := m.WriteGPIO(pin, val, port)
		return map[string]interface{}{"err": err}
	})

	m.AddCommand("ReadGPIO", func(params map[string]interface{}) interface{} {
		pin := params["pin"].(uint8)
		port := params["port"].(string)
		val, err := m.ReadGPIO(pin, port)
		return map[string]interface{}{"val": val, "err": err}
	})

	return m
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:28,代码来源:mcp23017_driver.go


示例7: NewCameraDriver

// NewCameraDriver creates a new driver with specified source.
// It also creates a start function to either set camera as a File or Camera capture.
func NewCameraDriver(source interface{}, v ...time.Duration) *CameraDriver {
	c := &CameraDriver{
		name:     "Camera",
		Eventer:  gobot.NewEventer(),
		Source:   source,
		interval: 10 * time.Millisecond,
		start: func(c *CameraDriver) (err error) {
			switch v := c.Source.(type) {
			case string:
				c.camera = cv.NewFileCapture(v)
			case int:
				c.camera = cv.NewCameraCapture(v)
			default:
				return errors.New("Unknown camera source")
			}
			return
		},
	}

	if len(v) > 0 {
		c.interval = v[0]
	}

	c.AddEvent(Frame)

	return c
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:29,代码来源:camera_driver.go


示例8: NewDriver

// NewDriver creates an Driver for the ARDrone.
//
// It add the following events:
//     'flying' - Sent when the device has taken off.
func NewDriver(connection *Adaptor) *Driver {
	d := &Driver{
		name:       "ARDrone",
		connection: connection,
		Eventer:    gobot.NewEventer(),
	}
	d.AddEvent(Flying)
	return d
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:13,代码来源:ardrone_driver.go


示例9: NewGenericAccessDriver

// NewGenericAccessDriver creates a GenericAccessDriver
func NewGenericAccessDriver(a *ClientAdaptor) *GenericAccessDriver {
	n := &GenericAccessDriver{
		name:       "GenericAccess",
		connection: a,
		Eventer:    gobot.NewEventer(),
	}

	return n
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:10,代码来源:generic_access_driver.go


示例10: NewDeviceInformationDriver

// NewDeviceInformationDriver creates a DeviceInformationDriver
func NewDeviceInformationDriver(a *ClientAdaptor) *DeviceInformationDriver {
	n := &DeviceInformationDriver{
		name:       "DeviceInformation",
		connection: a,
		Eventer:    gobot.NewEventer(),
	}

	return n
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:10,代码来源:device_information_driver.go


示例11: NewBatteryDriver

// NewBatteryDriver creates a BatteryDriver
func NewBatteryDriver(a *ClientAdaptor) *BatteryDriver {
	n := &BatteryDriver{
		name:       "Battery",
		connection: a,
		Eventer:    gobot.NewEventer(),
	}

	return n
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:10,代码来源:battery_driver.go


示例12: NewAdaptor

// NewAdaptor creates new Photon adaptor with deviceId and accessToken
// using api.particle.io server as default
func NewAdaptor(deviceID string, accessToken string) *Adaptor {
	return &Adaptor{
		name:        "Particle",
		DeviceID:    deviceID,
		AccessToken: accessToken,
		servoPins:   make(map[string]bool),
		APIServer:   "https://api.particle.io",
		Eventer:     gobot.NewEventer(),
	}
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:12,代码来源:adaptor.go


示例13: NewDriver

// NewDriver creates a Driver for a Sphero Ollie
func NewDriver(a *ble.ClientAdaptor) *Driver {
	n := &Driver{
		name:          "Ollie",
		connection:    a,
		Eventer:       gobot.NewEventer(),
		packetChannel: make(chan *packet, 1024),
	}

	return n
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:11,代码来源:ollie_driver.go


示例14: NewDriver

// NewDriver returns a new audio Driver. It accepts:
//
// *Adaptor: The audio adaptor to use for the driver
//  string: The filename of the audio to start playing
//
func NewDriver(a *Adaptor, filename string) *Driver {
	return &Driver{
		name:       "Audio",
		connection: a,
		interval:   500 * time.Millisecond,
		filename:   filename,
		halt:       make(chan bool, 0),
		Eventer:    gobot.NewEventer(),
		Commander:  gobot.NewCommander(),
	}
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:16,代码来源:audio_driver.go


示例15: NewDriver

// NewDriver creates a new leap motion driver
//
// Adds the following events:
//		"message" - Gets triggered when receiving a message from leap motion
//		"hand" - Gets triggered per-message when leap motion detects a hand
//		"gesture" - Gets triggered per-message when leap motion detects a hand
func NewDriver(a *Adaptor) *Driver {
	l := &Driver{
		name:       "LeapMotion",
		connection: a,
		Eventer:    gobot.NewEventer(),
	}

	l.AddEvent(MessageEvent)
	l.AddEvent(HandEvent)
	l.AddEvent(GestureEvent)
	return l
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:18,代码来源:leap_motion_driver.go


示例16: newMockFirmataBoard

func newMockFirmataBoard() *mockFirmataBoard {
	m := &mockFirmataBoard{
		Eventer:         gobot.NewEventer(),
		disconnectError: nil,
		pins:            make([]client.Pin, 100),
	}

	m.pins[1].Value = 1
	m.pins[15].Value = 133

	m.AddEvent("I2cReply")
	return m
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:13,代码来源:firmata_adaptor_test.go


示例17: NewMPL115A2Driver

// NewMPL115A2Driver creates a new driver with specified i2c interface
func NewMPL115A2Driver(a I2c, v ...time.Duration) *MPL115A2Driver {
	m := &MPL115A2Driver{
		name:       "MPL115A2",
		connection: a,
		Eventer:    gobot.NewEventer(),
		interval:   10 * time.Millisecond,
	}

	if len(v) > 0 {
		m.interval = v[0]
	}
	m.AddEvent(Error)
	return m
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:15,代码来源:mpl115a2_driver.go


示例18: NewPingDriver

func NewPingDriver(adaptor *loopbackAdaptor, pin string) *pingDriver {
	t := &pingDriver{
		name:       "Ping",
		connection: adaptor,
		pin:        pin,
		Eventer:    gobot.NewEventer(),
		Commander:  gobot.NewCommander(),
	}

	t.AddEvent("ping")

	t.AddCommand("ping", func(params map[string]interface{}) interface{} {
		return t.Ping()
	})

	return t
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:17,代码来源:batty.go


示例19: NewDriver

// NewDriver creates a Neurosky Driver
// and adds the following events:
//
//   extended - user's current extended level
//   signal - shows signal strength
//   attention - user's current attention level
//   meditation - user's current meditation level
//   blink - user's current blink level
//   wave - shows wave data
//   eeg - showing eeg data
func NewDriver(a *Adaptor) *Driver {
	n := &Driver{
		name:       "Neurosky",
		connection: a,
		Eventer:    gobot.NewEventer(),
	}

	n.AddEvent(Extended)
	n.AddEvent(Signal)
	n.AddEvent(Attention)
	n.AddEvent(Meditation)
	n.AddEvent(Blink)
	n.AddEvent(Wave)
	n.AddEvent(EEG)
	n.AddEvent(Error)

	return n
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:28,代码来源:neurosky_driver.go


示例20: NewGroveTemperatureSensorDriver

// NewGroveTemperatureSensorDriver returns a new GroveTemperatureSensorDriver with a polling interval of
// 10 Milliseconds given an AnalogReader and pin.
//
// Optionally accepts:
// 	time.Duration: Interval at which the TemperatureSensor is polled for new information
//
// Adds the following API Commands:
// 	"Read" - See AnalogSensor.Read
func NewGroveTemperatureSensorDriver(a AnalogReader, pin string, v ...time.Duration) *GroveTemperatureSensorDriver {
	d := &GroveTemperatureSensorDriver{
		connection: a,
		pin:        pin,
		Eventer:    gobot.NewEventer(),
		interval:   10 * time.Millisecond,
		halt:       make(chan bool),
	}

	if len(v) > 0 {
		d.interval = v[0]
	}

	d.AddEvent(Data)
	d.AddEvent(Error)

	return d
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:26,代码来源:grove_temperature_sensor_driver.go



注:本文中的gobot/io/x/gobot.NewEventer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gobot.NewRobot函数代码示例发布时间:2022-05-28
下一篇:
Golang gobot.Every函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap