// NewAccelerometerDriver creates a Microbit AccelerometerDriver
188334
func NewAccelerometerDriver(a ble.BLEConnector) *AccelerometerDriver {
	n := &AccelerometerDriver{
		name:       gobot.DefaultName("Microbit Accelerometer"),
		connection: a,
		Eventer:    gobot.NewEventer(),
	}

	n.AddEvent(Accelerometer)

	return n
}
711411
func NewDeviceAccounter(n *Node) *DeviceAccounter {
	numDevices := 0
	var devices []*NodeDeviceResource

	// COMPAT(0.11): Remove in 0.11
	if n.NodeResources != nil {
		numDevices = len(n.NodeResources.Devices)
		devices = n.NodeResources.Devices
	}

	d := &DeviceAccounter{
		Devices: make(map[DeviceIdTuple]*DeviceAccounterInstance, numDevices),
	}

	for _, dev := range devices {
		id := *dev.ID()
		d.Devices[id] = &DeviceAccounterInstance{
			Device:    dev,
			Instances: make(map[string]int, len(dev.Instances)),
		}
		for _, instance := range dev.Instances {
			// Skip unhealthy devices as they aren't allocatable
			if !instance.Healthy {
				continue
			}

			d.Devices[id].Instances[instance.ID] = 0
		}
	}

	return d
}
404397
func NewECU(cfg *ECUConfig) *ECU {
	if cfg == nil {
		defaultCfg := DefaultECUConfig()
		cfg = &defaultCfg
	}
	return &ECU{
		cfg:             cfg,
		shutdown:        make(chan bool),
		shutdownControl: make(chan bool),
		shutdownMonitor: make(chan bool),
	}
}
997290
func NewAdaptor() *Adaptor {
	b := &Adaptor{
		name:         gobot.DefaultName("BeagleboneBlack"),
		digitalPins:  make([]*sysfs.DigitalPin, 120),
		pwmPins:      make(map[string]*sysfs.PWMPin),
		i2cBuses:     make(map[int]i2c.I2cDevice),
		mutex:        &sync.Mutex{},
		pinMap:       bbbPinMap,
		pwmPinMap:    bbbPwmPinMap,
		analogPinMap: bbbAnalogPinMap,
		findPin: func(pinPath string) (string, error) {
			files, err := filepath.Glob(pinPath)
			return files[0], err
		},
	}

	b.setPaths()
	return b
}
398712
func NewOvsdbDriver(bridgeName string, failMode string, vxlanUDPPort int) (*OvsdbDriver, error) {
	// Create a new driver instance
	d := new(OvsdbDriver)
	d.bridgeName = bridgeName
	d.vxlanUDPPort = fmt.Sprintf("%d", vxlanUDPPort)

	// Connect to OVS
	ovs, err := libovsdb.ConnectUnix("")
	if err != nil {
		log.Fatalf("Error connecting to OVS. Err: %v", err)
		return nil, err
	}

	d.ovs = ovs

	// Initialize the cache
	d.cache = make(map[string]map[libovsdb.UUID]libovsdb.Row)
	d.ovs.Register(d)
	initial, _ := d.ovs.MonitorAll(ovsDataBase, "")
	d.populateCache(*initial)

	// Create a bridge after registering for events as we depend on ovsdb cache.
	// Since the same dirver is used as endpoint driver, only create the bridge
	// if it's not already created
	// XXX: revisit if the bridge-name needs to be configurable
	brCreated := false
	for _, row := range d.cache[bridgeTable] {
		if row.Fields["name"] == bridgeName {
			brCreated = true
			break
		}
	}

	if !brCreated {
		err = d.createDeleteBridge(bridgeName, failMode, operCreateBridge)
		if err != nil {
			log.Fatalf("Error creating bridge %s. Err: %v", bridgeName, err)
			return nil, err
		}
	}

	return d, nil
}
792520
func (v *Widget) AddAccelerator(signal string, group *AccelGroup, key uint, mods gdk.ModifierType, flags AccelFlags) {
	csignal := C.CString(signal)
	defer cfree(csignal)
	C.gtk_widget_add_accelerator(v.GWidget, gstring(csignal), group.GAccelGroup, guint(key),
		C.GdkModifierType(mods), C.GtkAccelFlags(flags))
}
1326914
func NewGPIODriver(pinMap PinMap, dpf digitalPinFactory, apf analogPinFactory, ppf pwmPinFactory) GPIODriver {
	return &gpioDriver{
		pinMap: pinMap,
		dpf:    dpf,
		apf:    apf,
		ppf:    ppf,

		initializedPins: map[string]pin{},
	}
}
372453
func (d *driver) NextDeviceInfo(
	ctx types.Context) (*types.NextDeviceInfo, error) {
	return s3fsUtils.NextDeviceInfo, nil
}
511063
func (b *AccelerometerDriver) Start() (err error) {
	// subscribe to accelerometer notifications
	b.adaptor().Subscribe(accelerometerCharacteristic, func(data []byte, e error) {
		a := &RawAccelerometerData{X: 0, Y: 0, Z: 0}

		buf := bytes.NewBuffer(data)
		binary.Read(buf, binary.LittleEndian, &a.X)
		binary.Read(buf, binary.LittleEndian, &a.Y)
		binary.Read(buf, binary.LittleEndian, &a.Z)

		result := &AccelerometerData{
			X: float32(a.X) / 1000.0,
			Y: float32(a.Y) / 1000.0,
			Z: float32(a.Z) / 1000.0}

		b.Publish(b.Event(Accelerometer), result)
	})

	return
}
487448
func NewAdaptor() *Adaptor {
	c := &Adaptor{
		name:  gobot.DefaultName("Tinker Board"),
		mutex: &sync.Mutex{},
	}

	c.setPins()
	return c
}
442108
func RegisterIntegrationDriver(name string, ctor types.NewIntegrationDriver) {
	intDriverCtorsRWL.Lock()
	defer intDriverCtorsRWL.Unlock()
	intDriverCtors[strings.ToLower(name)] = ctor
}
1093422
func NewDriver(a BaseAdaptor, v ...time.Duration) *Driver {
	m := &Driver{
		name:       "Mavlink",
		connection: a,
		Eventer:    gobot.NewEventer(),
		interval:   10 * time.Millisecond,
	}

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

	m.AddEvent(PacketEvent)
	m.AddEvent(MessageEvent)
	m.AddEvent(ErrorIOEvent)
	m.AddEvent(ErrorMAVLinkEvent)

	return m
}
912852
func NewGroveBuzzerDriver(a DigitalWriter, pin string) *GroveBuzzerDriver {
	return &GroveBuzzerDriver{
		BuzzerDriver: NewBuzzerDriver(a, pin),
	}
}
169687
func NewGroveRelayDriver(a DigitalWriter, pin string) *GroveRelayDriver {
	return &GroveRelayDriver{
		RelayDriver: NewRelayDriver(a, pin),
	}
}
639949
func NewMAX7219Driver(a gobot.Connection, clockPin string, dataPin string, csPin string, count uint) *MAX7219Driver {
	t := &MAX7219Driver{
		name:       gobot.DefaultName("MAX7219Driver"),
		pinClock:   NewDirectPinDriver(a, clockPin),
		pinData:    NewDirectPinDriver(a, dataPin),
		pinCS:      NewDirectPinDriver(a, csPin),
		count:      count,
		connection: a,
		Commander:  gobot.NewCommander(),
	}

	/* TODO : Add commands */

	return t
}
983825
func NewDriver(a ble.BLEConnector) *Driver {
	n := &Driver{
		name:          gobot.DefaultName("Ollie"),
		connection:    a,
		Eventer:       gobot.NewEventer(),
		packetChannel: make(chan *packet, 1024),
	}

	n.AddEvent(Collision)

	return n
}
413795
func NewHilSensor(TIME_USEC uint64, XACC float32, YACC float32, ZACC float32, XGYRO float32, YGYRO float32, ZGYRO float32, XMAG float32, YMAG float32, ZMAG float32, ABS_PRESSURE float32, DIFF_PRESSURE float32, PRESSURE_ALT float32, TEMPERATURE float32, FIELDS_UPDATED uint32) *HilSensor {
	m := HilSensor{}
	m.TIME_USEC = TIME_USEC
	m.XACC = XACC
	m.YACC = YACC
	m.ZACC = ZACC
	m.XGYRO = XGYRO
	m.YGYRO = YGYRO
	m.ZGYRO = ZGYRO
	m.XMAG = XMAG
	m.YMAG = YMAG
	m.ZMAG = ZMAG
	m.ABS_PRESSURE = ABS_PRESSURE
	m.DIFF_PRESSURE = DIFF_PRESSURE
	m.PRESSURE_ALT = PRESSURE_ALT
	m.TEMPERATURE = TEMPERATURE
	m.FIELDS_UPDATED = FIELDS_UPDATED
	return &m
}